Difference Between Revision 3 and Essentials / A_tw-ffmpeg-7

ffmpeg-7.spec Changed
x
 
1
@@ -125,6 +125,7 @@
2
 Patch18:        ffmpeg-7-CVE-2025-25473.patch
3
 Patch19:        ffmpeg-7-CVE-2025-22921.patch
4
 Patch20:        0001-avcodec-libsvtav1-unbreak-build-with-latest-svtav1.patch
5
+Patch199:       ffmpeg-support-kid-key.patch
6
 BuildRequires:  ladspa-devel
7
 BuildRequires:  libgsm-devel
8
 BuildRequires:  libmp3lame-devel >= 3.98.3
9
@@ -838,6 +839,7 @@
10
 Patch10:        ffmpeg-chromium.patch
11
 Patch91:        ffmpeg-dlopen-openh264.patch
12
 Patch15:        11013-avcodec-decode-clean-up-if-get_hw_frames_parameters-.patch
13
+Patch199:       ffmpeg-support-kid-key.patch
14
 BuildRequires:  c_compiler
15
 Requires:       this-is-only-for-build-envs
16
 
17
ffmpeg-support-kid-key.patch Added
201
 
1
@@ -0,0 +1,454 @@
2
+--- a/doc/demuxers.texi
3
++++ b/doc/demuxers.texi
4
+@@ -281,7 +281,11 @@
5
+ @table @option
6
+ 
7
+ @item cenc_decryption_key
8
+-16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
9
++Default 16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
10
++
11
++ at item cenc_decryption_keys
12
++Dictionary of 16-byte key ID => 16-byte key, both in hex, to decrypt files encrypted using ISO Common Encryption
13
++(CENC/AES-128 CTR; ISO/IEC 23001-7).
14
+ 
15
+ @end table
16
+ 
17
+@@ -931,7 +935,11 @@
18
+ specify.
19
+ 
20
+ @item decryption_key
21
+-16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
22
++Default 16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
23
++
24
++ at item decryption_keys
25
++Dictionary of 16-byte key ID => 16-byte key, both in hex, to decrypt files encrypted using ISO Common Encryption
26
++(CENC/AES-128 CTR; ISO/IEC 23001-7).
27
+ 
28
+ @item max_stts_delta
29
+ Very high sample deltas written in a trak's stts box may occasionally be intended but usually they are written in
30
+--- a/libavformat/dashdec.c
31
++++ b/libavformat/dashdec.c
32
+@@ -153,6 +153,7 @@
33
+     AVDictionary *avio_opts;
34
+     int max_url_size;
35
+     char *cenc_decryption_key;
36
++    char *cenc_decryption_keys;
37
+ 
38
+     /* Flags for init section*/
39
+     int is_init_section_common_video;
40
+@@ -1906,6 +1907,8 @@
41
+ 
42
+     if (c->cenc_decryption_key)
43
+         av_dict_set(&in_fmt_opts, "decryption_key", c->cenc_decryption_key, 0);
44
++    if (c->cenc_decryption_keys)
45
++        av_dict_set(&in_fmt_opts, "decryption_keys", c->cenc_decryption_keys, 0);
46
+ 
47
+     // provide additional information from mpd if available
48
+     ret = avformat_open_input(&pls->ctx, "", in_fmt, &in_fmt_opts); //pls->init_section->url
49
+@@ -2347,7 +2350,8 @@
50
+         OFFSET(allowed_extensions), AV_OPT_TYPE_STRING,
51
+         {.str = "aac,m4a,m4s,m4v,mov,mp4,webm,ts"},
52
+         INT_MIN, INT_MAX, FLAGS},
53
+-    { "cenc_decryption_key", "Media decryption key (hex)", OFFSET(cenc_decryption_key), AV_OPT_TYPE_STRING, {.str = NULL}, INT_MIN, INT_MAX, .flags = FLAGS },
54
++    { "cenc_decryption_key", "Media default decryption key (hex)", OFFSET(cenc_decryption_key), AV_OPT_TYPE_STRING, {.str = NULL}, INT_MIN, INT_MAX, .flags = FLAGS },
55
++    { "cenc_decryption_keys", "Media decryption keys by KID (hex)", OFFSET(cenc_decryption_keys), AV_OPT_TYPE_STRING, {.str = NULL}, INT_MIN, INT_MAX, .flags = FLAGS },
56
+     {NULL}
57
+ };
58
+ 
59
+--- a/libavformat/isom.h
60
++++ b/libavformat/isom.h
61
+@@ -340,8 +340,8 @@
62
+     void *audible_iv;
63
+     int audible_iv_size;
64
+     struct AVAES *aes_decrypt;
65
+-    uint8_t *decryption_key;
66
+-    int decryption_key_len;
67
++    uint8_t *decryption_default_key;
68
++    int decryption_default_key_len;
69
+     int enable_drefs;
70
+     int32_t movie_display_matrix33; ///< display matrix from mvhd
71
+     int have_read_mfra_size;
72
+@@ -356,6 +356,7 @@
73
+     int thmb_item_id;
74
+     int64_t idat_offset;
75
+     int interleaved_read;
76
++    AVDictionary* decryption_keys;
77
+ } MOVContext;
78
+ 
79
+ int ff_mp4_read_descr_len(AVIOContext *pb);
80
+--- a/libavformat/mov.c
81
++++ b/libavformat/mov.c
82
+@@ -7414,19 +7414,62 @@
83
+     return 0;
84
+ }
85
+ 
86
++static int get_key_from_kid(uint8_t* out, int len, MOVContext *c, AVEncryptionInfo *sample) {
87
++    AVDictionaryEntry *key_entry_hex;
88
++    char kid_hex16*2+1;
89
++
90
++    if (c->decryption_default_key && c->decryption_default_key_len != len) {
91
++        av_log(c->fc, AV_LOG_ERROR, "invalid default decryption key length: got %d, expected %d\n", c->decryption_default_key_len, len);
92
++        return -1;
93
++    }
94
++
95
++    if (!c->decryption_keys) {
96
++        av_assert0(c->decryption_default_key);
97
++        memcpy(out, c->decryption_default_key, len);
98
++        return 0;
99
++    }
100
++
101
++    if (sample->key_id_size != 16) {
102
++        av_log(c->fc, AV_LOG_ERROR, "invalid key ID size: got %u, expected 16\n", sample->key_id_size);
103
++        return -1;
104
++    }
105
++
106
++    ff_data_to_hex(kid_hex, sample->key_id, 16, 1);
107
++    key_entry_hex = av_dict_get(c->decryption_keys, kid_hex, NULL, AV_DICT_DONT_STRDUP_KEY|AV_DICT_DONT_STRDUP_VAL);
108
++    if (!key_entry_hex) {
109
++        if (!c->decryption_default_key) {
110
++            av_log(c->fc, AV_LOG_ERROR, "unable to find KID %s\n", kid_hex);
111
++            return -1;
112
++        }
113
++        memcpy(out, c->decryption_default_key, len);
114
++        return 0;
115
++    }
116
++    if (strlen(key_entry_hex->value) != len*2) {
117
++        return -1;
118
++    }
119
++    ff_hex_to_data(out, key_entry_hex->value);
120
++    return 0;
121
++}
122
++
123
+ static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8_t *input, int size)
124
+ {
125
+     int i, ret;
126
+     int bytes_of_protected_data;
127
++    uint8_t decryption_keyAES_CTR_KEY_SIZE;
128
+ 
129
+     if (!sc->cenc.aes_ctr) {
130
++        ret = get_key_from_kid(decryption_key, sizeof(decryption_key), c, sample);
131
++        if (ret < 0) {
132
++            return ret;
133
++        }
134
++
135
+         /* initialize the cipher */
136
+         sc->cenc.aes_ctr = av_aes_ctr_alloc();
137
+         if (!sc->cenc.aes_ctr) {
138
+             return AVERROR(ENOMEM);
139
+         }
140
+ 
141
+-        ret = av_aes_ctr_init(sc->cenc.aes_ctr, c->decryption_key);
142
++        ret = av_aes_ctr_init(sc->cenc.aes_ctr, decryption_key);
143
+         if (ret < 0) {
144
+             return ret;
145
+         }
146
+@@ -7472,15 +7515,21 @@
147
+     int i, ret;
148
+     int num_of_encrypted_blocks;
149
+     uint8_t iv16;
150
++    uint8_t decryption_key16;
151
+ 
152
+     if (!sc->cenc.aes_ctx) {
153
++        ret = get_key_from_kid(decryption_key, sizeof(decryption_key), c, sample);
154
++        if (ret < 0) {
155
++            return ret;
156
++        }
157
++
158
+         /* initialize the cipher */
159
+         sc->cenc.aes_ctx = av_aes_alloc();
160
+         if (!sc->cenc.aes_ctx) {
161
+             return AVERROR(ENOMEM);
162
+         }
163
+ 
164
+-        ret = av_aes_init(sc->cenc.aes_ctx, c->decryption_key, 16 * 8, 1);
165
++        ret = av_aes_init(sc->cenc.aes_ctx, decryption_key, 16 * 8, 1);
166
+         if (ret < 0) {
167
+             return ret;
168
+         }
169
+@@ -7531,15 +7580,21 @@
170
+ {
171
+     int i, ret, rem_bytes;
172
+     uint8_t *data;
173
++    uint8_t decryption_keyAES_CTR_KEY_SIZE;
174
+ 
175
+     if (!sc->cenc.aes_ctr) {
176
++        ret = get_key_from_kid(decryption_key, sizeof(decryption_key), c, sample);
177
++        if (ret < 0) {
178
++            return ret;
179
++        }
180
++
181
+         /* initialize the cipher */
182
+         sc->cenc.aes_ctr = av_aes_ctr_alloc();
183
+         if (!sc->cenc.aes_ctr) {
184
+             return AVERROR(ENOMEM);
185
+         }
186
+ 
187
+-        ret = av_aes_ctr_init(sc->cenc.aes_ctr, c->decryption_key);
188
++        ret = av_aes_ctr_init(sc->cenc.aes_ctr, decryption_key);
189
+         if (ret < 0) {
190
+             return ret;
191
+         }
192
+@@ -7597,15 +7652,21 @@
193
+     int i, ret, rem_bytes;
194
+     uint8_t iv16;
195
+     uint8_t *data;
196
++    uint8_t decryption_key16;
197
+ 
198
+     if (!sc->cenc.aes_ctx) {
199
++        ret = get_key_from_kid(decryption_key, sizeof(decryption_key), c, sample);
200
++        if (ret < 0) {
201