-   Linux - General (
-   -   MJPEG movie to JPEG without quality loss (

danielsbrewer 07-07-2008 09:59 AM

MJPEG movie to JPEG without quality loss
My camera produces movies in MJPEG format with audio. With some of these I have filmed them in portrait rather than landscape and so when played they are the wrong way round. I would like to rotate them.

It is my understanding that MJPEGs are just made up of JPEG images and so one should be able to extract the JPEGs, rotate them using jpegtran and then put them back together, combining them with the audio.

Anyone got any idea or a simple script to do this.

I was looking at mplayer/mencoder but this reduces the quality.

matthewg42 07-07-2008 10:38 AM

Is MJPEG really just a series of JPEGS - effectively every frame being a key frame? If so then it might be possible. If not then I think it's inevitable that you will have quality loss.

danielsbrewer 07-07-2008 10:45 AM

This is what wikipedia says:

"In multimedia, Motion JPEG (M-JPEG) is an informal name for multimedia formats where each video frame or interlaced field of a digital video sequence is separately compressed as a JPEG image"

I should say that the container is an AVI.

matthewg42 07-07-2008 11:11 AM

What mplayer / mencoder commands are you using?

danielsbrewer 07-08-2008 06:29 AM

I'm not using mplayer/mencoder as they would decompress the jpegs and then recompress.

I am getting somewhere using and the almara tools.

The only problem I have is that the resulting movie cannot not be played by mplayer. This is the output of the rotated movie:

VDec: vo config request - 480 x 640 (preferred colorspace: Unknown 0x0000)
[PP] Using external postprocessing filter, max q = 6.
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.

Compared to the unrotated movie:
VDec: vo config request - 640 x 480 (preferred colorspace: Planar 422P)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
VDec: using Planar 422P as output csp (no 1)

I have isolated the problem to the jpegtran rotation step, it seems that after a jpeg is rotated (other transformations do not do this) it losses its color space and can not be opened by mplayer.

Any ideas?

matthewg42 07-08-2008 06:33 AM

none, sorry.

estabroo 07-08-2008 07:48 AM

You can rotate them during playback with mplayer with -vf rotate=1 (90 clockwise, man page shows a few other values for rotate). I know this doesn't give you a permanent change, but at least you would be able to watch them.

All times are GMT -5. The time now is 02:01 AM.