解决加密的HLS(m3u8)视频转换问题

下载视频,遇到一个问题,下载后无法播放,百度一下原来是HLS加密。

M3U8格式分析

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="key.key" #这个就是密钥
#EXTINF:6.08,
000.ts
#EXTINF:10,
001.ts
#EXTINF:10,
002.ts
#EXTINF:10,
003.ts
#EXTINF:10,
004.ts
#EXTINF:10,
005.ts
......

看下key里是什么内容:

b47fa130f88e8e9a

先把所有的ts以及最重要的key.key都下载下来放到一个目录内。

然后修改m3u8,把里面的所有连接都改成本地相对连接。

F:\迅雷下载\XXXXXXXX>ffmpeg -i list.m3u8 -c copy -bsf:a aac_adtstoasc ALL.mp4
ffmpeg version 2.5.3 Copyright (c) 2000-2015 the FFmpeg developers
  built on Aug  3 2015 16:53:06 with gcc 4.9.1 (GCC)
  configuration: --arch=x86 --cross-prefix=/home/builder/mingw-w64-i686-3.6.4/mingw-w64-i686/mingw-w64-i686/bin/i686-w64-mingw32- --target-os=mingw32 --pkg-config=pkg-config --disa
ble-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv -
-enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb --enable-li
bopencore-amrwb --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-li
bvo-aacenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libxavs --enable-libxvid --enable-lzma --enable-zlib --enable-libfdk-aa
c --enable-nonfree --enable-dxva2 --disable-sse --disable-sse2 --disable-amd3dnow --disable-amd3dnowext --disable-sse3 --disable-ssse3 --disable-sse4 --disable-sse42 --disable-avx
--disable-os2threads --disable-ffplay --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --prefix=/home/builder/ffmpeg-i686-mw364-trunk --ex
tra-cflags='-m32 -I/home/builder/mingw-w64-i686-3.6.4/mingw-w64-i686/mingw-w64-i686/include' --extra-ldflags='-L/home/builder/mingw-w64-i686-3.6.4/mingw-w64-i686/mingw-w64-i686/lib -L/home/builder/mingw-w64-i686-3.6.4/mingw-w64-i686/mingw-w64-i686/bin -static-libgcc -static -lpthread'
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, hls,applehttp, from 'list.m3u8':
  Duration: 00:26:41.20, start: 1.459000, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1080x608 [SAR 1216:1215 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 4 kb/s Output #0, mp4, to 'ALL.mp4': Metadata: encoder : Lavf56.15.102 Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1080x608 [SAR 1216:1215 DAR 16:9], q=2-31, 25 fps, 90k tbn, 90k tbc Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 4 kb/s Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [mp4 @ 004c7a00] Non-monotonous DTS in output stream 0:1; previous: 63488, current: 63483; changing to 63489. This may result in incorrect timestamps in the output file. frame=40030 fps=8265 q=-1.0 Lsize= 105439kB time=00:26:41.31 bitrate= 539.4kbits/s video:91639kB audio:12393kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.353236%

命令:
ffmpeg -i list.m3u8 -c copy -bsf:a aac_adtstoasc ALL.mp4

红色的是关键部分

PS:我使用的版本是优酷 v7.5.5.5170自带的ffmpeg

其他参考:https://blog.csdn.net/cnhome/article/details/73250495

相关文章
相关标签/搜索