Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made a broken footage using the following pipeline:

gst-launch-1.0 v4l2src ! filesink location=encode.mjpeg

Somehow gstreamer can still play it back:

gst-launch-1.0 filesrc location=encode.mjpeg ! jpegdec ! videoconvert ! xvimagesink

However as I by mistake didn't use any container, the stream is played back at a very fast pace framerate=(fraction)0/1. Is there any way to convert my broken file into an .avi or any other container without recompression?

The following trivial muxing didn't work as expected:

gst-launch-1.0 filesrc location=encode.mjpeg \
    ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! avimux \
    ! filesink location=encode.avi . -v

Somehow gstreamer plays encode.avi back very slowly at ~1 FPS without consuming significant CPU. And neither Vlc` nor Adobe Aftereffects can import it - they only display a correctly decoded stipe of the first frame at the top.

share|improve this question

The problem you're having with muxing into avi is related to the fact that filesrc is providing buffers to avimux that are not properly aligned to the mjpeg frames, so avimux is creating samples with wrong alignment internally, making it harder for players to use them later during playback.

This can be fixed by using a mjpeg parser after the capsfilter (jpegparse?). Another option is to decode and reencode the samples to get them aligned and muxed properly. The following pipeline should work:

gst-launch-1.0 filesrc location=encode.mjpeg \
! 'image/jpeg,framerate=30/1,width=1280,height=720' ! decodebin ! videoconvert ! \
<some encoder> ! <some muxer> ! filesink location=outputfile

You can select the encoder and muxer you like, you can even encode them back to jpeg and mux into avi, as you wanted initially.

Edit: To attempt to mux the content into avi without decoding, try something like:

gst-launch-1.0 filesrc location=encode.mjpeg \
    ! 'image/jpeg,framerate=30/1,width=1280,height=720' ! jpegparse ! avimux \
    ! filesink location=encode.avi . -v

If jpegparse does it job very well, the ''image/jpeg,framerate=30/1,width=1280,height=720'' shouldn't be required.

share|improve this answer
without recompression - recompressing with mjpeg apparently decreases quality as quantization settings are different in camera and in jpegenc. – nponeccop Sep 17 '13 at 17:40
If remuxing without decompressing still doesn't work you can try looking at jpegenc quality property by doing: gst-inspect-1.0 jpegenc and setting it to a higher level to see if it improves your situation. In gst-launch you set properties after the element with: jpegenc quality=<somevalue> – thiagoss Sep 18 '13 at 14:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.