2

I'm struggling with ffmpeg. My webcam can do 720p at 30fps, but only when using the MJPEG codec:

~> v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'YUYV'
        Name        : YUV 4:2:2 (YUYV)


-- cut -- 

                Size: Discrete 1280x720
                        Interval: Discrete 0.133 s (7.500 fps)
                        Interval: Discrete 0.200 s (5.000 fps)
-- cut --

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'MJPG' (compressed)
        Name        : MJPEG


-- cut -- 
                Size: Discrete 1280x720
                        Interval: Discrete 0.033 s (30.000 fps)
                        Interval: Discrete 0.040 s (25.000 fps)
                        Interval: Discrete 0.050 s (20.000 fps)
                        Interval: Discrete 0.067 s (15.000 fps)
                        Interval: Discrete 0.100 s (10.000 fps)
                        Interval: Discrete 0.200 s (5.000 fps)

-- cut --

I can't figure out how to tell ffmpeg to read the MJPEG compressed format. It is trying to read the raw variant, which ends up with horrible quality.

3

You don't say what options you're using but I did find these 2 examples. Do these work for you?

ffmpeg -i <input_file> -vcodec mjpeg -qmin 1 -qmax 1 -o <output_file.avi>
ffmpeg -i <input_file> -vcodec mjpeg -qscale 1 <output_file.avi>

For the second example, I found a note that mentioned that the -qscale ... switch made a noticeable difference. The lower your x, the better is the quality (range 2 to 32, fractions allowed).

  • Hmm, interesting, I already tried that, but it would seem that this is actually correct. It's just my webcam being incredibly temperamental (starts recording once out of five attempts). – Let_Me_Be May 17 '13 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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