0

I try to switch 2 video from webcam with 1 audio file looped, every 30 seconds (f.e.), but i didn't find how ....

/dev/video0 /dev/video2

to broadcast the result on youtube (rtmp) via an RPi 3+

Someone can help me ? or lightup for a way ... ?

FoxFr
  • 23
  • 4
  • Yes many thanks llogan, just one extra question : can you explain how add a third input (image png for example) ? – FoxFr Mar 07 '21 at 09:02
  • What should the image do? Simple overlay? – llogan Mar 07 '21 at 18:25
  • Not overlay, brodcast a static image and can be change to display the new one – FoxFr Mar 09 '21 at 07:10
  • More clearly, i wish to broadcated a static image updated each minutes with ffmpeg -i image.png after 30" i encounte an error av_interleaved_write_frame(): Broken pipeB time=00:00:06.06 bitrate=4854.5kbits/s speed=0.0448x Last message repeated 1 times [flv @ 0x966740] Failed to update header with correct duration. [flv @ 0x966740] Failed to update header with correct filesize. Error writing trailer of rtmp://a.rtmp.youtube.com/live2/7gea-b563-947u-jqy1-8hz4: Broken pipe – FoxFr Mar 09 '21 at 13:30
  • Need to see your command and the complete log to be able to help. – llogan Mar 09 '21 at 20:33
  • llogan, i'd understand one things, if i use a jpg file its ok but worst with png, can you help me for https://stackoverflow.com/questions/66483613/brodcast-png-video-ffmpeg-with-raspberry?noredirect=1 ? – FoxFr Mar 10 '21 at 13:31

1 Answers1

0

Switch webcams every 30 seconds and live stream

Use the overlay filter with enable option using lt and mod functions:

ffmpeg -i /dev/video0 -i /dev/video2 -stream_loop -1 -re -i audio.mp3 -filter_complex "[0][1]overlay=enable='lt(mod(t,60),30)'[v]" -map "[v]" -map 2:a -c:v libx264 -b:v 4000k -maxrate 4000k -bufsize 8000k -g 50 -c:a aac -f flv rtmp://youtube
llogan
  • 121,796
  • 28
  • 232
  • 243