Here is an avi movie (204*432 Pixels) which contains 22 different images with numbers from 1 to 22. I tested e.g. with VirtualDub and MATLAB that all extracted images are different.
Movie: https://drive.google.com/open?id=0B9wKP6yNcpyfUE1hb0UyNXhDRFk
(5.5MB)
When I extract the images with the mathematica code below image 20 is same as image 19. All the rest is correct.
The two same images are seen here:
Import[avifile, {"AVI", "ImageList", Range[19, 20, 1]}]
The error occurs due to the non integer
FrameRate
:Import[avifile, {"FrameRate"}] 15.7143
VirtualDub and other software do not care about the frame rate. They simply extract sequentially image by image and the result is corrrect:
{Import["virtualdub_000019.png"], Import["virtualdub_000020.png"]}
Do you know a solution for mathematica?
My code for extracting grayscale images is:
avifile = "20170623_movie_for_testing_duplicate_images.avi";
numberImages = Length@Import[avifile, "Frames"]
22
Do[
image = ColorConvert[Import[avifile, {"Frames", i}], "Grayscale"];
fileNameCounter = ToString@PaddedForm[i, 6, NumberPadding -> {"0", ""}];
Export[StringJoin[fileNameCounter, ".png"], image];
, {i, 1, numberImages}
];
For comparison here are all extracted
mathematica images: https://drive.google.com/open?id=0B9wKP6yNcpyfVFRtRm4tTjhMVTQ
VirtualDub images: https://drive.google.com/open?id=0B9wKP6yNcpyfc2s0a1BGR3l1NjA
Import[avifile,"ImageList"]
and extract the frames you want withPart
? (That will likely be faster anyway unless the file is too big to load in memory all at once ) $\endgroup$Import[..., "ImageList"]
. $\endgroup$