Skip to content

Commit

Permalink
Add loop option
Browse files Browse the repository at this point in the history
  • Loading branch information
jclem committed Apr 20, 2016
1 parent 42df1e0 commit 79930e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Remove CloudApp uploading
* Combine FPS and speed into a single flag
* Add -l loop option

## 2015-03-25

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ gifify -r 60 recording.mov
gifify -r 30@2 recording.mov
```

- Convert it and output at 30 frames per second at 2x speed, with a single loop:

```sh
gifify -r 30@2 -l 1 recording.mov
```

## Regarding framerates:

GIF renderers typically cap the framerate somewhere between 60 and 100 frames
Expand Down
8 changes: 6 additions & 2 deletions gifify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ function printHelpAndExit {
echo 'Options: (all optional)'
echo ' c CROP: The x and y crops, from the top left of the image, i.e. 640:480'
echo ' o OUTPUT: The basename of the file to be output (default "output")'
echo ' l LOOP: The number of times to loop the animnation. 0 (default)'
echo ' for infinity.'
echo ' r FPS@SPEED: With [email protected], output at 60FPS at a speed of 1.5x the'
echo ' source material. NOTE: It is best to keep FPSxSPEED'
echo ' below approximately 60.'
Expand All @@ -22,16 +24,18 @@ function printHelpAndExit {

crop=
output=
loop=0
fpsspeed='10@1'
scale=

OPTERR=0

while getopts 'c:o:p:r:s:' opt; do
while getopts 'c:o:l:p:r:s:' opt; do
case $opt in
c) crop=$OPTARG;;
h) printHelpAndExit 0;;
o) output=$OPTARG;;
l) loop=$OPTARG;;
r) fpsspeed=$OPTARG;;
p) scale=$OPTARG;;
*) printHelpAndExit 1;;
Expand Down Expand Up @@ -86,5 +90,5 @@ delay=$(bc -l <<< "100/$fps/$speed")
temp=$(mktemp /tmp/tempfile.XXXXXXXXX)

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

0 comments on commit 79930e6

Please sign in to comment.