[FFmpeg-user] pipe from /dev/video to /dev/video adding a delay - syncing issues

Javier Infante Porro jabi at irontec.com
Wed Jun 26 22:17:11 EEST 2019


Hello, 

I am trying to create a video device using another video device, adding a 20 seconds extra delay. 
Also, i will create on the fly a custom countdown video before my delayed stream starts. 











I create my virtual video device using v4l2loopback: 

modprobe v4l2loopback exclusive_caps=1 video_nr=20 card_label="LIVE" 







The command writting to file works pretty good (an initial 20 seconds countdown with bg.jpg background): 



ffmpeg -loglevel 43 -y -loop 1 -r 28 -t 20 -i bg.jpg -f v4l2 -thread_queue_size 512 -i /dev/video0 -filter_complex "[0:v:0]setpts=N/(28*TB),drawtext=fontfile='/usr/share/fonts/truetype/msttcorefonts/Georgia.ttf':fontcolor=yellow:fontsize=40:x=(w-text_w)/2:y=(h-text_h)/2:text='%{eif\:20-t\:d}'[count]; [count] [1:v:0] concat=n=2:v=1:a=0:unsafe=1 [v];[v]scale=852:480[out]" -map "[out]" -an -pix_fmt yuv420p -c:v libx264 -preset ultrafast s1.mp4 


But whenever i try to push the stream back to the the /dev/video20 device, it works, but the countdown goes real fast (like 10x faster), and then video tries to catch up and keeps around a 2 second delay: 





ffmpeg -loglevel 43 -y -loop 1 -r 28 -t 20 -i bg.jpg -f v4l2 -thread_queue_size 512 -i /dev/video0 -filter_complex "[0:v:0]setpts=N/(28*TB),drawtext=fontfile='/usr/share/fonts/truetype/msttcorefonts/Georgia.ttf':fontcolor=yellow:fontsize=40:x=(w-text_w)/2:y=(h-text_h)/2:text='%{eif\:20-t\:d}'[count]; [count] [1:v:0] concat=n=2:v=1:a=0:unsafe=1 [v];[v]scale=852:480[out]" -map "[out]" -an -pix_fmt yuv420p -f v4l2 -r 28 /dev/video20 


Any ideas on how to output as v4l2 correctly or achiving what i am trying using another approach? 

Thanks in advance! 


-- 
Jabi 


More information about the ffmpeg-user mailing list