identify command requires mpeg2decode

Bug #59908 reported by Bart Kroon
4
Affects Status Importance Assigned to Milestone
ImageMagick
Fix Released
Undecided
Unassigned
imagemagick (Debian)
Fix Released
Unknown
imagemagick (Mandriva)
Unknown
Medium
imagemagick (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

The ImageMagick identify command requires mpeg2decode to provide information on videos. mpeg2decode is however not available. There is no dependency and also no information on this topic in the description of the Ubuntu imagemagick package.

user@host:~ $ identify sample.mpg
sh: mpeg2decode: command not found
identify: Delegate failed `"mpeg2decode" -q -b "%i" -f -r -o3 "%u%%d"'.

Revision history for this message
Kjell Braden (afflux) wrote :

Can confirm this on up-to-date hardy, imagemagick 7:6.2.4.5.dfsg1-2ubuntu1. I can't find any package for mpeg2decode.

Changed in imagemagick:
status: New → Confirmed
Kjell Braden (afflux)
Changed in imagemagick:
importance: Undecided → Low
Revision history for this message
Ed S (ed-spittles) wrote :

I believe mpeg2decode in this case is the old and abandoned reference decoder available from http://www.mpeg.org/MPEG/video/mssg-free-mpeg-software.html

It seems to be copyright but freely distributable.

I believe the invocation will attempt to identify all frames, which could take a long time. I'd suggest identify shouldn't try to do this operation in this way. I notice that 'file' is able to identify some *mpg files:
mpeg_target_practice.mpg: MPEG sequence, v1, progressive Y'CbCr 4:2:0 video, SVCD NTSC 525, 30 fps
cbp.mpg: MPEG sequence, CIF NTSC, 29.97 fps
and is perhaps a better tactic (and dependency)

Revision history for this message
Fabio Hecht (fabiovh) wrote :

Is there any workaround?

I'm getting

[code]
$ mogrify -format JPG soft/timelapse/20080422-timelapse.bak.mpg

sh: mpeg2decode: command not found

mogrify: Delegate failed `"mpeg2decode" -q -b "%i" -f -r -o3 "%u%%d"'.

[/code]

Changed in imagemagick:
status: Unknown → Confirmed
Revision history for this message
ilmarw (ilmar-wilbers) wrote :

I am having the exact same problem using animate.
Version: 7:6.3.7.9.dfsg1-2ubuntu1

ilmar

Revision history for this message
Adam Williamson (awilliamson) wrote :

mpeg2decode and mpeg2encode are the very old MPEG reference encoder and decoder. The problem for distros is they are not F/OSS - the license does not mention modification or redistribution rights, and you can't consider them as implied. So we can't package them.

I've looked at patching ImageMagick to use something else. I think I have a replacement that will work for decoding: this is quite simple, it just involves replacing the 'mpeg2decode' command ImageMagick uses with an ffmpeg command that does the same thing.

Encoding is not so straightforward. The problem is that mpeg2encode uses a weird system that nothing else uses. The command is very simple - mpeg2encode in.par out.mpeg . The trickery is all in the .par file, which is essentially a one-time job configuration file: it specifies all the details about what you actually want to encode. In the ImageMagick source, coders/mpeg.c contains a big bunch of code to write an appropriate .par file for the operation.

No modern, F/OSS encoder that I've found seems to be able to understand .par files. They all expect you to just feed them a series of images direct on the command line, which is a completely different system. So to migrate ImageMagick from mpeg2encode to something modern you'd have to substantially change mpeg.c to just feed out a series of YUV images, not write a .par file, and call the delegate properly, *then* change the delegate from mpeg2encode to mpeg2enc or ffmpeg or mencoder or whatever you want to use. Unfortunately, my (non-existent) C skills don't extend to that, really, though I may give it a bash.

I'll attach patches when I have something I know works.

Revision history for this message
Nelson A. de Oliveira (naoliv) wrote : Re: [Bug 59908] Re: identify command requires mpeg2decode

Hi!

On Fri, Aug 8, 2008 at 3:35 PM, Adam Williamson
<email address hidden> wrote:
> No modern, F/OSS encoder that I've found seems to be able to understand
> .par files. They all expect you to just feed them a series of images
> direct on the command line, which is a completely different system. So
> to migrate ImageMagick from mpeg2encode to something modern you'd have
> to substantially change mpeg.c to just feed out a series of YUV images,
> not write a .par file, and call the delegate properly, *then* change the
> delegate from mpeg2encode to mpeg2enc or ffmpeg or mencoder or whatever
> you want to use. Unfortunately, my (non-existent) C skills don't extend
> to that, really, though I may give it a bash.

We can discuss this with upstream. At least from my experience, they
are very responsive and open to talk about problems, suggestions, etc.

Best regards,
Nelson

Revision history for this message
Adam Williamson (awilliamson) wrote :

I have done:

http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=11827&p=38454#p38454

They say:

"A patch from you or another user is the best path to getting this into the ImageMagick source base as quickly as possible. We are in agreement with you but the ImageMagick developers are currently swamped and we will not get to this problem for a minimum of several months."

Unfortunately I can't my patch to work. :( It needs someone with a better understanding of how exactly the code works. I can give a few pointers, though, if it helps anyone else.

The actual commands used are in magick/delegate.c and config/delegates.xml.in (the latter seems to be the one that's actually operative, at least in my case). For the mpeg case, these are called from coders/mpeg.c , so you need to look at that to see exactly what it does, too.

Currently ImageMagick uses this command for decoding:

command="&quot;mpeg2decode&quot; -q -b &quot;%i&quot; -f -r -o3 &quot;%u%%d&quot;

which basically works out to:

mpeg2decode -q -b (input) -f -r -o3 (output)

where %i is the input and %u%%d is the output. I'm not quite sure how %u%%d *works* - that's the bit I can't figure out and I think is what's preventing me from patching it properly.

The following ffmpeg command does something rather similar:

ffmpeg -i (input) -vcodec ppm -an -f rawvideo (output)

but just substituting it in the most logical way doesn't work. I'm missing something here but I'm not sure what. The logical "mpeg2dec" program, btw, doesn't actually seem capable of doing what's needed (for one thing it doesn't seem possible to control the output filenames).

You don't need to keep rebuilding to test modifications. The installed ImageMagick package will contain a file named delegates.xml , somewhere like /usr/lib/ImageMagick-6.4.2/config/ . You can edit this and change the command directly in there - the change will be applied the next time you run an ImageMagick command.

You can test with simply 'identify file.mpg' . If it's working right, you should get something like:

[adamw@lenovo ~]$ identify movie.mpg
movie.mpg=>/home/adamw/tmp/magick-XXRc9qGL0.ppm[0] MPEG 128x128 128x128+0+0 8-bit DirectClass 48kb

(repeated a lot of times, use a short movie).

For encoding it gets more complex, but again the basic thing is you need to look at what mpeg.c does - in this case it'll need to be changed - and then adjust the delegate to a modern command (probably mpeg2enc , which most distros package).

I'll see if I can find all discussions of this issue in various places and link them together...

Changed in imagemagick:
status: Unknown → In Progress
Revision history for this message
Adam Williamson (awilliamson) wrote :

OK, the ImageMagick folks have fixed the decoding side of things (which is the easy bit). As per http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=11827 , SVN trunk now uses ffmpeg for decoding, not mpeg2decode . Encoding isn't done yet.

Revision history for this message
Adam Williamson (awilliamson) wrote :

Both encoding and decoding are now fixed in upstream ImageMagick. Any version since 6.4.2.10 should be OK, so this bug can be closed relative to any distro release that includes ImageMagick 6.4.2.10 or later.

Kjell Braden (afflux)
Changed in imagemagick:
status: New → Fix Released
Changed in imagemagick:
status: Confirmed → Fix Released
Revision history for this message
Kjell Braden (afflux) wrote :

Fix is in jaunty with version 7:6.4.5.4.dfsg1-1ubuntu1.

Changed in imagemagick:
status: Confirmed → Fix Released
Changed in imagemagick:
status: In Progress → Confirmed
Changed in imagemagick (Mandriva):
status: Confirmed → Invalid
Changed in imagemagick (Mandriva):
status: Invalid → Unknown
Changed in imagemagick (Mandriva):
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.