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

Javier Infante Porro jabi at irontec.com
Thu Jun 27 11:59:30 EEST 2019


----- Mensaje original -----
> De: "Moritz Barsnick" <barsnick at gmx.net>
> Para: "FFmpeg user discussions" <ffmpeg-user at ffmpeg.org>
> Enviados: Jueves, 27 de Junio 2019 9:27:04
> Asunto: Re: [FFmpeg-user] pipe from /dev/video to /dev/video adding a delay - syncing issues
> 
> On Wed, Jun 26, 2019 at 21:17:11 +0200, Javier Infante Porro wrote:
> > 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.
> [...]
> > 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
> 
> The input image is processed "as fast as possible" by ffmpeg, while the
> v4l2 input stream is "realtime" by nature.
> 
> It should suffice to add "-re" as an input option to the first input:
> 
> $ ffmpeg -loglevel 43 -y -re -loop 1 -r 28 -t 20 -i bg.jpg -f v4l2 [...]
> 

Yes! It works as you are describing with the countdown.
Thank you very much Moritz!

So I have a countdown, but when it's done, the video source tries to catch up  with "reality" really fast... 
I have been trying to play with the setpts filter, but still no luck...


TIME=5
ffmpeg -y -re \
  -loop 1 -r 28 -t $TIME -i bg.jpg \
  -f v4l2 -thread_queue_size 512 -framerate 28 -i /dev/video30 \
  -filter_complex \
   "[0:v:0]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\:$TIME+1-t\:d}\'[count]; \
   [1:v:0]fps=28,setpts=PTS+$TIME/TB[live];[count] [live] 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?





More information about the ffmpeg-user mailing list