On 2009-08-03 at 23:03:42 [+0200], Art Clarke <[email protected]> wrote:
> On Mon, Aug 3, 2009 at 3:45 PM, Stephan Assmus <[email protected]> wrote:
> 
> > I do see one problem in your explaination, though. In my code, just 
> > opening and closing the AVCodecContext for each stream makes all the 
> > difference (I tested that with a #define to either include this code or 
> > not). These instances have not been used for anything when I call 
> > av_write_frame(). So I am very much expecting that there is still 
> > something fishy. How can it be explained that just opening and closing 
> > the AVCodecContext instances, but not using them for anything, makes 
> > all the difference here?
> 
> Opening the AVCodecContext will cause FFmpeg to fill in any defaults for 
> that codec.  In turn, some AVFormatContext require defaults for a codec 
> to have been filled in when it writes the header
> 
> For example, opening a H263 codec that has the global headers flag set 
> will cause global header data to be created in AVCodecContext, and then 
> calling av_write_header for a .mov AVFormatContext will use (indeed 
> requires) that information.
> 
> It's somewhat confusing, but yes the rule is if you're calling 
> av_write_header, make sure you've opened each codec first (in Xuggler we 
> explicitly throw warnings if you don't).

Thanks a lot, it becomes much clearer now! What do you do in Xuggler to 
support encoders that libavcodec does not support (not that that would be a 
real-life problem anyway... ;-)?

With your information, I thought I could avoid opening the codec context by 
using avcodec_get_context_defaults[2](), like the ffmpeg.c code does when 
adding streams, but it didn't work. Though I used it in an earlier version 
of my code, it now results in av_write_header() to fail. For the time 
being, I can certainly live with opening and closing "dummy" codec contexts.

So, thanks again and best regards,
-Stephan
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to