回复 6# 877
第23行有个笔误,应该为set "SecondMp4=%CS%"- @echo off
- REM 1、下载并安装 FFmpeg 这个命令行工具
- REM https://github.com/BtbN/FFmpeg-Builds/releases
- REM 2、根据自己电脑实际安装路径设置以下临时环境变量
- set "path=C:\Program Files\ffmpeg\ffmpeg-n6.0-latest-win64-gpl-6.0\bin\;%path%"
-
- cd /d "%~dp0"
- set "OutputName=output.mp4"
- for %%i in (*.wav) do (
- set "InputWav=%%i"
- )
- for %%i in (*.mp4) do (
- set "InputMp4=%%i"
- )
-
- for /f "tokens=2-5 delims=:., " %%a in ('ffmpeg.exe -i "%InputWav%" 2^>^&1 ^| find "Duration:"') do (
- call :Time2SS %%a %%b %%c %%d
- )
- set "SecondWav=%CS%"
- for /f "tokens=2-5 delims=:., " %%a in ('ffmpeg.exe -i "%InputMp4%" 2^>^&1 ^| find "Duration:"') do (
- call :Time2SS %%a %%b %%c %%d
- )
- set "SecondMp4=%CS%"
-
- set "VideoFactor=%SecondWav%/%SecondMp4%"
- set "AudioFactor=%SecondMp4%/%SecondWav%"
-
- ffmpeg.exe -i "%InputMp4%" -vf "setpts=%VideoFactor%*PTS" -af "atempo=%AudioFactor%" "%OutputName%"
- goto :eof
-
- :Time2SS
- set /a HH=1%1-100,MM=1%2-100,SS=1%3-100
- set "CS=(%HH%*3600+%MM%*60+%3.%4)"
- goto :eof
复制代码
|