From 6938c8bea670ec9d8dbdd7a892e20e83226c11e7 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 1 Jan 2015 14:51:20 -0800 Subject: [PATCH] Video: Fix FFmpeg crashing when the file extension is wrong --- CHANGES | 1 + src/platform/ffmpeg/ffmpeg-encoder.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 24fd131aa..8c1096ff9 100644 --- a/CHANGES +++ b/CHANGES @@ -37,6 +37,7 @@ Bugfixes: - GBA Video: Fix sprite mis-ordering behavior in some cases (fixes #168) - GBA Video: Fix window interactions with 16-color mode 0 mosaic - GBA Video: Fix sprite boundary conditions with mosaic + - Video: Fix FFmpeg crashing when the file extension is wrong Misc: - Qt: Disable sync to video by default - GBA: Exit cleanly on FATAL if the port supports it diff --git a/src/platform/ffmpeg/ffmpeg-encoder.c b/src/platform/ffmpeg/ffmpeg-encoder.c index 5f112dc88..b03b97f9d 100644 --- a/src/platform/ffmpeg/ffmpeg-encoder.c +++ b/src/platform/ffmpeg/ffmpeg-encoder.c @@ -196,15 +196,15 @@ bool FFmpegEncoderOpen(struct FFmpegEncoder* encoder, const char* outfile) { encoder->currentVideoFrame = 0; encoder->nextAudioPts = 0; + AVOutputFormat* oformat = av_guess_format(encoder->containerFormat, 0, 0); #ifndef USE_LIBAV - avformat_alloc_output_context2(&encoder->context, 0, 0, outfile); + avformat_alloc_output_context2(&encoder->context, oformat, 0, outfile); #else encoder->context = avformat_alloc_context(); strncpy(encoder->context->filename, outfile, sizeof(encoder->context->filename)); + encoder->context->oformat = oformat; #endif - encoder->context->oformat = av_guess_format(encoder->containerFormat, 0, 0); - if (acodec) { encoder->audioStream = avformat_new_stream(encoder->context, acodec); encoder->audio = encoder->audioStream->codec;