[FFmpeg-user] Extract image every x frames?
Stefano Sabatini
stefasab at gmail.com
Tue Aug 7 23:25:06 CEST 2012
On date Tuesday 2012-08-07 14:38:13 +0200, Peter B. encoded:
> Quoting Nicolas George <nicolas.george at normalesup.org>:
>
> >Le primidi 21 thermidor, an CCXX, Peter B. a écrit :
> >>However, it's incredibly slow!
> >>When I extract the keyframes using the looping method, it's done in a
> >>second, whereas using the "-vf select" filter it takes almost 15
> >>minutes (!) to process a 30 minute ffv1 PAL/SD file.
> >>
> >>The image file for the first frame (frame #0) is written after a few
> >>seconds, whereas I'd assume that it should be instant, no?
> >>
> >>Am I doing something wrong?
> >
> >You are doing nothing wrong: filters work with decoded frames, so even if
> >you want to extract only one frame out of 1500, all must be decoded, even
> >those that do not change the output at all. Doing things more efficiently is
> >possible, but would be more complex, and nothing is implemented in ready to
> >use solutions.
>
> Ah, ok!
> Makes perfect sense now. Thank you very much for the explanation.
Best way to solve the issue is through scripting. You copy/link
the files matching a certain pattern, like in (completely untested):
ORIG_IDX=0
ORIG_IDX_STEP=1500
NEW_IDX=0
while [ -e ORIG-$n.png ]; do
ln -s NEW_${NEW_IDX}.png ORIG_${ORIG_IDX}.png
ORIG_IDX=$(($ORIG_IDX+$ORIG_IDX_STEP))
NEW_IDX=$(($NEW_IDX+1))
done
then you do:
ffmpeg -framerate -i 'NEW_%d.png' OUTPUT
Alternatively we could implement -number_step option, see:
https://ffmpeg.org/trac/ffmpeg/ticket/1445
but I'm not yet convinced that would be a good idea.
As for testing select, consider using showinfo filter like in:
select=...,showinfo
--
ffmpeg-user random tip #3
Some few multimedia formats (mpeg-1, mpeg-2:PS, DV) support physical merge
consistency, which means you can merge two files with cat. E.g.:
cat input1.mpeg input2.mpeg > output.mpeg
See: http://www.ffmpeg.org/faq.html#SEC25
More information about the ffmpeg-user
mailing list