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?

Darth Vader
  • 4,218
  • 24
  • 47
  • 70
weirdgyn
  • 122
  • 2
  • 15

1 Answers1

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.

weirdgyn
  • 122
  • 2
  • 15