From aeb6bb1a133bfdf66e614fd3b5f9d34d80bcd1c9 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 15 Apr 2015 06:21:44 +0000 Subject: [PATCH] transcoding option for additional resolutions svn path=/trunk/; revision=34 --- actions/transcode.sh | 16 ++++++++++++++++ index.cgi | 2 +- pages/videoview.sh | 14 ++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 actions/transcode.sh diff --git a/actions/transcode.sh b/actions/transcode.sh new file mode 100644 index 0000000..835a166 --- /dev/null +++ b/actions/transcode.sh @@ -0,0 +1,16 @@ +#!/bin/zsh + +info="$_GET[\"i\"]" +target="$_GET[\"t\"]" +video="${_DATA}/videos/$info" +meta="${_DATA}/meta/$info.meta" +trans="${_DATA}/transcoded/${info}.${target}p.webm" + +head -n1 "$meta" |read length width height name + +twidth=$(($width * $target / $height)) + +[ -f "$target" ] || nohup avconv -i "$video" -s "${twidth}x${target}" "$trans" & + +echo "Location: transcoded/${info}.${target}p.webm" +echo diff --git a/index.cgi b/index.cgi index ec75729..40b67f1 100755 --- a/index.cgi +++ b/index.cgi @@ -42,7 +42,7 @@ _DATA="$(dirname "$call")" #storage directory [ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable" # create directories for object storage -for each in "$_DATA"/{cache,meta,mp4,videos,thumbs,trash,by_length}; do +for each in "$_DATA"/{cache,meta,mp4,videos,thumbs,trash,by_length,transcoded}; do [ ! -e "$each" ] && mkdir "$each" [ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory" done diff --git a/pages/videoview.sh b/pages/videoview.sh index 33f47dd..eacc547 100755 --- a/pages/videoview.sh +++ b/pages/videoview.sh @@ -74,7 +74,7 @@ _printVideo(){ cache="${_DATA}/cache/$info.cache" video="${_DATA}/videos/$info" meta="${_DATA}/meta/$info.meta" - if [ "$cache" -nt "$video" -a "$cache" -nt "$meta" ]; then + if [ "$cache" -nt "$meta" ]; then cat "$cache" else tags="$(sed -n 2p "$meta")" @@ -85,14 +85,14 @@ _printVideo(){ [ -z "$height" ] && height=0 # reenc="${_DATA}/vp8/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1:' <<<"$info" )" - mpfake="${_DATA}/mp4/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1.mp4:' <<<"$info" )" +# mpfake="${_DATA}/mp4/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1.mp4:' <<<"$info" )" # [ -f "$reenc.mp4" ] && reenc="$reenc.mp4" || reenc="$reenc.mkv" [ -r "$meta" ] || ". ${_EXEC}/helpers/genmeta.sh" "$video" "$meta" [ -r "$thumb" ] || ". ${_EXEC}/helpers/genthumb.sh" "$video" "$thumb" - [ -L "$mpfake" ] || ln -s "../videos/$info" "$mpfake" +# [ -L "$mpfake" ] || ln -s "../videos/$info" "$mpfake" video="$(urlsave "videos/$info")" thumb="$(urlsave "thumbs/$info.jpg")" - mpfake="$(urlsave "$info" |sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:mp4/\1.mp4:')" +# mpfake="$(urlsave "$info" |sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:mp4/\1.mp4:')" [ "$(($length % 60))" -lt 10 ] &&\ minutes="$(($length / 60)):0$(($length % 60))" ||\ @@ -101,12 +101,14 @@ _printVideo(){ linkinfo="$(urlsave "$info")" tee "$cache" < - + $info - fake-mp4 +