Skip to content

Commit

Permalink
removed gifski encoder, since ffmpeg encoder is better/equal in every…
Browse files Browse the repository at this point in the history
… way. fixes #2
  • Loading branch information
phisch committed Jun 4, 2019
1 parent d387467 commit 8e52600
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 75 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Optionally, install the following dependencies:
- slop (`--select`)
- xdotool (`--window` or desktop recording)
- zenity (`--interface zenity`)
- gifski (`--encoder gifski`)

Clone the giph repository:

Expand Down
22 changes: 0 additions & 22 deletions man/giph.1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ giph \- record gif from desktop, window or selection
\fB-w\fR \fIINT\fR |
\fB-s\fR [\fB-l\fR] [\fB-c\fR \fIFLOAT,FLOAT,FLOAT,FLOAT\fR] [\fB-p\fR \fIFLOAT\fR] [\fB-b\fR \fIFLOAT\fR]]
[\fB-i\fR \fIINTERFACE\fR]
[\fB-e\fR \fIENCODER\fR [=\fIgifski\fR \fB-q\fR \fIINT\fR]]
[\fB-d\fR \fIINT\fR]
[\fB-t\fR \fIINT\fR]
[\fB-f\fR \fIINT\fR]
Expand Down Expand Up @@ -86,15 +85,6 @@ Selects the user interface method that is used for countdown, timer and to stop
.br
\(bu
.IR zenity ": displays control-windows using zenity"
.TP
.BR \-e ", " \-\-encoder " \fISTRING\fR (default: \fIffmpeg\fR)"
Selects one of the following encoders uses to encode the gif:
.in +2
\(bu
.IR ffmpeg ": high quality gif encoder"
.br
\(bu
.IR gifski ": highest quality gif encoder, rather slow, uses \fBGIFSKI OPTIONS\fR described below"
.SH SLOP OPTIONS
When
.BR -s " or " --select
Expand Down Expand Up @@ -128,17 +118,5 @@ Disable being able to cancel the selection using the keyboard.
.TP
.BR \-o ", " \-\-noopengl
Disable graphics acceleration.
.SH GIFSKI OPTIONS
When
.BR -e " or " --encoder
.I gifski
is used, gifski will be used as the gif encoder. The following options will be passed to gifski if they are set:
.TP
.BR \-gq ", " \-\-gifski-quality
Set the quality from
.RI "Set the quality from " 1 " to " 100 ", where 1 is the lowest, and 100 the best quality."
.TP
.BR \-gf ", " \-\-gifski-fast
Makes the encoding 3 times faster. Results in 10% lower quality and a bigger filesize though.
.SH SEE ALSO
.B slop(1)
56 changes: 4 additions & 52 deletions src/giph
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ SLOP=0
DELAY=0
FRAMERATE=15
INTERFACE="cli"
ENCODER="ffmpeg"

function print_version() {
echo $VERSION
Expand All @@ -35,11 +34,10 @@ OPTIONS
-s, --select Enable slop selection.
-g, --geometry=STRING Record rectangle by geometry. (like 100x300+0+0)
-w, --window=INT Record window by id.
-d, --delay=INT Time in seconds before the recording starts.
-d, --delay=INT Time in seconds before the recording starts.
-t, --timer=TIMEDURATION Time of the recording. (e.g. 10 for 10 seconds or 1:30 for 1 minute 30 seconds)
-f, --framerate=INT Set the framerate.
-i, --interface=STRING Set the user interface that should be used. ("cli" or "zenity")
-e, --encoder=STRING Set the encoder that should be used. ("ffmpeg" or "gifski")
-i, --interface=STRING Set the user interface that should be used. ("cli" or "zenity")
SLOP OPTIONS
-b, --bordersize=FLOAT Set the selection border thickness.
Expand All @@ -51,10 +49,6 @@ SLOP OPTIONS
-l, --highlight Highlight the selection rectangle.
-k, --nokeyboard Disable cancel through keypress.
-o, --noopengl Disable graphics acceleration.
GIFSKI OPTIONS
-gq, --gifski-quality=INT Set the desired gifski quality from 1 to 100.
-gf, --gifski-fast 3 times faster encoding, 10% lower quality, larger filesize.
EOF

exit 0
Expand Down Expand Up @@ -138,10 +132,6 @@ while [[ "$1" == -* ]]; do
shift
INTERFACE="$1"
;;
-e|--encoder)
shift
ENCODER="$1"
;;
-b|--bordersize)
shift
SLOP_BORDERSIZE="$1"
Expand Down Expand Up @@ -175,13 +165,6 @@ while [[ "$1" == -* ]]; do
-o|--noopengl)
SLOP_NOOPENGL=true
;;
-gq|--gifski-quality)
shift
GIFSKI_QUALITY="$1"
;;
-gf|--gifski-fast)
GIFSKI_FAST=true
;;
-*)
log_error "option '$1' does not exist" false
;;
Expand Down Expand Up @@ -408,20 +391,8 @@ function stop_recording_handler_zenity() {
fi
}

function encode_gif() {
case "$ENCODER" in
"ffmpeg")
log "encoding gif using ffmpeg encoder" 1 true
encode_gif_ffmpeg
;;
"gifski")
log "encoding gif using gifski encoder" 1 true
encode_gif_gifski
;;
esac
}

function encode_gif_ffmpeg() {
log "encoding gif using ffmpeg encoder" 1 true
ffmpeg_generate_palette=(ffmpeg -i "$TEMP_DIRECTORY/recording.mkv" -vf palettegen "$TEMP_DIRECTORY/palette.png")
[ "$VERBOSITY" -lt "3" ] && ffmpeg_generate_palette+=(-loglevel "quiet")

Expand All @@ -437,25 +408,6 @@ function encode_gif_ffmpeg() {
[ $? = 1 ] && log_error "could not encode gif from video and color palette"
}

function encode_gif_gifski() {
ffmpeg=(ffmpeg -i "$TEMP_DIRECTORY/recording.mkv" "$TEMP_DIRECTORY/frame%04d.png")
[ "$VERBOSITY" -lt "3" ] && ffmpeg+=(-loglevel "quiet")

log "separating video frames into individual images" 2 true
"${ffmpeg[@]}"
[ $? = 1 ] && log_error "could not separate video frames into individual images"

gifski=(gifski --fps "$FRAMERATE" -o "$TEMP_DIRECTORY/encoded.gif")
[ "$VERBOSITY" -lt "3" ] && gifski+=(--quiet)
[ -n "$GIFSKI_QUALITY" ] && gifski+=(--quality "$GIFSKI_QUALITY")
[ -n "$GIFSKI_FAST" ] && gifski+=(--fast)
gifski+=("$TEMP_DIRECTORY"/frame*.png)

log "encoding gif using separated frames" 2 true
"${gifski[@]}"
[ $? = 1 ] && log_error "could not encode gif using separated frames"
}

function deliver_final_gif() {
if [ -n "$OUTPUT_FILE" ]; then
mv "$TEMP_DIRECTORY/encoded.gif" "$OUTPUT_FILE" && {
Expand All @@ -476,7 +428,7 @@ function giph() {
get_geometry
create_temporary_directory
start_video_recording
encode_gif
encode_gif_ffmpeg
deliver_final_gif
delete_temporary_directory
exit 0
Expand Down

0 comments on commit 8e52600

Please sign in to comment.