]> git.plutz.net Git - serve0/blob - actions/transcode.sh
styling for pagination links
[serve0] / actions / transcode.sh
1 #!/bin/zsh
2 # Copyright 2015 - 2016 Paul Hänsch
3 #
4 # This file is part of Serve0
5 #
6 # Serve0 is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Serve0 is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU Affero General Public License for more details.
15 #
16 # You should have received a copy of the GNU Affero General Public License
17 # along with Serve0  If not, see <http://www.gnu.org/licenses/>.
18
19 info="${_GET[i]}"
20 target="${_GET[t]}"
21 video="${_DATA}/videos/$info"
22 meta="${_DATA}/meta/$info.meta"
23 trans="${_DATA}/transcoded/${info}.${target}p.webm"
24
25 head -n1 "$meta" |read length width height name
26
27 twidth=$(($width * $target / $height))
28
29 if ! [ -f "$trans" ]; then
30  [ "$target" -le 240 ] && nohup avconv -i "$video" -s "${twidth}x${target}" -b:a 80k -threads auto "$trans" &
31  [ "$target" -gt 240 ] && nohup avconv -i "$video" -s "${twidth}x${target}" -threads auto "$trans" &
32 fi
33
34 redirect "/transcoded/${info}.${target}p.webm"