]> git.plutz.net Git - serve0/commitdiff
transcoding option for additional resolutions
authorpaul <paul@plutz.net>
Wed, 15 Apr 2015 06:21:44 +0000 (06:21 +0000)
committerpaul <paul@plutz.net>
Wed, 15 Apr 2015 06:21:44 +0000 (06:21 +0000)
svn path=/trunk/; revision=34

actions/transcode.sh [new file with mode: 0644]
index.cgi
pages/videoview.sh

diff --git a/actions/transcode.sh b/actions/transcode.sh
new file mode 100644 (file)
index 0000000..835a166
--- /dev/null
@@ -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
index ec7572914a9d8f3bfbb6b1cf8d1925b1099936c9..40b67f1d1d4f65e92812dd400cf3dc4758d430d7 100755 (executable)
--- 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
index 33f47dd7c2a0db0e69741d4513200d340a2acf51..eacc54718e89b41fb8a73acb42190062b6d177c1 100755 (executable)
@@ -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" <<VIDEOend
       <li class="thumb">
-        <a class="watchlink" name="$linkinfo" href="?action=watch&i=$linkinfo">
+        <a class="watchlink" name="${linkinfo}" href="?action=watch&i=${linkinfo}">
           <img src="$thumb">
         </a>
         <a class="videolink" href="$video">$info</a>
         <!-- a href="$reenc">VP8</a -->
-        <a class="videolink fake-mp4" href="$mpfake">fake-mp4</a>
+        <!-- a class="videolink fake-mp4" href="$mpfake">fake-mp4</a --
+        <a class="videolink" href="?action=transcode&i=${linkinfo}&t=480">480p</a>
+        <a class="videolink" href="?action=transcode&i=${linkinfo}&t=240">240p</a>
         <input type="checkbox" name="tagsel" value="$info">
         <span class="info property">${minutes}min</span>
         <span class="info property">${width}x${height}</span>