[FFmpeg-cvslog] ffmpeg: check encoder earlier.

Nicolas George git at videolan.org
Fri Apr 20 16:41:55 CEST 2012


ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Fri Apr 20 15:17:38 2012 +0200| [34c426be4a3cb52f6d420e5e775a3f2daebcfefe] | committer: Nicolas George

ffmpeg: check encoder earlier.

Fixes a segfault with Ogg output, libtheora not compiled in
and no codec specified.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=34c426be4a3cb52f6d420e5e775a3f2daebcfefe
---

 ffmpeg.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 3e77610..0721a04 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3013,6 +3013,12 @@ static int transcode_init(void)
         } else {
             if (!ost->enc)
                 ost->enc = avcodec_find_encoder(codec->codec_id);
+            if (!ost->enc) {
+                snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d:%d",
+                         avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
+                ret = AVERROR(EINVAL);
+                goto dump_format;
+            }
 
             if (ist)
                 ist->decoding_needed = 1;
@@ -3154,12 +3160,6 @@ static int transcode_init(void)
         if (ost->encoding_needed) {
             AVCodec      *codec = ost->enc;
             AVCodecContext *dec = NULL;
-            if (!codec) {
-                snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d:%d",
-                         avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
-                ret = AVERROR(EINVAL);
-                goto dump_format;
-            }
 
             if ((ist = get_input_stream(ost)))
                 dec = ist->st->codec;



More information about the ffmpeg-cvslog mailing list