From: z Date: Sat, 1 Apr 2017 16:46:06 +0000 (-0400) Subject: added command to convert video to gif X-Git-Tag: xonotic-v0.8.5~202^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2caacb2447fb3e78486ede063d3162a63606bc20;p=xonotic%2Fxonotic.git added command to convert video to gif --- diff --git a/misc/tools/encode-demos.sh b/misc/tools/encode-demos.sh index 139b4a53..0a30a9eb 100755 --- a/misc/tools/encode-demos.sh +++ b/misc/tools/encode-demos.sh @@ -1,9 +1,9 @@ #!/bin/bash # name: encode-demos.sh -# version: 0.6.2 +# version: 0.6.3 # author: Tyler "-z-" Mulligan # license: GPL & MIT -# date: 26-02-2017 +# date: 01-04-2017 # description: headless encoding of demo files to HD video concurrently with Xfvb and parallel # # The encoding is done with a full Xonotic client inside Xfvb. @@ -42,7 +42,7 @@ # Customize USERDIR=${HOME}/.xonotic-clean # path to Xonotic userdir for client that does encoding -GAMEDIR=${USERDIR}/data # path to Xonotic userdir for client that does encoding +GAMEDIR=${USERDIR}/data # path to Xonotic gamedir for client that does encoding XONOTIC_BIN="./all" # binary used to launch Xonotic JOB_TIMEOUT="4h" # if demo doesn't quit itself or hangs JOBS=4 # number of concurrent jobs @@ -358,6 +358,24 @@ compress() { fi } +create_gif() { + local video=$1 + local fps=${2:-15} + local width=${3:-320} + local start=${4:-0} + local length=${5:-999999} + local loop=${6:-1} + local output=$(basename ${video%.*}.gif) + + # Generate palette for better quality + ${FFMPEG} -i ${GAMEDIR}/${video} -vf fps=${fps},scale=${width}:-1:flags=lanczos,palettegen ${GAMEDIR}/tmp_palette.png + + # Generate gif using palette + ${FFMPEG} -i ${GAMEDIR}/${video} -i ${GAMEDIR}/tmp_palette.png -ss ${start} -t ${length} -loop ${loop} -filter_complex "fps=${fps},scale=${width}:-1:flags=lanczos[x];[x][1:v]paletteuse" ${GAMEDIR}/${output} + + rm ${GAMEDIR}/tmp_palette.png +} + list_jobs() { completed_jobs=$(_get_completed_jobs) active_jobs=$(_get_active_demo_jobs) @@ -510,19 +528,23 @@ COMMANDS Encoding -------- - batch [demos.txt] [timeout] [--compress] batch process a list of demos from file relative to \$USERDIR/data - single [timeout] [--compress] process a single demo file in \$USERDIR/data. ex: demos/cool.dem - 'timeout' does not include '--compress', compress starts a new job + batch [demos.txt] [timeout] [--compress] batch process a list of demos from file relative to \$USERDIR/data + single [timeout] [--compress] process a single demo file in \$USERDIR/data. ex: demos/cool.dem + 'timeout' does not include '--compress', compress starts a new job Compression ----------- - compress