all repos — mgba @ d3bb022bf12b60034859f51c1a1e952cc5cfd32e

mGBA Game Boy Advance Emulator

Video: Fix setting global extradata in FFmpeg
Jeffrey Pfau jeffrey@endrift.com
Tue, 04 Nov 2014 00:15:54 -0800
commit

d3bb022bf12b60034859f51c1a1e952cc5cfd32e

parent

67e31c9666531c99aa7625c2ef009b39ae4bb49e

1 files changed, 6 insertions(+), 5 deletions(-)

jump to
M src/platform/ffmpeg/ffmpeg-encoder.csrc/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);