隐藏

向bat拖拽进文件夹利用ffmpeg把视频向指定路径切片成m3u8文件和若干ts文件?

发布:2021/3/22 14:17:40作者:管理员 来源:本站 浏览次数:1262

以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI
/*&cls
@echo off
rem 把一个指定文件夹拖曳到bat文件图标上使用ffmpeg将文件夹里mp4视频文件进行切片生成一个m3u8文件和多个ts文件
mode con lines=3000
setlocal enabledelayedexpansion
>"%tmp%\t.t" echo;!cmdcmdline!
endlocal
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
set "oldfolder="
set "newfolder=G:\动漫"
set ext=*.mp4
set "exefile=bin\ffmpeg.exe"
if not exist "%exefile%" (echo;"%exefile%" not found&pause&exit)
>"%tmp%\j.j" echo;s=WSH.StdIn.ReadLine().replace(/^^.+?\.(bat^|cmd)" /ig,'');
>>"%tmp%\j.j" echo;WSH.echo(s.replace(/"/g,'').replace(/ (?=[a-z]:)/ig,'\r\n'));
for /f "delims=" %%a in ('type "%tmp%\t.t"^|cscript -nologo -e:jscript "%tmp%\j.j"') do (
if exist "%%a\" set "oldfolder=%%a"
)
if not defined oldfolder (echo;拖曳指定文件夹到bat文件图标上&pause&exit)
set "file="
pushd "%oldfolder%"
for /f "delims=" %%a in ('dir /a-d-h/b/s %ext%') do set "file=%%a"
popd
if not defined file (echo;%ext% not found&pause&exit)
for /f "delims=" %%a in ("%file%") do (
if not exist "%newfolder%\%%~na" md "%newfolder%\%%~na"
"%exefile%" -i "%%a" -c copy -map 0 -f segment -segment_list "%newfolder%\%%~na\%%~na.m3u8" -segment_time 5 "%newfolder%\%%~na\out%%6d.ts"
)
echo;
echo;%#% +%$%%$%/%@% %z%
pause
exit