I am tinkering with my two Raspberry Pis and would like to do the following:

Both Pis record via a camera and stream it via cvlc to the network. Then one of them uses both streams to make a single stream wich alternates between both sources every 30 seconds. My setup is as below:

Pi 3 ( and Pi 4 ( both use the following command to stream the camera feed to my local network:

raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264

The Pi 4 then uses

ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -f concat -safe 0 -i stream_list.txt -c copy output.mp4

with content of stream_list.txt being:

file http:\/\/
duration 00:00:02.00
file http:\/\/
duration 00:00:02.00

I use output.mp4 as test, this will be a twitch server or somewhat. The current duration is 2 seconds just for testing as well. And I will add a loop -1 to keep switching. My problem is that the process doesnt stop after 4 seconds. It keeps "recording" forever until I CTRL+C and then output.mp4 only contains the camera feed of the first mentioned stream in the stream_list.txt. It doesn't stop after 2 seconds switches to the other stream and then stops after another 2 seconds as I expected.

Is there something that I am essentially doing wrong or am I at least somewhat on the right way?

  • Replace duration 00:00:02.00 with outpoint 00:00:02.00. For looping, you would add -stream_loop -1 – Gyan Jan 2 at 5:14

Your Answer

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

Browse other questions tagged or ask your own question.