m3u8 list create by: mediafilesegmenter --encrypt-key-file=keya.key --encrypt-key-url="keya.key" --iso-fragmented input.mp4
before this patch: bogon:xxx StevenLiu$ ./ffplay -allowed_extensions ALL prog_index.m3u8 ffplay version N-91601-g551a029a18 Copyright (c) 2003-2018 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.2) configuration: --enable-libass --enable-opengl --enable-libx264 --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local --enable-libtesseract --enable-libspeex --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac --enable-videotoolbox --enable-libxml2 libavutil 56. 19.100 / 56. 19.100 libavcodec 58. 22.101 / 58. 22.101 libavformat 58. 17.101 / 58. 17.101 libavdevice 58. 4.101 / 58. 4.101 libavfilter 7. 26.100 / 7. 26.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [hls,applehttp @ 0x7fa30305f000] Opening 'fileSequence0.mp4' for reading [hls,applehttp @ 0x7fa30305f000] Opening 'keya.key' for reading [hls,applehttp @ 0x7fa30305f000] Opening 'crypto:fileSequence1.mp4' for reading Format ac3 detected only with low score of 25, misdetection possible! [ac3 @ 0x7fa304869000] frame sync errorvq= 0KB sq= 0B f=0/0 [ac3 @ 0x7fa304869000] new coupling strategy must be present in block 0 [ac3 @ 0x7fa304869000] error decoding the audio block Input #0, hls,applehttp, from 'prog_index.m3u8': Duration: 00:00:59.87, start: 0.000000, bitrate: 0 kb/s Program 0 Metadata: variant_bitrate : 0 Stream #0:0: Audio: ac3, 48000 Hz, 5.1(side), fltp, 320 kb/s Metadata: variant_bitrate : 0 [ac3 @ 0x7fa30382b800] frame sync error [ac3 @ 0x7fa30382b800] new coupling strategy must be present in block 0 [ac3 @ 0x7fa30382b800] error decoding the audio block [ac3 @ 0x7fa30382b800] expacc 125 is out-of-range sq= 0B f=0/0 [ac3 @ 0x7fa30382b800] error decoding the audio block after this patch: bogon:xxx StevenLiu$ ./ffplay -allowed_extensions ALL prog_index.m3u8 ffplay version N-91602-g03fc3a68e7 Copyright (c) 2003-2018 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.2) configuration: --enable-libass --enable-opengl --enable-libx264 --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local --enable-libtesseract --enable-libspeex --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac --enable-videotoolbox --enable-libxml2 libavutil 56. 19.100 / 56. 19.100 libavcodec 58. 22.101 / 58. 22.101 libavformat 58. 17.101 / 58. 17.101 libavdevice 58. 4.101 / 58. 4.101 libavfilter 7. 26.100 / 7. 26.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [hls,applehttp @ 0x7f86e1868000] Opening 'keya.key' for reading/0 [hls,applehttp @ 0x7f86e1868000] Opening 'crypto:fileSequence0.mp4' for reading [hls,applehttp @ 0x7f86e1868000] Opening 'crypto:fileSequence1.mp4' for reading Input #0, hls,applehttp, from 'prog_index.m3u8': Duration: 00:00:59.87, start: 10.000000, bitrate: 0 kb/s Program 0 Metadata: variant_bitrate : 0 Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 992 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc Metadata: variant_bitrate : 0 major_brand : mp42 minor_version : 1 compatible_brands: mp41mp42isomhlsf creation_time : 2018-08-13T10:04:15.000000Z Stream #0:1: Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 232 kb/s Metadata: variant_bitrate : 0 [hls,applehttp @ 0x7f86e1868000] Opening 'crypto:fileSequence2.mp4' for reading Signed-off-by: Steven Liu <l...@chinaffmpeg.org> --- libavformat/hls.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libavformat/hls.c b/libavformat/hls.c index 3d4f7f2647..8ad08baaed 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -811,6 +811,27 @@ static int parse_playlist(HLSContext *c, const char *url, ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_init_section_args, &info); cur_init_section = new_init_section(pls, &info, url); + cur_init_section->key_type = key_type; + if (has_iv) { + memcpy(cur_init_section->iv, iv, sizeof(iv)); + } else { + int seq = pls->start_seq_no + pls->n_segments; + memset(cur_init_section->iv, 0, sizeof(cur_init_section->iv)); + AV_WB32(cur_init_section->iv + 12, seq); + } + + if (key_type != KEY_NONE) { + ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key); + cur_init_section->key = av_strdup(tmp_str); + if (!cur_init_section->key) { + av_free(cur_init_section); + ret = AVERROR(ENOMEM); + goto fail; + } + } else { + cur_init_section->key = NULL; + } + } else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) { if (pls) pls->finished = 1; -- 2.15.2 (Apple Git-101.1) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel