shortstheory / APStreamline

Live Video Streaming Made Easy!
GNU General Public License v3.0
117 stars 35 forks source link

Raspberry Pi camera on HDMI output #14

Open jeroentaverne opened 3 years ago

jeroentaverne commented 3 years ago

I am using a Raspberry Pi with lite OS without running X. It would be very nice if the camera output is also shown on the HDMI output of the Raspberry Pi during IP streaming. The tool raspivid seems to create some non latency hardware connection between CSI port and HDMI output, and is also able to stream to IP at the same time. Example using VLC is: raspivid -o - -t 0 -w 1920 -h 1080 -fps 25 | cvlc -vvv stream:///dev/stdin --sout '#rtp{access=udp,sdp=rtsp://:8554/stream}' :demux=h264. This has off course limitations. Would it be possible to use raspivid for feeding video data into APStreamline? What could be the proper way of doing this?

shortstheory commented 3 years ago

Thanks for sharing this! That's a pretty cool feature but I'm afraid that workflow wouldn't suit APStreamline as it only works with cameras which support the V4L2 API. It looks like VLC is reading bytes from stdin and then streaming it using rtp/rtsp in the example you provided.

But I'm unclear how this works without trying it out. Without running X, how do you get any output on HDMI apart from the terminal prompt? Does the video just overlay on top of the screen?

If you are willing to go ahead with installing the full, GUI version of RPiOS, you might be able to stream and view the video at the same time using a v4l-loopback device. I haven't tried this out yet (and there is a chance it won't work because of APStreamline's live video adaptations breaking things). Could you tell me more about your use case? I'd love to hear more!

jeroentaverne commented 3 years ago

raspivid is just putting the video on top of the terminal prompt and erases the text that was there. It really looks like there is some hardware connection enabled between camera and framebuffer. If this "trick" could be added in the V4L2 API... I would like to stay away from the full GUI as it takes longer to boot, and is pretty useless as the project doesn't need any keyboard/mouse or running multiple GUI related applications, and I would like to end up with a read only filesystem, so the PI can survive power off without proper shutdown. With gstreamer it's also possible to get video on top of the terminal prompt without running X. Example: gst-launch-1.0 -v videotestsrc ! fbdevsink. fbdevsink is supported by gst-plugins-bad.

jeroentaverne commented 3 years ago

I tried this to get real time video on HDMI and an accessible /dev/video1 device.

In first terminal: I modified RPiCamera.cfg to use /dev/video1. $ sudo modprobe v4l2loopback devices=2 $ raspivid -fps 30 -w 1920 -h 1080 -t 0 -o - | ffmpeg -i pipe: -s 1920x1080 -vcodec rawvideo -f v4l2 /dev/video1 This seems to run fine at 30 fps

In second terminal: cd APStreamline ./build/stream_server eth0 After opening the stream using VLC (rtsp://172.16.0.196:8554/cam1) I get a Segmentation fault without any extra information

Any idea?

shortstheory commented 3 years ago

I'm not sure at the moment. I haven't yet tried out this particular use case, so I'll need some more time to try it out to figure out what's going on.