diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c index a24f99c447..c24572f160 100644 --- a/libavformat/adtsenc.c +++ b/libavformat/adtsenc.c @@ -94,13 +94,11 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const ui return 0; } -static int adts_write_header(AVFormatContext *s) +static int adts_init(AVFormatContext *s) { ADTSContext *adts = s->priv_data; AVCodecParameters *par = s->streams[0]->codecpar; - if (adts->id3v2tag) - ff_id3v2_write_simple(s, 4, ID3v2_DEFAULT_MAGIC); if (par->extradata_size > 0) return adts_decode_extradata(s, adts, par->extradata, par->extradata_size); @@ -108,6 +106,16 @@ static int adts_write_header(AVFormatContext *s) return 0; } +static int adts_write_header(AVFormatContext *s) +{ + ADTSContext *adts = s->priv_data; + + if (adts->id3v2tag) + ff_id3v2_write_simple(s, 4, ID3v2_DEFAULT_MAGIC); + + return 0; +} + static int adts_write_frame_header(ADTSContext *ctx, uint8_t *buf, int size, int pce_size) { @@ -220,6 +228,7 @@ AVOutputFormat ff_adts_muxer = { .priv_data_size = sizeof(ADTSContext), .audio_codec = AV_CODEC_ID_AAC, .video_codec = AV_CODEC_ID_NONE, + .init = adts_init, .write_header = adts_write_header, .write_packet = adts_write_packet, .write_trailer = adts_write_trailer,