Video: Fix setting global extradata in FFmpeg
Jeffrey Pfau jeffrey@endrift.com
Tue, 04 Nov 2014 00:15:54 -0800
1 files changed,
6 insertions(+),
5 deletions(-)
M
src/platform/ffmpeg/ffmpeg-encoder.c
→
src/platform/ffmpeg/ffmpeg-encoder.c
@@ -184,6 +184,9 @@ encoder->audio->sample_rate = encoder->sampleRate;
encoder->audio->sample_fmt = encoder->sampleFormat; AVDictionary* opts = 0; av_dict_set(&opts, "strict", "-2", 0); + if (encoder->context->oformat->flags & AVFMT_GLOBALHEADER) { + encoder->audio->flags |= CODEC_FLAG_GLOBAL_HEADER; + } avcodec_open2(encoder->audio, acodec, &opts); av_dict_free(&opts); encoder->audioFrame = av_frame_alloc();@@ -221,6 +224,9 @@ encoder->video->time_base = (AVRational) { VIDEO_TOTAL_LENGTH, GBA_ARM7TDMI_FREQUENCY };
encoder->video->pix_fmt = encoder->pixFormat; encoder->video->gop_size = 15; encoder->video->max_b_frames = 0; + if (encoder->context->oformat->flags & AVFMT_GLOBALHEADER) { + encoder->video->flags |= CODEC_FLAG_GLOBAL_HEADER; + } avcodec_open2(encoder->video, vcodec, 0); encoder->videoFrame = av_frame_alloc(); encoder->videoFrame->format = encoder->video->pix_fmt;@@ -231,11 +237,6 @@ encoder->scaleContext = sws_getContext(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, AV_PIX_FMT_0BGR32,
VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, encoder->video->pix_fmt, 0, 0, 0, 0); av_image_alloc(encoder->videoFrame->data, encoder->videoFrame->linesize, encoder->video->width, encoder->video->height, encoder->video->pix_fmt, 32); - - if (encoder->context->oformat->flags & AVFMT_GLOBALHEADER) { - encoder->audio->flags |= CODEC_FLAG_GLOBAL_HEADER; - encoder->video->flags |= CODEC_FLAG_GLOBAL_HEADER; - } avio_open(&encoder->context->pb, outfile, AVIO_FLAG_WRITE); avformat_write_header(encoder->context, 0);