Advertisement
Guest User

ffmpeg from /dev/video to /dev/video with delay

a guest
Jun 26th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.26 KB | None | 0 0
  1. # I create my virtual video device:
  2. modprobe v4l2loopback exclusive_caps=1 video_nr=20 card_label="LIVE"
  3.  
  4. # The command writting to file works pretty good (an initial 20 seconds countdown with bg.jpg background):
  5.  
  6. 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
  7.  
  8.  
  9.  
  10. # But whenever i try to push the stream back to the the /dev/video20 device, it works, but the countdown goes fast, and then video tries to catch up and keeps around a 2 second delay:
  11. 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement