[FFmpeg-devel] MJPEG format and framerate

Stefano Sabatini stefano.sabatini-lala
Sun Jul 5 12:21:18 CEST 2009


Hi all,

I recently tried this command: 

stefano at geppetto ~/s/ffmpeg> ffmpeg -i tmp.avi -y out.mjpeg
[...]
Input #0, avi, from 'tmp.avi':
  Duration: 00:00:03.70, start: 0.000000, bitrate: 304 kb/s
    Stream #0.0: Video: h263, yuv420p, 176x144, 10 tbr, 10 tbn, 10 tbc
Output #0, mjpeg, to 'out.mjpeg':
    Stream #0.0: Video: mjpeg, yuvj420p, 176x144, q=2-31, 200 kb/s, 90k tbn, 10 tbc
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
frame=   37 fps=  0 q=7.7 Lsize=     170kB time=3.70 bitrate= 376.2kbits/s    
video:170kB audio:0kB global headers:0kB muxing overhead 0.000000%

Note that the resulting output framerate is shown as 10.

Then reproducing the file I get a playback 2.5x faster than the
original file:
stefano at geppetto ~/s/ffmpeg> ffmpeg -i out.mjpeg 
[...]
Input #0, mjpeg, from 'out.mjpeg':
  Duration: N/A, bitrate: N/A
    Stream #0.0: Video: mjpeg, yuvj420p, 176x144, 25 tbr, 1200k tbn, 25 tbc
At least one output file must be specified

I quickly read the code, and I couldn't find any framerate information
associated to an MJPEG stream/container, so ffmpeg is assuming the
input framerate to be 25 by default when reading an MJPEG file.

In order to get the expected result, I had to provide this command:
stefano at geppetto ~/s/ffmpeg> ffmpeg -i tmp.avi -r 25 -y out.mjpeg

I wonder if it would make sense to warn/fail if the provided framerate
is different from 25 when transcoding, as the output MJPEG file will
be reproduced assuming a framerate of 25 fps, or if there is some way
to set such information in the output file when transcoding.

For example it could fail with something like this:
stefano at geppetto ~/s/ffmpeg> ffmpeg -i tmp.avi -y out.mjpeg
[...]
Input #0, avi, from 'tmp.avi':
  Duration: 00:00:03.70, start: 0.000000, bitrate: 304 kb/s
    Stream #0.0: Video: h263, yuv420p, 176x144, 10 tbr, 10 tbn, 10 tbc
Output #0, mjpeg, to 'out.mjpeg':
    Stream #0.0: Video: mjpeg, yuvj420p, 176x144, q=2-31, 200 kb/s, 90k tbn, 10 tbc
...
[mjpeg @ 0x9e72920]Only a framerate value of 25 is valid.

Or maybe this is just wrong, and the playback application should be
able to define which is the assumed framerate to use (so not
necessarily 25).

Regards.
-- 
FFmpeg = Freak and Fast Mystic Pacific Elegant Gadget



More information about the ffmpeg-devel mailing list