[FFmpeg-cvslog] libavformat/flvenc: support for codec configuration change mid stream

Ivan git at videolan.org
Sat Jun 11 11:08:46 CEST 2016


ffmpeg | branch: master | Ivan <grigoriev.ivan.a at gmail.com> | Thu Jun  9 22:12:10 2016 -0400| [c1f57e2f91e250e83830099e3cadeec4f0080bc2] | committer: Michael Niedermayer

libavformat/flvenc: support for codec configuration change mid stream

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/flvenc.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index cf8d221..6fd7792 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -566,6 +566,19 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
     else
         flags_size = 1;
 
+    if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264
+            || par->codec_id == AV_CODEC_ID_MPEG4) {
+        int side_size = 0;
+        uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
+        if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) {
+            av_free(par->extradata);
+            par->extradata = av_mallocz(side_size + AV_INPUT_BUFFER_PADDING_SIZE);
+            memcpy(par->extradata, side, side_size);
+            par->extradata_size = side_size;
+            flv_write_codec_header(s, par);
+        }
+    }
+
     if (flv->delay == AV_NOPTS_VALUE)
         flv->delay = -pkt->dts;
 



More information about the ffmpeg-cvslog mailing list