Skip to content

Commit 79930e6

Browse files
committed
Add loop option
1 parent 42df1e0 commit 79930e6

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Remove CloudApp uploading
66
* Combine FPS and speed into a single flag
7+
* Add -l loop option
78

89
## 2015-03-25
910

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ gifify -r 60 recording.mov
4444
gifify -r 30@2 recording.mov
4545
```
4646

47+
- Convert it and output at 30 frames per second at 2x speed, with a single loop:
48+
49+
```sh
50+
gifify -r 30@2 -l 1 recording.mov
51+
```
52+
4753
## Regarding framerates:
4854

4955
GIF renderers typically cap the framerate somewhere between 60 and 100 frames

gifify.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ function printHelpAndExit {
99
echo 'Options: (all optional)'
1010
echo ' c CROP: The x and y crops, from the top left of the image, i.e. 640:480'
1111
echo ' o OUTPUT: The basename of the file to be output (default "output")'
12+
echo ' l LOOP: The number of times to loop the animnation. 0 (default)'
13+
echo ' for infinity.'
1214
echo ' r FPS@SPEED: With [email protected], output at 60FPS at a speed of 1.5x the'
1315
echo ' source material. NOTE: It is best to keep FPSxSPEED'
1416
echo ' below approximately 60.'
@@ -22,16 +24,18 @@ function printHelpAndExit {
2224

2325
crop=
2426
output=
27+
loop=0
2528
fpsspeed='10@1'
2629
scale=
2730

2831
OPTERR=0
2932

30-
while getopts 'c:o:p:r:s:' opt; do
33+
while getopts 'c:o:l:p:r:s:' opt; do
3134
case $opt in
3235
c) crop=$OPTARG;;
3336
h) printHelpAndExit 0;;
3437
o) output=$OPTARG;;
38+
l) loop=$OPTARG;;
3539
r) fpsspeed=$OPTARG;;
3640
p) scale=$OPTARG;;
3741
*) printHelpAndExit 1;;
@@ -86,5 +90,5 @@ delay=$(bc -l <<< "100/$fps/$speed")
8690
temp=$(mktemp /tmp/tempfile.XXXXXXXXX)
8791

8892
ffmpeg -loglevel panic -i "$filename" $filter -r $fps -f image2pipe -vcodec ppm - >> $temp
89-
cat $temp | convert +dither -layers Optimize -delay $delay - "${output}.gif"
93+
cat $temp | convert +dither -layers Optimize -loop $loop -delay $delay - "${output}.gif"
9094
echo "${output}.gif"

0 commit comments

Comments
 (0)