[FFmpeg-user] Recording From Video4Linux Device When Resolution Changes Midstream

Ide, Bruce (Contractor) Bruce_Ide at comcast.com
Thu May 23 21:34:19 EEST 2019


Hello ffmpeg users!

This might be a better question for ffmpeg-developers, but I thought I’d ask here, first.

I have a magewell HDMI capture card that provides a video4linux driver, and am recording the output of a digital set top box to a webm file with this command:

ffmpeg -thread_queue_size 4096 -f v4l2 -i /dev/video0 \
       -thread_queue_size 4096 -f alsa -i hdmi_audio_0 -ac 2 -ar 48000 \
       -f webm \
       -c:v libvpx -threads 4 -speed 6 -r 15 -b:v 512 \
       -c:a libopus -ac 2 -threads 4 -ar 48000  \
       /tmp/video0.webm

While doing this, I navigate to the settings menu on the digital set top box and change the resolution from 720p to 1080p. The magewell driver and video4linux both detect the resolution change immediately, but the resolution of the video I’m recording never changes. I seem to be getting video frames for my entire session, but they all seem to be at the same resolution.

Now I’d guess this is probably working-as-designed, I wouldn’t expect ffmpeg to detect a resolution change on a running stream like that. I suppose I can poll video4linux on a frame by frame basis and restart my ffmpeg encoding process if the resolution changes. In that case, I just can’t use the ffmpeg command line to continuously record the video file, if I’m going to change the resolution on the STB. Not a huge deal.

So my question is, what should happen in my video file at that point? Should I close the old resolution’s stream and create a new stream with a new stream number that picks up at the timestamp where the old video left off? I’m guessing I can’t just encode differently sized frames into the old stream. If I have a video that changes a resolution by encoding a new stream with a new resolution, would the entire video be played by ffplay/vlc/et al correctly? Would the webm player in chrome be able to handle that if I were doing it in a stream?


More information about the ffmpeg-user mailing list