[FFmpeg-devel] [PATCH 2/3] ffmpeg: open encoders after decoders

Aurelien Jacobs aurel
Sat Oct 16 17:27:39 CEST 2010


On Wed, Oct 06, 2010 at 06:04:52PM +0200, Michael Niedermayer wrote:
> On Wed, Aug 11, 2010 at 05:43:48PM +0200, Aurelien Jacobs wrote:
> > On Wed, Aug 11, 2010 at 06:25:02PM +0200, Michael Niedermayer wrote:
> > > On Tue, Aug 10, 2010 at 10:39:37PM +0200, Aurelien Jacobs wrote:
> > > > On Tue, Aug 10, 2010 at 02:10:35PM +0200, Michael Niedermayer wrote:
> > > > > On Sun, Aug 08, 2010 at 02:26:57AM +0200, Aur?lien Jacobs wrote:
> > > > > > From: Aurelien Jacobs <aurel at gnuage.org>
> > > > > > 
> > > > > > ---
> > > > > >  ffmpeg.c |   46 +++++++++++++++++++++++-----------------------
> > > > > >  1 files changed, 23 insertions(+), 23 deletions(-)
> > > > > 
> > > > > this should be unneeded, av_find_stream_info() should cause all the things
> > > > > to be set
> > > > 
> > > > It currently don't. So I've tried to force av_find_stream_info() to fill
> > > > the subtitle_header field with the attached patch. With this,
> > > > av_find_stream_info() indeed fills subtitle_header, but after it finishes
> > > > probing parameters, it calls avcodec_close() which effectively free the
> > > > subtitle_header buffer.
> > > > So after av_find_stream_info() call, subtitle_header is NULL again...
> > > > 
> > > > Any better alternative ?
> > > 
> > > what problems are there with using extradata?
> > 
> > Regarding the decoder, extradata is an input parameter which will
> > contain the "header" in native subtitle format. The decoder then need to
> > export the "decoded header" into generic format (ASS). That's what I
> > added subtitle_header for. Trying to re-use extradata instead would mean
> > overwritting something provided by the calling app, which might have
> > been allocated with something else than av_malloc(), or that might even
> > point to a static const buffer.
> > The situation is exactly the same for the encoder, but reverted. It is
> > supposed to output extradata in native encoded format and take the
> > generic subtitle_header as input.
> > 
> > So re-using extradata for this sounds like a dead-end to me.
> > 
> > Any other idea ?
> 
> free subtitle_header like extradata so av_find_stream_info can be used

I thought that's what I was doing. Now I noticed that I had a typo in my
code (was checking for avctx->codec->decode instead of
avctx->codec->encode). With this typo fixed everything is working fine,
and no need to reorder encoder and decoder initialization.
av_find_stream_info() now does the right thing.
I will send a new patchset shortly.

Aurel



More information about the ffmpeg-devel mailing list