--- /dev/null
+#!/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
[ -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
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")"
[ -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))" ||\
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>