Created
January 10, 2016 23:46
-
-
Save kg/a343131f085a1396a4f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@if [%6]==[] goto error | |
@goto ok | |
:error | |
@echo USAGE: video2gif START_TIME DURATION WIDTH FRAME_RATE (DITHER_OPTIONS) (CROP_RECTANGLE width:height:x:y) INPUT OUTPUT | |
@goto end | |
:ok | |
@set PALETTE="%TEMP%\palette.png" | |
@set START_TIME=%1 | |
@set DURATION=%2 | |
@set WIDTH=%3 | |
@set FRAME_RATE=%4 | |
@if [%7]==[] goto dither_omitted | |
@if [%8]==[] goto dither_specified | |
:crop_specified | |
set DITHER_OPTIONS=%5 | |
set CROP_RECTANGLE=crop=%6, | |
@set INPUT=%7 | |
@set OUTPUT=%8 | |
@goto who_cares | |
:dither_specified | |
set DITHER_OPTIONS=%5 | |
@set CROP_RECTANGLE= | |
@set INPUT=%6 | |
@set OUTPUT=%7 | |
@goto who_cares | |
:dither_omitted | |
@set DITHER_OPTIONS=dither=bayer:bayer_scale=4 | |
@set CROP_RECTANGLE= | |
@set INPUT=%5 | |
@set OUTPUT=%6 | |
@goto who_cares | |
:who_cares | |
@set PALETTEUSE=%DITHER_OPTIONS%:diff_mode=rectangle | |
@set FILTERS=fps=%FRAME_RATE%,%CROP_RECTANGLE%scale=%WIDTH%:-1:flags=lanczos | |
@set OPTS_PREFIX=-v warning -ss %START_TIME% -t %DURATION% -i %INPUT% | |
ffmpeg %OPTS_PREFIX% -vf "%FILTERS%,palettegen=stats_mode=diff" -y %PALETTE% | |
ffmpeg %OPTS_PREFIX% -i %PALETTE% -lavfi "%FILTERS% [x]; [x][1:v] paletteuse=%PALETTEUSE%" -y %OUTPUT% | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment