6

I'm trying to extract frames from a variable framerate video every 5 seconds and get the exact timestamps of each frame extracted. This is what I have so so far:

-i inputfile -vstats_file vstats.log  -vsync 2 -vcodec png -r 0.2 -f image2pipe -

And this is what I get:

frame=     1 q= 0.0 f_size= 136261 s_size=      133kB **time= 5.000** br=   218.0kbits/s avg_br=   218.0kbits/s type= I
frame=     2 q= 0.0 f_size= 139382 s_size=      269kB **time= 10.000** br=   223.0kbits/s avg_br=   220.5kbits/s type= I
frame=     3 q= 0.0 f_size= 141631 s_size=      407kB **time= 15.000** br=   226.6kbits/s avg_br=   222.5kbits/s type= I

I need the exact timestamp of the frame that was used for extraction, so I can later accurately cut the video based on thumbnails generated.

Also, is there a way to print vstats to stdout rather than a file?

1
  • non-ffmpeg solutions are fine too, as long as it's a command-line tool.
    – Mango
    Commented Jun 7, 2012 at 15:10

1 Answer 1

3

i'm not sure what you tried to do, but if it works for you then it's ok...

Anyway, for skipping frames I would have use SELECT video filter (make sure you have libavfilter enable). For frames infoI would have used SHOWINFO video filter.

Your command should be something like the following:

ffmpeg -i inputfile -vf '[in]select=not(mod(n\,150))[s1];[s1]showinfo[out]' -vcodec mpeg2video outputfile

(where 150 frames are 5sec * 30fps)

2
  • 3
    showinfo is exactly what I needed, thanks. By the way, for a variable framerate video I used select='isnan(prev_selected_t)+gte(t-prev_selected_t,5)' to get a frame every 5 seconds.
    – Mango
    Commented Jun 12, 2012 at 17:32
  • @Mango 'isnan(prev_selected_t)+gte(t-prev_selected_t,5)' this filter does not work for me, is it still valid?
    – bendaf
    Commented Aug 2, 2018 at 7:24

You must log in to answer this question.

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