Where is the documentation for the Mjpeg codec used in mencoder, VLC and FFMpeg?

白昼怎懂夜的黑 提交于 2020-01-06 10:20:23

问题


Mencoder has a lovely option for converting a mjpeg file into an avi file with an 'MJPG' codec that plays in VLC.

The command line to do this is:

mencoder filename.mjpeg -oac copy -ovc copy -o outputfile.avi -speed 0.3

where 0.3 is the ratio of the desired play framerate to the default 25 fps. All this does is make a copy of the mjpeg file, put an avi header on top and at the end, what seems to be an index of the frame positions in the file.

I want to replicate this in my own code, but I can't find documentation anywhere. What is the exact format of the index section? The header has extra filler bytes in it for some reason - whats this about?

Anyone know where I can find documentation? Both mencoder and vlc seem to have this codec built in.


回答1:


After much work, study and fiddling around with HxD and RiffPad, I finally figured it out. It would take a long blog entry to explain it all, but basically there isn't really an 'MJPG' codec out there - mjpg just uses a few tricks and unusual parts of the avi standard to produce an indexed file.

The key is to place '00dc' and an Int32 length tag 8 bytes in front of each Jpeg open tag. If you want the avi to be random access, then you need an index at the end which points to each of the '00dc' tag positions.

VLC will play this natively. If you have ffmpeg installed, then Windows Media Player uses that to decode these types of mjpg files.



来源:https://stackoverflow.com/questions/7077573/where-is-the-documentation-for-the-mjpeg-codec-used-in-mencoder-vlc-and-ffmpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!