From a2564264116aabc5a95755ca93a31508ef547f40 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 4 Jul 2022 18:53:50 +0200 Subject: [PATCH] avformat/movenc: Ensure packet is writable before modifying it Fixes e.g. ffmpeg -i fate-suite/h264/bbc2.sample.h264 -c:v rawvideo -map 0:v -frames:v 10 -pix_fmt gray8 -f tee "first.mov|second.mov" Signed-off-by: Andreas Rheinhardt --- libavformat/movenc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index a4dace7c1d..5608afde42 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -6513,6 +6513,9 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) } else if (trk->par->codec_id == AV_CODEC_ID_RAWVIDEO && (trk->par->format == AV_PIX_FMT_GRAY8 || trk->par->format == AV_PIX_FMT_MONOBLACK)) { + ret = av_packet_make_writable(pkt); + if (ret < 0) + goto fail; for (i = 0; i < pkt->size; i++) pkt->data[i] = ~pkt->data[i]; }