ImageMagick6
ImageMagick6 copied to clipboard
Regression in support of MPEG video after coder name-change to "video"
ImageMagick version
6.9.11-60
Operating system
Linux
Operating system, version and so on
Ubuntu 22.04
Description
The new "video" coder doesn't declare an "MPEG" format anymore, but there's several leftovers in the code referring to it, i.e.:
- https://github.com/ImageMagick/ImageMagick6/blob/3b18a98dfb1e614a7a95716b8629326e4901318a/coders/video.c#L375
- https://github.com/ImageMagick/ImageMagick6/blob/78395b3affd854ff8aa349e42767202d30f574a0/magick/coder.c#L190
- https://github.com/ImageMagick/ImageMagick6/blob/78395b3affd854ff8aa349e42767202d30f574a0/magick/magic.c#L148
The result is that IM detects MPEG-1 ".mpeg/.mpg" video files as the MPEG format but doesn't know what to do from there. You can work around it by explicitly specifying the format of any of the video formats that are registered, but by default it will "magic" detect the format MPEG and fail (and of course manually specifying the format MPEG also fails).
I assume that this was just a bit of a mistake/confusion since MPEG used to be the generic coder name before it was changed to VIDEO.
Steps to Reproduce
$ identify test.mpg
From IM 6.9.11-60:
identify: no decode delegate for this image format `MPEG' @ error/constitute.c/ReadImage/575.
While IM 6.9.10-23 works. As does identify "MP4:test.mpg" on 6.9.11.
Images
No response
We could not reproduce this issue with the latest release of ImageMagick version 6 (6.9.12-54) or 7 (7.1.0-39). Upgrade your release and you should get expected results.
The problem doesn't exist in latest 7, but I do still reproduce in 6. Built from current main branch:
Version: ImageMagick 6.9.12-55 beta Q16 x86_64 e76b0f833:20220620 https://legacy.imagemagick.org
identify: no decode delegate for this image format `MPEG' @ error/constitute.c/ReadImage/576.
The 7 codebase contains code registering the MPEG format with the video coder that is absent in 6.
Looking more closely, what happened here is that the 6 version of the change to the "video" coder made a (presumed) mistake that the 7 version did not: it changed the MPEG format registration to VIDEO as well. So if you look at 6 vs 7, 6 now has a VIDEO format in -list format that's absent from 7 (and of course there's the basis of this issue: -list format on 6 is missing MPEG).
I linked to a line in the 7 codebase in my last comment. Note that the corresponding line in 6 registers the format VIDEO where 7 (and old versions of 6) register MPEG.
Recompiling with this change applied resolves the issue.
A simpler version that just changes the string on video.c's line 282 from "VIDEO" back to "MPEG" would also do it, though would be a possible issue for anyone having come to rely on the presence of the VIDEO format, since it has now existed in 6 for a while.
Thanks for the problem report. We can reproduce it and will have a patch to fix it in the GIT main branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://imagemagick.org/download/beta/ by sometime tomorrow.