2

I'm trying to create a h264 stream from my Pi 3 and display it on an Android application.

After several attempts I found quite a simple solution:

raspivid -n -ih -t 0 -w 640 -h 480 -fps 25 -b 2000000 -l -o - | nc -l -p 5000

It works fine and I can play it through a common app like VLC on Windows:

vlc tcp/h264://my_pi_address:5000/

This stream can also be viewed on Android using a custom application (RPi Camera Viewer).

Reading PiCamera docs I found another solution using Python that should act the same way:

import socket
import time
import picamera

camera = picamera.PiCamera()
camera.resolution = (640, 480)
camera.framerate = 24

server_socket = socket.socket()
server_socket.bind(('0.0.0.0', 8000))
server_socket.listen(0)

# Accept a single connection and make a file-like object out of it
connection = server_socket.accept()[0].makefile('wb')
try:
    camera.start_recording(connection, format='h264')
    camera.wait_recording(60)
    camera.stop_recording()
finally:
    connection.close()
    server_socket.close()

Tested through VLC it works fine but I'm unable to view this stream in Android. (At least not with RPi Camera Viewer).

I think one problem may come from minor differences between the stream's structures so how can I compare them?

1

Issues in Android app visualization were given by a faulty network connection.

It is pretty difficult to say what happens in detail because I cannot investigate further on access point configuration and other network settings (including firewalls) active on company network since I've not network admin privileges, This's pretty frustrating. As a matter of fact using a different access point everything works as expected.

2
  • 2
    Could you please elaborate on "faulty network connection"? – Darth Vader Sep 1 '20 at 11:59
  • this's pretty difficult to say because I cannot investigate further on access point configuration or other network settings (including firewalls) active on company network since I've not network admin privileges.. this's pretty frustrating. As a matter of fact using a different access point everything works as expected. – weirdgyn Sep 1 '20 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.