本帖最后由 yakeyun 于 2023-2-4 09:46 编辑
回复 1# lvwenjun11
[分享]批处理一键执行M3U8视频转码合并 - BAT求助&讨论 - 批处理之家 批处理_BAT脚本_PowerShell_VBS_CMD_DOS_Perl_Python - Powered by Discuz! http://www.bathome.net/thread-62860-1-1.html
可以参考下,这个是对单个视频文件批量处理的代码。如果要批量处理多个视频,就需要修改代码,以最终子目录为目标,先输出子目录名录到文本,然后逐一读取对应子目录处理。批处理放到TS文件夹外层目录下运行:- @echo off
- title M3U8视频转换合并工具v1.1 By.sanli
- cd /d "%~dp0"
- if not exist %SystemRoot%\System32\ffmpeg.exe (curl -O http://bcn.bathome.net/tool/ffmpeg,4.3/ffmpeg.exe & move /y "ffmpeg.exe" "%SystemRoot%\System32\ffmpeg.exe")
- if not exist %SystemRoot%\System32\ffmpeg.exe (mshta "vbscript:msgbox("当前网络不可用,无法继续执行!",0,"提醒:") & window.close" & exit )
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ("%cd%") do set name=%%~na
- for /f "tokens=* delims=, " %%a in ('dir /a /s /b .\*.ts') do (
- ffmpeg -i "%%a" -threads 4 -f mp4 -codec copy "000%%~na.mp4"
- )
-
- (
- for /f "tokens=* delims=, " %%a in ('dir /a /s /b .\*.mp4') do (
- echo %%~nxa
- )
- )>del.txt
- (
- for /f "tokens=* delims=, " %%a in ('dir /a /s /b .\*.mp4') do (
- echo file '%%~nxa'
- )
- )>config.txt
-
- ffmpeg -f concat -i config.txt -c copy output.mp4
- ren output.mp4 "!name!.mp4"
- for /f %%a in (del.txt) do (
- del %%a
- )
- if exist del.txt (del del.txt)
- if exist config.txt (del config.txt)
- exit
复制代码
|