FFMPEG - How to Extract Frames As Images While Removing Sequentially Duplicate Frames

4.6k Views Asked by At

Is there any way (via script or preferably some parameter in calling ffmpeg that I missed) to extract frames from an avi file and ignore sequentially duplicate frames, thus being able to go through the pictures looking only at the deltas/changes?

I frequently have to record meetings at work and a lot of the time, the client screen that I am looking at is not changing while we are talking over the phone. After the meeting is over, I need to use these images as part of our documentation and specifications gathering.

I know that I could just output every frame and run them through any given duplicate file remover utility, but this would remove ALL duplicate frames. So, if the frames extracted went like this:

A, A, A, B, B, B, B, C, C, A, A, C, C, C, B, B, B ...

Running them through a typical duplicate file remover, I would get: A, B, C

What I would want is: A, B, C, A, C, B

The command that I am currently using to extract the images is:

ffmpeg.exe -i file.avi -ss 0 -sameq -f image2 -r 1 images%5d.png

I was getting every frame beforehand (removing the -r 1 from above), but that was generating way too many frames to deal with since these online meetings can go for hours, so for now, I get one frame per second from the file.

A Windows based solution would be preferable, however, I'm sure other people would be interested in solutions on other platforms if available.

Any solution or point in the right direction is much appreciated.

3

There are 3 best solutions below

4
On

Did you try with the -vsync 0 option?

0
On

After running ffmpeg, run a duplicate file finder.

Linux: fdupes -N -d *.png (http://code.google.com/p/fdupes/).

For dozens of similar tools, for Windows etc., see http://en.wikipedia.org/wiki/List_of_duplicate_file_finders .

0
On

You may reach it by mpdecimate video filter (followed by setpts filter for the correct timing).
Use this option:

-vf mpdecimate,setpts=N/FRAME_RATE/TB

Maybe it will not work with your original command and you will need use it to first converting your original video to the video without duplicated frames:

ffmpeg.exe -i file.avi -vf mpdecimate,setpts=N/FRAME_RATE/TB outfile.avi

and then use the outfile.avi for producing the sequence of images.

(In the case of need the filter mpdecimate may be adjusted by its options hi, lo and frac but the default values work fine.)