- @echo off
- chcp 65001 >nul
- rem https://qastack.cn/superuser/579008/add-1-second-of-silence-to-audio-through-ffmpeg
- rem 批处理保存为utf-8编码格式,需要ffmpeg ffprobe
- set m=1.5
- for /f "delims=" %%i in ('dir /b /a-d *.mp3') do (
- set file=%%i
- setlocal enabledelayedexpansion
- for /f "tokens=1-2 delims==" %%a in ('ffprobe -loglevel 0 -show_streams "!file!"') do (
- if "%%a" equ "sample_rate" (
- set sr=%%b
- ) else if "%%a" equ "channel_layout" (
- set cl=%%b
- ) else if "%%a" equ "duration" (
- for /f "delims=" %%e in ('powershell -c %%b*%m%') do set dt=%%e
- )
- )
- ffmpeg -f lavfi -t !dt! -i anullsrc=channel_layout=!cl!:sample_rate=!sr! -i "!file!" -filter_complex "[1:a][0:a]concat=n=2:v=0:a=1" outputx.mp3
- move /y outputx.mp3 "!file!"
- endlocal
- )
- pause
复制代码
每次使用前先备份! |