summaryrefslogtreecommitdiff
path: root/libavformat/flvenc.c
diff options
context:
space:
mode:
authorIvan <grigoriev.ivan.a@gmail.com>2016-06-09 22:12:10 -0400
committerMichael Niedermayer <michael@niedermayer.cc>2016-06-11 10:54:43 +0200
commitc1f57e2f91e250e83830099e3cadeec4f0080bc2 (patch)
tree9a2f98550546131b9fc3cc433afcc020b6434546 /libavformat/flvenc.c
parent52985768afd27c9a582ece03d2c49556578ea90e (diff)
downloadffmpeg-c1f57e2f91e250e83830099e3cadeec4f0080bc2.tar.gz
libavformat/flvenc: support for codec configuration change mid stream
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/flvenc.c')
-rw-r--r--libavformat/flvenc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index cf8d221f75..6fd7792e28 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;