[FFmpeg-devel] [PATCH 4/4] avformat/movenc: Ensure packet is writable before modifying it

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Jul 4 22:15:39 EEST 2022


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 <andreas.rheinhardt at outlook.com>
---
 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];
             }
-- 
2.34.1



More information about the ffmpeg-devel mailing list