[FFmpeg-devel] [PATCH 2/3] ffmpeg: open encoders after decoders
Aurélien Jacobs
aurel
Sun Aug 8 02:26:57 CEST 2010
From: Aurelien Jacobs <aurel at gnuage.org>
---
ffmpeg.c | 46 +++++++++++++++++++++++-----------------------
1 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/ffmpeg.c b/ffmpeg.c
index b9e748d..ca85b34 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2325,29 +2325,6 @@ static int transcode(AVFormatContext **output_files,
goto fail;
}
- /* open each encoder */
- for(i=0;i<nb_ostreams;i++) {
- ost = ost_table[i];
- if (ost->encoding_needed) {
- AVCodec *codec = output_codecs[i];
- if (!codec)
- codec = avcodec_find_encoder(ost->st->codec->codec_id);
- 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 (avcodec_open(ost->st->codec, codec) < 0) {
- snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
- ost->file_index, ost->index);
- ret = AVERROR(EINVAL);
- goto dump_format;
- }
- extra_size += ost->st->codec->extradata_size;
- }
- }
-
/* open each decoder */
for(i=0;i<nb_istreams;i++) {
ist = ist_table[i];
@@ -2372,6 +2349,29 @@ static int transcode(AVFormatContext **output_files,
}
}
+ /* open each encoder */
+ for(i=0;i<nb_ostreams;i++) {
+ ost = ost_table[i];
+ if (ost->encoding_needed) {
+ AVCodec *codec = output_codecs[i];
+ if (!codec)
+ codec = avcodec_find_encoder(ost->st->codec->codec_id);
+ 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 (avcodec_open(ost->st->codec, codec) < 0) {
+ snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
+ ost->file_index, ost->index);
+ ret = AVERROR(EINVAL);
+ goto dump_format;
+ }
+ extra_size += ost->st->codec->extradata_size;
+ }
+ }
+
/* init pts */
for(i=0;i<nb_istreams;i++) {
AVStream *st;
--
1.7.1
More information about the ffmpeg-devel
mailing list