[FFmpeg-devel] [PATCH] ffmpeg: Update muxer extradata after flushing encoders
Michael Niedermayer
michael at niedermayer.cc
Wed Aug 17 12:53:34 EEST 2016
This is needed for encoders which store a final sample count or checksum in extradata
alternatively every encoder as well as muxer can implement AV_PKT_DATA_NEW_EXTRADATA support
to update the extradata at the end.
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
ffmpeg.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/ffmpeg.c b/ffmpeg.c
index bae515d..9d972d0 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1772,6 +1772,23 @@ static void flush_encoders(void)
if (stop_encoding)
break;
}
+ if (ost->enc_ctx->extradata_size) {
+ void *ptr = av_mallocz(ost->enc_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ void *ptr2 = av_mallocz(ost->enc_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (ptr && ptr2) {
+ av_free(ost->st->codec->extradata);
+ av_free(ost->st->codecpar->extradata);
+ ost->st->codec->extradata = ptr;
+ ost->st->codecpar->extradata = ptr2;
+ memcpy(ost->st->codec->extradata , ost->enc_ctx->extradata, ost->enc_ctx->extradata_size);
+ memcpy(ost->st->codecpar->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size);
+ ost->st->codec ->extradata_size = ost->enc_ctx->extradata_size;
+ ost->st->codecpar->extradata_size = ost->enc_ctx->extradata_size;
+ } else {
+ av_free(ptr);
+ av_free(ptr2);
+ }
+ }
}
}
--
2.9.3
More information about the ffmpeg-devel
mailing list