Opened 4 years ago
Last modified 4 years ago
#8783 open defect
I am trying to generate an encrypted single file hls stream but the output segment is not encrypted
Reported by: | noobcryptor | Owned by: | Steven Liu |
---|---|---|---|
Priority: | important | Component: | avformat |
Version: | git-master | Keywords: | hls regression |
Cc: | liuqi05@kuaishou.com | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
the output single file segment is not encrypted and when I remove the EXT-X-KEY tag I can play it using a normal video player.
while previous versions of ffmpeg encrypted the single file successfully, but the output byte ranges were wrong.
How to reproduce:
ffmpeg -i test.mp4 -hls_flags single_file -hls_key_info_file key.info playlist.m3u8 ffmpeg version: latest snapshot
log :
ffmpeg -i test.mp4 -hls_flags single_file -hls_key_info_file key.info playlist.m3u8 ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04) configuration: --pkgconfigdir=/home/vertexpotato/ffmpeg-build-script/workspace/lib/pkgconfig --prefix=/home/vertexpotato/ffmpeg-build-script/workspace --pkg-config-flags=--static --extra-cflags=-I/home/vertexpotato/ffmpeg-build-script/workspace/include --extra-ldflags=-L/home/vertexpotato/ffmpeg-build-script/workspace/lib --extra-libs='-lpthread -lm' --enable-static --disable-debug --disable-shared --disable-ffplay --disable-doc --enable-openssl --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libvpx --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-runtime-cpudetect --enable-libfdk-aac --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libvidstab --enable-libaom libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: mp42avc1 creation_time : 2011-03-16T10:41:51.000000Z Duration: 00:01:00.08, start: 0.000000, bitrate: 699 kb/s Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 640x360, 633 kb/s, 24.04 fps, 24.04 tbr, 2500 tbn, 5k tbc (default) Metadata: creation_time : 2011-03-16T10:41:52.000000Z handler_name : Apple Video Media Handler Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 62 kb/s (default) Metadata: creation_time : 2011-03-16T10:41:53.000000Z handler_name : Apple Sound Media Handler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Press [q] to stop, [?] for help [libx264 @ 0x56153359ca00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 @ 0x56153359ca00] profile High, level 3.0, 4:2:0, 8-bit [libx264 @ 0x56153359ca00] 264 - core 160 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 [hls @ 0x56153359bfc0] Opening 'key.info' for reading [hls @ 0x56153359bfc0] Opening 'file.key' for reading [hls @ 0x56153359bfc0] Opening 'playlist.ts' for writing Output #0, hls, to 'playlist.m3u8': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: mp42avc1 encoder : Lavf58.45.100 Stream #0:0(eng): Video: h264 (libx264), yuv420p(progressive), 640x360, q=-1--1, 24.04 fps, 90k tbn, 24.04 tbc (default) Metadata: creation_time : 2011-03-16T10:41:52.000000Z handler_name : Apple Video Media Handler encoder : Lavc58.91.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A Stream #0:1(eng): Audio: aac (LC), 44100 Hz, mono, fltp, 69 kb/s (default) Metadata: creation_time : 2011-03-16T10:41:53.000000Z handler_name : Apple Sound Media Handler encoder : Lavc58.91.100 aac [hls @ 0x56153359bfc0] Opening 'playlist.m3u8.tmp' for writing/A speed=12.5x Last message repeated 2 times [hls @ 0x56153359bfc0] Opening 'playlist.m3u8.tmp' for writing/A speed=12.4x [hls @ 0x56153359bfc0] Opening 'playlist.m3u8.tmp' for writing/A speed=12.7x [hls @ 0x56153359bfc0] Opening 'playlist.m3u8.tmp' for writing/A speed= 12x [hls @ 0x56153359bfc0] Opening 'playlist.m3u8.tmp' for writing/A speed=11.7x [hls @ 0x56153359bfc0] Opening 'playlist.m3u8.tmp' for writing/A speed=11.6x [hls @ 0x56153359bfc0] Opening 'playlist.m3u8.tmp' for writing/A speed=11.8x frame= 1445 fps=279 q=-1.0 Lsize=N/A time=00:01:00.09 bitrate=N/A speed=11.6x video:4097kB audio:509kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown [libx264 @ 0x56153359ca00] frame I:10 Avg QP:18.01 size: 34297 [libx264 @ 0x56153359ca00] frame P:762 Avg QP:22.29 size: 4380 [libx264 @ 0x56153359ca00] frame B:673 Avg QP:27.39 size: 764 [libx264 @ 0x56153359ca00] consecutive B-frames: 34.8% 7.1% 6.6% 51.5% [libx264 @ 0x56153359ca00] mb I I16..4: 16.7% 20.5% 62.8% [libx264 @ 0x56153359ca00] mb P I16..4: 1.5% 3.7% 1.3% P16..4: 31.7% 11.0% 5.5% 0.0% 0.0% skip:45.4% [libx264 @ 0x56153359ca00] mb B I16..4: 0.6% 0.7% 0.1% B16..8: 36.4% 4.5% 0.9% direct: 1.7% skip:55.1% L0:50.9% L1:44.9% BI: 4.2% [libx264 @ 0x56153359ca00] 8x8 transform intra:50.8% inter:44.8% [libx264 @ 0x56153359ca00] coded y,uvDC,uvAC intra: 40.3% 45.6% 17.7% inter: 10.0% 11.5% 1.5% [libx264 @ 0x56153359ca00] i16 v,h,dc,p: 38% 33% 15% 14% [libx264 @ 0x56153359ca00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 21% 31% 2% 3% 3% 3% 3% 3% [libx264 @ 0x56153359ca00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 17% 15% 7% 8% 7% 8% 7% 7% [libx264 @ 0x56153359ca00] i8c dc,h,v,p: 59% 23% 13% 5% [libx264 @ 0x56153359ca00] Weighted P-Frames: Y:3.7% UV:1.8% [libx264 @ 0x56153359ca00] ref P L0: 77.5% 9.1% 10.5% 2.6% 0.3% [libx264 @ 0x56153359ca00] ref B L0: 93.5% 5.9% 0.6% [libx264 @ 0x56153359ca00] ref B L1: 96.8% 3.2% [libx264 @ 0x56153359ca00] kb/s:558.25 [aac @ 0x5615335802c0] Qavg: 227.509
Change History (9)
comment:2 by , 4 years ago
Keywords: | encryption aes-128 removed |
---|
comment:3 by , 4 years ago
Priority: | important → critical |
---|
follow-ups: 5 7 comment:4 by , 4 years ago
Cc: | added |
---|---|
Owner: | set to |
Status: | new → open |
try this patchset please:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1718
comment:5 by , 4 years ago
Replying to stevenliu:
try this patchset please:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1718
Hi, thank you for your response, I have tried this patchset, the stream got encrypted fine, but the playback is broken, I have tried playing it using ffplay and I got the following output
ffplay playlist.m3u8 -allowed_extensions ALL ffplay version 4.3 Copyright (c) 2003-2020 the FFmpeg developers built with gcc 9.3.1 (GCC) 20200621 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 [hls @ 00000200bdddb980] Skip ('#EXT-X-VERSION:4')sq= 0B f=0/0 [hls @ 00000200bdddb980] Opening 'file.key' for reading [hls @ 00000200bdddb980] Opening 'crypto:playlist.ts' for reading Input #0, hls, from 'playlist.m3u8':KB vq= 0KB sq= 0B f=0/0 Duration: 00:00:37.07, start: 1.459978, bitrate: 0 kb/s Program 0 Metadata: variant_bitrate : 0 Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 640x360, 24.04 fps, 24.04 tbr, 90k tbn, 48.08 tbc Metadata: variant_bitrate : 0 Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp Metadata: variant_bitrate : 0 [hls @ 00000200bdddb980] Opening 'crypto:playlist.ts' for reading [mpegts @ 00000200bdddfe80] Packet corrupt (stream = 0, dts = 990864). [hls @ 00000200bdddb980] Opening 'crypto:playlist.ts' for reading [mpegts @ 00000200bdddfe80] Packet corrupt (stream = 0, dts = 1095696). [h264 @ 00000200bde44180] error while decoding MB 3 21, bytestream -6 [h264 @ 00000200bde44180] concealing 126 DC, 126 AC, 126 MV errors in P frame [hls @ 00000200bdddb980] Opening 'crypto:playlist.ts' for reading [mpegts @ 00000200bdddfe80] Packet corrupt (stream = 0, dts = 736272). [h264 @ 00000200bde24f80] error while decoding MB 19 18, bytestream -10 [h264 @ 00000200bde24f80] concealing 230 DC, 230 AC, 230 MV errors in P frame [hls @ 00000200bdddb980] Opening 'crypto:playlist.ts' for reading [mpegts @ 00000200bdddfe80] Packet corrupt (stream = 0, dts = 1062000). [h264 @ 00000200bde44180] error while decoding MB 33 0, bytestream -6 [h264 @ 00000200bde44180] concealing 920 DC, 920 AC, 920 MV errors in I frame 3.62 A-V: -2.562 fd= 183 aq= 0KB vq= 0KB sq= 0B f=4/4
comment:6 by , 4 years ago
Keywords: | regression added |
---|---|
Priority: | critical → important |
follow-ups: 8 9 comment:7 by , 4 years ago
Replying to stevenliu:
try this patchset please:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1718
is this issue fixable ?
comment:8 by , 4 years ago
Replying to noobcryptor:
Replying to stevenliu:
try this patchset please:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1718
is this issue fixable ?
I will make new patchset to fix it, don't worry, maybe one or two weeks later.
comment:9 by , 4 years ago
Replying to noobcryptor:
Replying to stevenliu:
try this patchset please:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1718
is this issue fixable ?
try this patchset please:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=1838
update : I have tried the same command on ffmpeg compiled from git master and the issue still stands