解密ts分片视频

AES-128 加密的 ts 视频文件如何解密合并

新的一年,来了。
和往常一样,又是一段养生朋克的日子,等待着那笔早该入手的间歇性资本主义安慰。
算了,怀揣着不安的心倒不如打开电脑来看剧,那一刻我愿与这个世界为敌……
什么?网站上的剧居然下载不了~ 秒按 option+command+i 打开调试器查看,我去 blob: https:// 是什么鬼。。。
再看Netword选项XHR一堆ts文件请求,我点进去下载下来居然是一小段视频片段啊!
仿佛这个世界又一次成为了我的敌人… 废话不多说,一起开始撸代码做工具下载小视频吧 !~

FFmpeg如何加密视频

1.获取加密用16字节key,并查看其值。

$ openssl rand 16 > enc.key
$ xxd enc.key

查看enc.key的值
如图查看enc.key的值为000b92f10d9f69ab44c4956f22270f7a

2.获取加密用iv并查看其值。

$ openssl rand -hex 16 > enc.iv.txt
$ xxd enc.iv.txt

查看偏移量enc.iv.txt的值
如图查看偏移量enc.iv.txt的值为62b27e3171bb3c0613e4fb0985e00b83

3.生成hls_key_info_file其内容形式如下:

Key URI
Path to key file
IV (optional)

hls_key_info_file
vim enc.keyinfo

https://localhost/enc.key
enc.key
62b27e3171bb3c0613e4fb0985e00b83

:wq
注意:第三行的哈希值62b27e3171bb3c0613e4fb0985e00b83默认是32个0不写也可以。

4.使用FFmpeg切片视频为加密的hls视频

eg: ffmpeg -i PRTD-24.mp4 -hls_time 10 -hls_key_info_file enc.keyinfo -hls_playlist_type vod -hls_segment_filename "PRTD_%d.ts" PRTD-24.m3u8

$ ffmpeg -i [filename.mp4] -hls_time 10 -hls_key_info_file enc.keyinfo -hls_playlist_type vod -hls_segment_filename "filename_%d.ts" [filename.m3u8]

hls
如图执行完成后有:PRTD-24.m3u8 PRTD-240.ts PRTD-241.ts PRTD-242.ts 这些文件,其中.m3u8是索引文件,一般都是通过这个文件来爬去网站上的所有分片视频,.ts是加密的分片视频文件。

解密视频

使用openssl解密ts视频,其中参数-iv默认是32个0如果设置了就用哈希值,参数大写的-K是秘钥的值。
eg: openssl aes-128-cbc -d -in PRTD-240.ts -out 0.ts -nosalt -iv 62b27e3171bb3c0613e4fb0985e00b83 -K 000b92f10d9f69ab44c4956f22270f7a

$ openssl aes-128-cbc -d -in test0.ts -out 0.ts -nosalt -iv 00000000000000000000000000000000 -K 000b92f10d9f69ab44c4956f22270f7a

hls
如图对每个加密的ts文件执行后就是解密的ts视频文件了,再用FFmpeg合并解密后的分片视频就是原视频了。

$ ffmpeg -i "concat:0.ts|1.ts|2.ts" -acodec copy -vcodec copy -absf aac_adtstoasc output.mp4

工具使用git仓库下载

简单的m3u8下载工具,可以下载未加密的ts分片视频自动用FFmpeg合并。
git@github.com:eson-sheng/download-m3u8-to-mp4.git

工具使用很简单:主要是找到.m3u8文件的地址。
打开命令行输入 php download_m3u8.php --url https://xxx/index.m3u8 就开始下载视频啦 ~

上文中说的例举视频我已经放入仓库中的demo文件里,供大家参考学习哦^_^

视频快速下载方法

可以直接使用FFmpeg的方法下载视频。

eg:

ffmpeg -i https://localhost/playlist.m3u8 -c copy file_name.mp4

前端加载ts视频

请关注此项目 githubgithubhttps://github.com/eson-sheng/moviehttps://github.com/eson-sheng/movie 超酷!


Thanks♪(・ω・)ノ 感谢你长得那么好看还来看我的博客!see you around ~

00:00/00:00


顾北辰

?偶遇故人点头微笑^_^心像透明水滴☝没有喜悲…?

8 条评论

ifsa videolari · 2024年6月12日 下午1:00

one thing I find funny is that people search for money and numbers on the internet. And they are here every day begging to be recognized, for money, fame or praise. After they make money they disappear and appear when they want without the slightest regard for the people who put them where they are. For me this is at least dishonest. No matter who your vote is! Jared Landu

bedava bitcoin · 2024年6月12日 上午11:48

I wish to get across my love for your generosity giving support to individuals who need help with your question. Your personal dedication to getting the message all through turned out to be surprisingly useful and have usually enabled regular people like me to realize their objectives. Your own insightful publication denotes a lot a person like me and further more to my colleagues. Best wishes; from all of us. Dee Villella

freespin · 2024年6月9日 上午10:03

Goeiemore Dr. Christa. Het u al WordPress se vinnige konsep blogform gebruik? In Engels ook bekend as quickpress. Dis te vinde amper aan die onderkant van die blog se beheerpaneel, oftewel Dashboard. Ek gebruik dit baie en het nog nie probleme gehad daarmee nie. Ek sukkel self bietjie met WordPress se rich text editor maar gelukkig gebruik quickpress darem plain text. Edmundo Scarpitto

yasadisi bahis oyna · 2024年5月30日 下午7:53

Next time I read a blog, Hopefully it does not fail me as much as this one. After all, I know it was my choice to read, but I really thought you would probably have something interesting to talk about. All I hear is a bunch of whining about something that you can fix if you were not too busy seeking attention. Mikel Beitz

rdxzxc · 2020年10月11日 下午3:18

你好,有偿求指教,麻烦联系

黑鱼 · 2020年6月25日 下午4:19

可以邮件联系下,求帮忙,这个看的不明白

gary · 2020年3月4日 上午12:21

建议换个图床 图片太慢了

· 2020年1月6日 下午6:24

优秀的橙橙解决了恼人的ts文件??????

发表回复

Avatar placeholder

您的邮箱地址不会被公开。 必填项已用 * 标注