summaryrefslogtreecommitdiff
path: root/avconv.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-04-18 06:53:11 +0200
committerAnton Khirnov <anton@khirnov.net>2012-04-21 06:48:28 +0200
commit2994913d70050b8951e83b57c12baa7e4cf7e47e (patch)
tree1d00b6fd2986c0c052bad3c0eeffcc2067d39350 /avconv.c
parentb5c3f0b9940f964cdcaf33907eee91f9826c00b8 (diff)
avconv: fix a segfault when default encoder for a format doesn't exist.
Fail earlier and with a more descriptive error message.
Diffstat (limited to 'avconv.c')
-rw-r--r--avconv.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/avconv.c b/avconv.c
index 3da123cd22..a43a6f8ea3 100644
--- a/avconv.c
+++ b/avconv.c
@@ -2684,8 +2684,16 @@ static int transcode_init(void)
abort();
}
} else {
- if (!ost->enc)
- ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
+ if (!ost->enc) {
+ /* should only happen when a default codec is not present. */
+ snprintf(error, sizeof(error), "Automatic encoder selection "
+ "failed for output stream #%d:%d. Default encoder for "
+ "format %s is probably disabled. Please choose an "
+ "encoder manually.\n", ost->file_index, ost->index,
+ oc->oformat->name);
+ ret = AVERROR(EINVAL);
+ goto dump_format;
+ }
if (ist)
ist->decoding_needed = 1;
@@ -2819,12 +2827,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 id %d) not found for output stream #%d:%d",
- 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;