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
Answer
Solution:
The error described below has nothing to do with mathematica (as you veryfied it) but with Quicktime. Mathematica used the Quicktime decoder which produced the mistake. Quicktime extracts image 20 as beeing the same as image 19.
After deinstalling Quicktime mathematica extracts the images correctly.
Thanks to everybody, especially for the hint of Theo Tiger who wrote: Can it be a codec issue?
See also these links:
https://github.com/SimonWoods/MathMF/
https://github.com/kmisiunas/ffmpeg-mathematica
"Mathematica's (v9 or v10) default methods uses QuickTime that produces artifact in uncompressed videos or duplicated frames."
Comments
Post a Comment