5

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.

Michael Nelson
  • 131
  • 2
  • 6

3 Answers3

6

Did you try with the -vsync 0 option?

npinto
  • 393
  • 3
  • 7
  • That comes close, but when I tried it, `fdupes` still found more consecutive identical frames to cull. – Camille Goudeseune Oct 23 '13 at 21:40
  • 1
    +1 In my case (low frame rate) I had each frame duplicated 50 times. With this option there was only 1 duplicated frame for each 1000 non duplicated frames. – user2518618 Feb 26 '15 at 14:36
  • 1
    Came out in exactly the number of inputs frames for me. Perhaps there are some all black transition frames that are popping up as duplicates for the other commenters? – David Parks Mar 04 '17 at 18:20
  • Same. It gave me exactly the number of inputs frame. How's this actually working for others? – Innat Feb 17 '21 at 17:39
2

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 .

Camille Goudeseune
  • 2,934
  • 2
  • 35
  • 56
1

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.)

MarianD
  • 13,096
  • 12
  • 42
  • 54