回复 1# a574045075 - @echo off
- setlocal enabledelayedexpansion
- REM 视频结尾最后3秒处
- set "SecBack=3"
- REM 根据自己电脑实际情况设置ffmpeg的路径
- set "path=C:\Program Files\ffmpeg\ffmpeg-n5.1-latest-win64-gpl-5.1\bin\;%path%"
- for /f "delims=" %%i in ('dir /b /a-d *.mp4') do (
- echo Current file: %%i
- for /f "tokens=2-5 delims=:., " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "Duration:"') do (
- echo Duration %%a:%%b:%%c:%%d
- set /a "TotalCS=(1%%a%%100*3600+1%%b%%100*60+1%%c%%100)*100+1%%d%%100"
- set /a "SeekCS=TotalCS-SecBack*100"
- set /a "SeekSS=SeekCS/100"
- set /a "HH=SeekSS/3600+100"
- set /a "MM=SeekSS%%3600/60+100"
- set /a "SS=SeekSS%%60+100"
- set /a "CS=SeekCS%%100+100"
- set "SeekPosition=!HH:~1!:!MM:~1!:!SS:~1!.!CS:~1!"
- echo Position !SeekPosition!
- )
- ffmpeg -v quiet -i "%%i" -ss !SeekPosition! -frames:v 1 "%%~ni.png"
- )
复制代码
|