利用 FFmpeg palettegen paletteuse 生成接近全色的 gif 动画

下载FFmpeg-VideoToGif-v1.0.bat.7z

FFmpeg 2.6 及以上版本有效
未使用palette时 使用palette后
@echo off
set    inFile=2015.06.12.avi
set startTime=00:00:30.497 
set   endTime=00:00:37.037
set       fps=10
set     width=240

call Lib_CalculateTotalTime.bat %startTime% %endTime%
set totalTime=%TOTAL_TIME%
set "startTime=%startTime: =%"
set "endTime=%endTime: =%"
set "startTimeStr=%startTime::=.%"
set "endTimeStr=%endTime::=.%"
set outFile="out-%width%-%startTimeStr%-%endTimeStr%.gif"
set palette=palette.png
set filters=fps=%fps%,scale=%width%:-1:flags=fast_bilinear

prompt .
@echo %time%
REM Generate one palette -v warning  
@echo on
ffmpeg -v fatal -ss %startTime% -t %totalTime% -i "%inFile%" -vf %filters%,palettegen -y %palette%
@echo %time%
@echo off
REM Generate one gif
@echo on
ffmpeg -v fatal -ss %startTime% -t %totalTime% -i "%inFile%" -i %palette% -lavfi "%filters% [x]; [x][1:v] paletteuse" -y %outFile%

@echo %time%
@echo off
@echo.
@echo ---- Generate finished ----
del %palette%
@echo 
pause>nul
posted @ 2015-07-25 02:18  1CM  阅读(1569)  评论(0编辑  收藏  举报