-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvideoToGif.cmd
More file actions
46 lines (38 loc) · 1.24 KB
/
Copy pathvideoToGif.cmd
File metadata and controls
46 lines (38 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@echo off
echo ###################################################
echo # Description: Video to optimized gif
echo # Usage: videoToGif.cmd input.mov 600 [60]
echo # Param 1: Video file
echo # Param 2: Output width
echo # Param 3 [Optional]: framerate (default: 30)
echo # Requires: ffmpeg
echo ###################################################
echo.
REM Check parameters
IF "%~1"=="" (
echo Error: 1st arg must be a video file
exit /b 1
)
IF "%~2"=="" (
echo Error: 2nd arg must be output width
exit /b 1
)
REM Set defaults
set "fps=30"
IF NOT "%~3"=="" set "fps=%~3"
echo [Optional]: Using framerate of %fps%
REM Get filename
set "filename=%~1"
set "outputFile=%~n1.%~2w.%fps%-fps.gif"
echo Converting to GIF: %outputFile%
REM Create tmp directory if it doesn't exist
if not exist ".\tmp\" mkdir .\tmp
REM Set palette and filter variables
set "palette=.\tmp\palette.png"
set "filters=fps=%fps%,scale=%~2:-1:flags=lanczos"
REM Do conversion (2-pass for better quality)
ffmpeg -v warning -i "%filename%" -vf "%filters%,palettegen=max_colors=128" -y "%palette%"
ffmpeg -v warning -i "%filename%" -i "%palette%" -lavfi "%filters% [x]; [x][1:v] paletteuse" -y "%outputFile%"
REM Complete
echo Success: Movie to GIF complete:
echo # %outputFile%