如何使用查询字符串和EXT-X-KEY下载.m3u8视频?


0

m3u8 文件位置是

https://hls2.videos.sproutvideo.com/4c6...../b24db8.../video/720.m3u8?Policy=eyJTd....._&Signature=S7pry.....__&密钥对-ID = APKAIB5DGCGAQJ4GGIUQ

720.key 在...

https://hls2.videos.sproutvideo.com/4c6...../b24db8.../video/720.key?Policy=eyJTd....._&Signature=S7pry.....__&密钥对-ID = APKAIB5DGCGAQJ4GGIUQ

如果我正在使用 ffmpeg -i "https://hls2.videos.sproutvideo.com/4c6...../b24db8.../video/720.m3u8?Policy=eyJTd....._&Signature=S7pry.....__&Key-Pair-Id=APKA..... -c copy 01.ts 下载播放列表。它会得到一个 HTTP error 403 Forbidden 为了它 keyts 文件

[https @ 000000000364d8c0] HTTP error 403 Forbidden
Unable to open key file https://hls2.videos.sproutvideo.com/4c6...../b24db8.../video/720.key
[hls,applehttp @ 00000000005ec180] Opening 'crypto+https://hls2.videos.sproutvideo.com/4c6...../b24db8.../video/720_00000.ts' for rea
ding
[https @ 000000000364cc80] HTTP error 403 Forbidden
[crypto @ 0000000003695dc0] Unable to open resource: https://hls2.videos.sproutvideo.com/4c6...../b24db8.../video/720_00000.ts
[hls,applehttp @ 00000000005ec180] Failed to open segment 0 of playlist 0
[hls,applehttp @ 00000000005ec180] Opening 'crypto+https://hls2.videos.sproutvideo.com/4c6...../b24db8.../video/720_00001.ts' for rea
ding

然后我发现资源只能通过某些特定的查询字符串来访问。在这种情况下,它会 ?Policy=eyJTd....._&Signature=S7pry.....__&Key-Pair-Id=APKAIB5DGCGAQJ4GGIUQ

我的问题是如何为每个提供一次性查询字符串 tskey 文件,以便ffmpeg能够下载它。

720.m3u8 文件内容:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="720.key",IV=0x2f1fb3a9fd334f2babb6cc77f7753129
#EXTINF:10.000000,
720_00000.ts
#EXTINF:10.000000,
720_00001.ts
#EXTINF:10.000000,
720_00002.ts
#EXTINF:10.000000,
720_00003.ts
#EXTINF:8.733333,
720_00004.ts
#EXT-X-ENDLIST

不确定它是否可以工作,但考虑尝试“youtube-dl”。尽管它的名字很棒,所以那些复杂的东西都可以获得所有必需品和从任何网页/ URL中提取的bob然后继续下载内容。它使用引擎盖下的ffmpeg进行进一步处理。
TBR
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.