[FFmpeg-soc] [soc]: r4577 - concat/ffmpeg-patch.diff

gkovacs subversion at mplayerhq.hu
Sat Jul 4 03:39:31 CEST 2009


Author: gkovacs
Date: Sat Jul  4 03:39:30 2009
New Revision: 4577

Log:
ffmpeg patch to handle codec switching

Added:
   concat/ffmpeg-patch.diff

Added: concat/ffmpeg-patch.diff
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ concat/ffmpeg-patch.diff	Sat Jul  4 03:39:30 2009	(r4577)
@@ -0,0 +1,47 @@
+diff --git a/ffmpeg.c b/ffmpeg.c
+index 18bf949..b5e02ca 100644
+--- a/ffmpeg.c
++++ b/ffmpeg.c
+@@ -1237,7 +1237,8 @@ static void print_report(AVFormatContext **output_files,
+ /* pkt = NULL means EOF (needed to flush decoder buffers) */
+ static int output_packet(AVInputStream *ist, int ist_index,
+                          AVOutputStream **ost_table, int nb_ostreams,
+-                         const AVPacket *pkt)
++                         const AVPacket *pkt,
++                         AVFormatContext *is)
+ {
+     AVFormatContext *os;
+     AVOutputStream *ost;
+@@ -1250,6 +1251,23 @@ static int output_packet(AVInputStream *ist, int ist_index,
+     AVSubtitle subtitle, *subtitle_to_free;
+     int got_subtitle;
+     AVPacket avpkt;
++    if (ist && is && pkt && is->nb_streams > pkt->stream_index && is->streams && is->streams[pkt->stream_index] && is->streams[pkt->stream_index]->codec) {
++        fprintf(stdout, "stream index modified to %d\n", pkt->stream_index);
++        ist->st = is->streams[pkt->stream_index];
++        if (!ist->st->codec->codec) {
++            AVCodec *codec = avcodec_find_decoder(ist->st->codec->codec_id);
++            if (!codec) {
++                fprintf(stderr, "output_packet: Decoder (codec id %d) not found for input stream #%d.%d\n",
++                        ist->st->codec->codec_id, ist->file_index, ist->index);
++                return AVERROR(EINVAL);
++            }
++            if (avcodec_open(ist->st->codec, codec) < 0) {
++                fprintf(stderr, "output_packet: Error while opening decoder for input stream #%d.%d\n",
++                        ist->file_index, ist->index);
++                return AVERROR(EINVAL);
++            }
++        }
++    }
+ 
+     if(ist->next_pts == AV_NOPTS_VALUE)
+         ist->next_pts= ist->pts;
+@@ -2300,7 +2326,7 @@ static int av_encode(AVFormatContext **output_files,
+     for(i=0;i<nb_istreams;i++) {
+         ist = ist_table[i];
+         if (ist->decoding_needed) {
+-            output_packet(ist, i, ost_table, nb_ostreams, NULL);
++            output_packet(ist, i, ost_table, nb_ostreams, NULL, is);
+         }
+     }
+


More information about the FFmpeg-soc mailing list