To start streaming camera video, we simply combine
ffmpeg by piping one into another.
raspivid -t 0 -w 1280 -h 720 -fps 25 -g 75 -fl -o - | ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i pipe:0 -c:v copy -c:a aac -strict experimental -f flv -f flv rtmp://ip:port/app/stream
-t 0: Continuously pull video from the camera
-w 1280 -h 720 -fps 25: Video stream of 720p25
-g 75: I-frame interval at 1/s
-o -: Pipe video to
-f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100and
-c:a aac -strict experimental: Since the RaspberryPi doesn't have a microphone, we can pipe some silence instead. This is very optional and depends on your use case.
-i pipe:0 -c:v copy: Read the video stream from
stdin. The video stream from
raspividis already encoded in
h264, so we skip re-encoding by using
-f flv rtmp://ip:port/app/stream: The destination.
Originally published at blog.helveticode.com on July 13, 2016.