summaryrefslogtreecommitdiff
path: root/libavformat/dashenc.c
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2015-03-04 22:48:43 +0100
committerMartin Storsjö <martin@martin.st>2015-03-06 10:07:17 +0200
commit5aef535a64350b7bc06c5bdda8c26c9efec9443b (patch)
tree4bf0c9acd2cffbb9b85f93706474a9d2d7a81a9e /libavformat/dashenc.c
parent6cf7f30655e95e27fd0394b5a80970d6f9517015 (diff)
dashenc: Update extradata for mov muxer
The mov muxer already supports picking up extradata that wasn't present during the avformat_write_header call - we just need to propagate it. Since the dash muxer uses delay_moov, we have time up until the first segment is written to get extradata filled in. Also update the codec description string when the extradata becomes available. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/dashenc.c')
-rw-r--r--libavformat/dashenc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 6b385ae2e9..1d32cdf7ef 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -730,6 +730,29 @@ static void find_index_range(AVFormatContext *s, const char *full_path,
*index_length = AV_RB32(&buf[0]);
}
+static int update_stream_extradata(AVFormatContext *s, OutputStream *os,
+ AVCodecContext *codec)
+{
+ uint8_t *extradata;
+
+ if (os->ctx->streams[0]->codec->extradata_size || !codec->extradata_size)
+ return 0;
+
+ extradata = av_malloc(codec->extradata_size);
+
+ if (!extradata)
+ return AVERROR(ENOMEM);
+
+ memcpy(extradata, codec->extradata, codec->extradata_size);
+
+ os->ctx->streams[0]->codec->extradata = extradata;
+ os->ctx->streams[0]->codec->extradata_size = codec->extradata_size;
+
+ set_codec_str(s, codec, os->codec_str, sizeof(os->codec_str));
+
+ return 0;
+}
+
static int dash_flush(AVFormatContext *s, int final, int stream)
{
DASHContext *c = s->priv_data;
@@ -833,6 +856,10 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
int64_t seg_end_duration = (os->segment_index) * (int64_t) c->min_seg_duration;
int ret;
+ ret = update_stream_extradata(s, os, st->codec);
+ if (ret < 0)
+ return ret;
+
// If forcing the stream to start at 0, the mp4 muxer will set the start
// timestamps to 0. Do the same here, to avoid mismatches in duration/timestamps.
if (os->first_pts == AV_NOPTS_VALUE &&