[MPlayer-advusers] [BUG] mencoder floating point exception with -of lavf

Corey Hickey bugfood-ml at fatooh.org
Mon Nov 7 05:49:50 CET 2005


Michael Niedermayer wrote:
> whichever way its solved, not knowing the width/height when writing the header
> is a serious problem independant of lavf, just think of nut where width/height
> are variable length, so seeking back and filling it in wont work without some
> hacks, and if i understand correctly we cant just write the header at the
> first video frame as an audio frame might have been written before?

Last night I spent quite a while looking at how things work currently with
mplayer's avi muxer and how the lavf avi muxer is different. I'm starting to
get a basic understanding of what is going on.

mplayer's avi muxer writes the header twice -- once before it knows the video
dimensions, and once at the end of encoding. If we can't wait until after the
first video frame is decoded, then it seems like the best solution for the
lavf muxer would be to write the header twice as well.


Would the following plan be acceptable?

1. Remove width/height sanity check from libavformat/utils.c, and let it write
the header anyway.

2. Make the lavf muxer rewrite the header after encoding, just like the avi
muxer does presently.

3. After mencoder decodes the first video frame, store the original width and
height. For example, in ve_lavc.c, this would be in the config() function.
Right now we have:
    mux_v->bih->biWidth=width;
    mux_v->bih->biHeight=height;
I could change that to:
    mux_v->bih->biWidth=mux_v->bih->biOrigWidth=width;
    mux_v->bih->biHeight=mux_v->bih->biOrigHeight=height;
I'd have to change the other video encoders similarly. This would provide a
basis for variable-dimension video; the dimensions of the first packet would
be retained and written at the end.

4. Expand write_header() in muxer_lavf.c. Include a section beginning with:
    if(muxer->def_v){
...that copies the necessary values from muxer->def_v->bih into the video
stream, from which they can be read by whatever header-writing function in
lavf. That's how the header writing function of the current avi demuxer
operates.

5. Change the other muxers to use bih->biOrigWidth and bih->biOrigHeight
accordingly.


I wrote everything above before I read Rich's mail recommending that the
packets be buffered; my idea wouldn't work for non-seekable output either.
However, I think it could be an acceptable interim solution based on:
(a) There aren't any revolutionary changes.
(b) The likilihood of breaking anything that works currently is low.
(c) It's fairly simple and I could probably do it myself.
(d) There wouldn't be more to change if someone writes a buffer later.

What do you guys think? If it sounds ok and I'm not missing anything
egregious, I'll give it a shot and try to come up with a good patch.

-Corey




More information about the MPlayer-advusers mailing list