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

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

文件m3u8位置是

https://hls2.videos.sproutvideo.com/4c6...../b24db8.../video/720.m3u8?Policy=eyJTd....._&Signature=S7pry.....__&Key-Pair-Id=APKAIB5DGCGAQJ4GGIUQ

720.key

https://hls2.videos.sproutvideo.com/4c6...../b24db8.../video/720.key?Policy=eyJTd....._&Signature=S7pry.....__&Key-Pair-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 Forbiddenkeyts文件的

[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

我的问题是如何将一次性查询字符串放入每个ts文件key,以便 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

相关内容