Created
April 8, 2017 20:20
-
-
Save koteq/05e95bac9bfa8967ac18a124103eedde 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
@echo off | |
:: WARNING: after some testing considered as not recommended. | |
:: Filter to keep only non similar frames. | |
:: It selects only first frame `eq(n\,0)` | |
:: and frames with differences `gt(scene\,{sensivity})` | |
:: see https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect | |
set similar_frames_sensivity=0.002 | |
set skip_similar_frames=select=eq(n\,0)+gt(scene\,%similar_frames_sensivity%) | |
:: Adaptive Temporal Averaging Denoise. | |
:: https://ffmpeg.org/ffmpeg-filters.html#atadenoise | |
set atadenoise=atadenoise | |
:: Drop frames that do not differ greatly from the previous frame | |
:: https://ffmpeg.org/ffmpeg-filters.html#mpdecimate | |
set mpdecimate=mpdecimate | |
:: Calculate a palette | |
:: see https://ffmpeg.org/ffmpeg-filters.html#palettegen-1 | |
ffmpeg -i %1 -vf "%mpdecimate%,%atadenoise%,palettegen=stats_mode=full" "%~dpn1.palette.png" | |
:: Transcode video to a gif with the palette | |
ffmpeg -i %1 -i "%~dpn1.palette.png" -lavfi "%mpdecimate%,%atadenoise%,paletteuse=dither=bayer" -y "%~dpn1.gif" | |
:: Cleanup | |
del "%~dpn1.palette.png" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment