IoT
May 23, 2020
The raspivid + ffmpeg streaming pitfall
It's common to find the following pattern over the Internet to stream a video from a Raspberry Pi camera to YouTube:
raspivid -o - ... | ffmpeg ... -f h264 -i - ...
In this case raspivid
produces a stream on its own rate and it does not care whether the stream can actually be handled. Should a network glitch happen, frames get bufferized effectively creating a memory leak. Eventually, system runs out of memory and becomes unresponsive. For me it happened randomly in a few hours up to a few days of uptime.
I didn't observe the same issue with the Video4Linux input:
ffmpeg ... -f video4linux2 -i /dev/video0 ...