标题: [其他] m3u8网站视频下载合并工具 [打印本页]
作者: xp3000 时间: 2021-3-19 19:11 标题: m3u8网站视频下载合并工具
本帖最后由 xp3000 于 2021-3-19 20:41 编辑
在线看电影,不知道是不是下雨原因,一卡一卡的,用这个下载完再看就方便了
需要下载aria2c.exe、grep.exe和ffmpeg.exe放入C:\Windows\System32
下载工具aria2c
http://bcn.bathome.net/s/tool/index.html?key=aria2c
字符串搜索工具grep
http://bcn.bathome.net/s/tool/index.html?key=grep
视频合并工具ffmpeg
http://bcn.bathome.net/s/tool/index.html?key=ffmpeg
外站这里有最新版的https://github.com/BtbN/FFmpeg-Builds/releases- @echo off&Setlocal EnableDelayedExpansion
- title aria2c下载m3u8视频合并工具
-
- CD /D "%~dp0"
- set /p "str=请输入index.m3u8链接地址:"
- del index.m3u8&@aria2c.exe -c -s 5 %str%
- echo 正在后台单链接下载,不要关闭……&md "m3u8"
- @grep -oP "[^\/\n]*$" index.m3u8>"m3u8\index.m3u8"
- @ren 未下载.TXT m3u8.TXT&@aria2c.exe -c -s 5 -m 0 -d "m3u8" m3u8.TXT&del m3u8.TXT
-
- @for /f "delims=*" %%a in ('echo;%str%^|grep -oP "^[^\n]+\/"') do (
- @for /f "tokens=*" %%b in ('grep -oP "[^\/]+\.ts$" "%~dp0m3u8\index.m3u8"') do (
- if exist %~dp0m3u8\%%b (echo 存在%%b
- ) else (echo %%b不存在……&echo 正在下载%%a%%b&CD %~dp0
- for /f "tokens=1,* delims==" %%i in ('aria2c.exe -c -s 5 -m 0 -d "m3u8" %%a%%b^|grep -oP "ERROR.*URI=[^\r\n]*"') do (
- set "fn=%%i"&set fn=!fn:^[=!!fn:^]=!&echo;%%j>>未下载.TXT
- )
- )
- )
- )
- echo 检查是否存在没下载成功的视频,
- echo 如果全部下载完,按任意键合并,
- echo 否则直接关闭……
- pause
- cd "%~dp0m3u8" & ffmpeg -i "index.m3u8" -vcodec copy -acodec copy "合并.mp4"
-
- cls&echo 合并完成,按任意键删除所有ts视频
- echo 如果不删除,直接关闭即可……
- pause
- del *.ts
- pause
复制代码
因为有的网站关闭浏览器后m3u8就下载不了,最好是先打开网页把m3u8地址找出来
打开网站后,右键查看网页源代码,一般里面有两个,有一个假的,例如:
https://www.kan.cc/play/687-0-0.html
https://www.dgzhuorui.com:65/202 ... 00kb/hls/index.m3u8
复制index.m3u8的连接,粘贴进批处理即可
作者: thp2008 时间: 2021-3-21 14:20
本帖最后由 thp2008 于 2021-3-21 20:38 编辑
下载可以,合并的时候出错了。合并那句估计有点问题。
报错如下:
Failed to open segment 2623 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/hr6ClSRZ.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2624 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/4PU2BK26.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2625 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/pnwFr7E3.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2626 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/ovFBsl6i.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2627 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/TyQA4W0O.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2628 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/GefQI1E2.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2629 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/6B9bFp4Q.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2630 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/FdsTgDCJ.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2631 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/0pPd2CDs.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2632 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/M4G5y0xs.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2633 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/Lg7ILrmR.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2634 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/4VRrSW1p.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2635 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/B6ad76Mf.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2636 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/Gx7ax3jL.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2637 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/J9Mc0Muz.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2638 of playlist 0
[hls @ 0682d6c0] Opening '/20200825/uzO40ti3/1200kb/hls/BYvGLacl.ts' for reading
[hls @ 0682d6c0] Failed to open segment 2639 of playlist 0
[hls @ 0682d6c0] Error when loading first segment '/20200825/uzO40ti3/1200kb/hls/7S1uVr30.ts'
index.m3u8: Invalid data found when processing input
下载已完成,2000多个小文件。就是不能合成成功。
作者: xp3000 时间: 2021-3-21 23:12
不对啊,我是grep -oP "[^\/]+\.ts$先搜非/的字符到ts输出到m3u8\index.m3u8
再进cd "%~dp0m3u8"后合并,
m3u8文件夹的index.m3u8是没有/20200825/uzO40ti3/1200kb/hls/这部分的
(这个直接在批处理上第二次输入链接就能继续未完成下载)
感觉应该是ffmpeg问题,m3u8是新出来的,论坛的17mb,我用的这个53mb
https://www.filehorse.com/download-ffmpeg/old-versions/
Download FFmpeg 4.3.1 (32-bit)
Free Download
在Start Download上右键复制链接,
用aria2c.exe -c 链接下载的,
这个网站慢,而且链接经常变,
但是连接断了可以重新复制再来
64位系统这里下载要快一点,在release下面
https://www.gyan.dev/ffmpeg/builds/
作者: xp3000 时间: 2021-3-22 07:50
本帖最后由 xp3000 于 2021-3-22 11:05 编辑
试了下论坛下载的ffmpeg可以合并,应该是你操作问题,这个将链接保存到TXT,不用一次次输入了- @echo off
-
- @for /f "tokens=*" %%a in ('dir /b/a-d/oN *.txt') do (
- @for /f "tokens=1,* delims=:" %%b in ('grep -Eo "https?.+\.m3u8" %%a^|grep -n -Eo "^.+\/"') do (
- if exist %~dp0%%~na_视频%%b合并.mp4 (echo 已下载链接%%b,合并为%%~na_视频%%b合并.mp4
- ) else (md 视频%%b
- aria2c.exe -c -s 5 -m 0 %%cindex.m3u8 -o "%%~na%%b.m3u8" & grep -Eo "[^\/\n]*$" "%%~na%%b.m3u8">"视频%%b\%%b.m3u8"
-
- @ren 未下载视频%%b.TXT 视频%%b.TXT 2>nul & @aria2c.exe -c -s 5 -m 0 -d "视频%%b" 视频%%b.TXT 2>nul & del 视频%%b.TXT 2>nul
-
- pushd
- for /f "delims=*" %%e in ('grep -Eo "[^\/]+\.ts$" "%~dp0视频%%b\%%b.m3u8"') do (
- if exist %~dp0视频%%b\%%e.aria2 DEL %~dp0视频%%b\%%e*
- if exist %~dp0视频%%b\%%e (echo 存在%~dp0视频%%b\%%e
- ) else (echo %~dp0视频%%b\%%e不存在……&echo 正在下载%%c%%e
- for /f "tokens=1,* delims==" %%i in ('aria2c.exe -c -s 5 -m 0 -d "%~dp0视频%%b" %%c%%e^|grep -Eo "ERROR.*URI=[^\r\n]*"') do (
- set "fn=%%i"&set fn=!fn:^[=!!fn:^]=!&echo;%%c%%e>>未下载视频%%b.TXT
- )
- )
- )
- echo 检查是否存在没下载成功的视频,
- echo 如果全部下载完,按任意键合并,
- echo 否则直接关闭,再重新打开……
- pause
- if exist %~dp0未下载视频%%b.TXT (echo 有未下载的视频,关闭打开即可&pause&exit /b
- ) else (
- cd "%~dp0视频%%b" & ffmpeg -i "%%b.m3u8" -vcodec copy -acodec copy "%~dp0%%~na_视频%%b合并.mp4" & cd "%~dp0"
- rd /s /q "%~dp0视频%%b" 2>nul & del "%%~na%%b.m3u8" 2>nul
- )
- )
- ))
- pause
复制代码
作者: 老刘1号 时间: 2021-3-22 10:31
感谢分享,我个人习惯直接上ffmpeg下载+合并+转封装,一句搞定比较省事,就是下载是单线程,速度慢
最近发现IDM下载m3u8有自动合并功能,挺舒服的,也是多线程,就换IDM了
之前看到的其它下载工具:https://github.com/nilaoda/N_m3u8DL-CLI/
作者: xp3000 时间: 2021-3-22 11:14
本帖最后由 xp3000 于 2021-3-22 11:42 编辑
回复 5# 老刘1号
谢谢分享,你的吗?试用了感觉不错,
希望支持更多网站
作者: thp2008 时间: 2021-3-22 11:53
回复 3# xp3000
我是在论坛下载的,18M的,不知道为什么会出错,我重试了几次都不行,算了,我看楼下介绍的工具,挺好用的。感谢
作者: thp2008 时间: 2021-3-22 11:54
回复 5# 老刘1号
这个工具不错,速度超快,一次性解决,小巧,简单,方便。好用。
好工具多分享,感谢!
作者: 老刘1号 时间: 2021-3-22 12:02
回复 6# xp3000
不是我写的,是吾爱论坛一位大佬写的,原帖好像因为涉及影视资源被删了,就不贴出来了
作者: xp3000 时间: 2021-3-22 12:36
哦,我发现原来是我网络问题,动不动网站访问不了
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |