PR #26308 opened by Baptiste Coudurier (bcoudurier)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26308
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26308.patch

CENC is not defined for MOV, 3GP or the other mov muxer variants. Refuse 
`-encryption_scheme cenc-aes-ctr` there instead of writing unreadable files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


From 0e40c7d7e0b4e8a35154dbf7982ea7981918d751 Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Sun, 22 Nov 2026 23:22:31 -0800
Subject: [PATCH] avformat/movenc: allow common encryption only in MP4 and ISMV

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
---
 doc/muxers.texi      | 3 ++-
 libavformat/movenc.c | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 4b419718ab8..32e5be61b05 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -448,7 +448,8 @@ set the media encryption key identifier in hexadecimal 
format
 
 @item encryption_scheme @var{scheme}
 configure the encryption scheme, allowed values are @samp{none}, and
-@samp{cenc-aes-ctr}
+@samp{cenc-aes-ctr}; @samp{cenc-aes-ctr} is only supported by the @samp{mp4}
+and @samp{ismv} muxers
 
 @item frag_duration @var{duration}
 Create fragments that are @var{duration} microseconds long.
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 097f1bc1064..6a6ddc9576f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -8878,6 +8878,10 @@ static int mov_init(AVFormatContext *s)
 
     if (mov->encryption_scheme_str != NULL && 
strcmp(mov->encryption_scheme_str, "none") != 0) {
         if (strcmp(mov->encryption_scheme_str, "cenc-aes-ctr") == 0) {
+            if (!(mov->mode & (MODE_MP4 | MODE_ISM))) {
+                av_log(s, AV_LOG_ERROR, "Common encryption is only supported 
in MP4 and ISMV\n");
+                return AVERROR(EINVAL);
+            }
             mov->encryption_scheme = MOV_ENC_CENC_AES_CTR;
 
             if (mov->encryption_key_len != AES_CTR_KEY_SIZE) {
-- 
2.54.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to