rt,在用批处理进行视频截图分割的时候出现了这个问题,而且截取出来的图像是灰色的- @echo off
- setlocal enabledelayedexpansion
-
- set index=0
-
- for %%f in (*.mp4) do (
- set files[!index!]=%%~nf
- echo !index!. %%~nf
- set /a index+=1
- )
- set /p select_index=Select:
- for /l %%i in (!select_index!, 1, !select_index!) do (
- if defined files[%%i] (
- call :cut_mp4 !files[%%i]!
- )
- )
-
- exit /b 0
-
- :convert_mp4
- ffmpeg -i %~1.mp4 ^
- -c:a copy ^
- -c:v hevc_nvenc ^
- -vf scale=1920:-1 ^
- -preset slow ^
- -crf 20 ^
- output/%~1.mp4
- exit /b 0
-
- :cut_mp4
- md output\%~1
-
- for /f "tokens=2 delims=, " %%a in ('ffmpeg -i %~1.mp4 2^>^&1 ^| find "Duration:"') do (
- set duration=%%a
- set /a duration_seconds=!duration:~0,2!*3600+!duration:~3,2!*60+!duration:~6,2!
- set /a frames=!duration_seconds!/30
- )
-
- for /l %%j in (1, 1, !frames!) do (
- set /a hours=%%j/120
- if !hours! lss 10 (set hours=0!hours!)
- set /a minutes=%%j/2-!hours!*60
- if !minutes! lss 10 (set minutes=0!minutes!)
- set /a seconds=%%j*30-!hours!*3600-!minutes!*60
- if !seconds! lss 10 (set seconds=0!seconds!)
- set times=!hours!:!minutes!:!seconds!
-
- ffmpeg -loglevel error ^
- -ss !times! ^
- -i %~1.mp4 ^
- -f image2 ^
- -frames:v 1 ^
- -q:v 1 ^
- output/%~1/!hours!_!minutes!_!seconds!-0.jpg
- )
- exit /b 0
-
- pause
复制代码
|