[FFmpeg-devel] [PATCH] ffmpeg: copy the extradata from encoder to muxer
Andreas Cadhalpun
andreas.cadhalpun at googlemail.com
Thu Oct 27 22:19:24 EEST 2016
This fixes creating apng files.
This partly reverts commit 5ef19590802f000299e418143fc2301e3f43affe.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
ffmpeg.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/ffmpeg.c b/ffmpeg.c
index 3b91710..9971148 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -646,6 +646,7 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
{
AVFormatContext *s = of->ctx;
AVStream *st = ost->st;
+ AVCodecContext *avctx = ost->encoding_needed ? ost->enc_ctx : ost->st->codec;
int ret;
if (!of->header_written) {
@@ -709,6 +710,16 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
}
}
+ if (!st->codecpar->extradata_size && avctx->extradata_size) {
+ st->codecpar->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codecpar->extradata) {
+ av_log(NULL, AV_LOG_ERROR, "Could not allocate extradata buffer to copy parser data.\n");
+ exit_program(1);
+ }
+ st->codecpar->extradata_size = avctx->extradata_size;
+ memcpy(st->codecpar->extradata, avctx->extradata, avctx->extradata_size);
+ }
+
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
if (pkt->dts != AV_NOPTS_VALUE &&
pkt->pts != AV_NOPTS_VALUE &&
--
2.9.3
More information about the ffmpeg-devel
mailing list