OSDN Git Service

Regular updates
[twpd/master.git] / animated_gif.md
1 ---
2 title: Animated GIFs
3 category: CLI
4 layout: 2017/sheet
5 ---
6
7 ## Animated GIFs
8 {: .-one-column}
9
10 ### Convert MP4 to GIF
11
12 ```bash
13 mkdir -p gif
14 mplayer -ao null -vo gif89a:outdir=gif $INPUT
15 mogrify -format gif *.png
16 gifsicle --colors=256 --delay=4 --loopcount=0 --dither -O3 gif/*.gif > ${INPUT%.*}.gif
17 rm -rf gif
18 ```
19
20 You'll need `mplayer`, `imagemagick` and `gifsicle`. This converts frames to .png, then turns them into an animated gif.
21
22 ### A given range
23
24 ```bash
25 mplayer -ao null -ss 0:02:06 -endpos 0:05:00 -vo gif89a:outdir=gif videofile.mp4
26 ```
27
28 See `-ss` and `-endpos`.