1

i want to extract the first image from every second of video. i have a command line, based on the video's timecode, that works correctly when the video is progressive, but not when interlaced (only the first field is output in that case, creating a half-height image). i've tried various combinations of bwdif with select but the filter chains i create either cause errors or still return a half-sized image. can someone help me with the syntax ?

here is my call w/a filter that works correctly for progressive video source :
ffmpeg -i $infile -vf "select='if(eq(n\,0),1,floor(t)-floor(prev_selected_t))" -vsync 0 $outfile

the following still return only half-height images for interlaced source :
... -vf "bwdif=0,select='if(eq(n\,0),1,floor(t)-floor(prev_selected_t))'"

... -vf "bwdif=0,select='between(mod(n\,$ips)\,1\,2)'" -- $ips is images per second

... -vf "select='between(mod(n\,$ips)\,1\,2)',bwdif=0"

...and on a related note, is there some truly complete, exhaustive documentation anywhere on the select filter ? (no, i don't consider 'ffmpeg filters' chapter 16.16 exhaustive).

thanks.

2
  • I don't follow what the role of these select statements, but have you tried yadif for deinterlacing? Commented Dec 14, 2021 at 16:55
  • @SaaruLindestøkke yes, both yadif and bwdif will deinterlace. however, i still need to specify the constraint that i want only the first frame of each second (which is the first two fields of an interlaced video). that is what select does. Commented Dec 16, 2021 at 8:01

1 Answer 1

0

it turns out the solution is to use the tinterlace filter first. this causes the half-height frames to be reinterlaced before deinterlacing them as FULL frames with bwdif. the full command line that worked for me was :

ffmpeg -i $infile -vf "tinterlace=mode=merge,bwdif=0,select='if(eq(n\,0),1,floor(t)-floor(prev_selected_t))" -vsync 

many thanks to the responder named Gyan (maybe the same who does ffmpeg development ?) on a thread in stackoverflow.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .