Skip to content

Commit

Permalink
WebMaster: use more zsh-isms
Browse files Browse the repository at this point in the history
  • Loading branch information
pituz committed Nov 16, 2014
1 parent 13e333c commit eb4707f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tools/.zshrc.avenc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ hkbr() {
cat <<END
hkbr — video bitrate calculator
Usage: hkbr time [audio] [result size]
time - length of fragment<F3>
time - length of fragment
audio may be one of:
existing file: use file size
0-320: bitrate, kbit/s; default - 120k
Expand Down
24 changes: 6 additions & 18 deletions tools/WebMaster
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env zsh
programname=$(basename $0)
programname=$0:t
help() {
cat >&1 <<END
WebMaster — wishmaster for WebM encoding: magic button with additional controls
Expand Down Expand Up @@ -49,27 +49,15 @@ force=0
crf=16
cpuused=1
force_bitrate=.
[ $FFMPEG ] || FFMPEG=(ffmpeg -hide_banner -v warning -stats)
[[ -n $FFMPEG ]] || FFMPEG=(ffmpeg -hide_banner -v warning -stats)

# config file
for f in $0.rc ~/.${programname}rc; [[ -f $f ]] && source $f
unset f

[[ -z $1 ]] && help
set -e
source "$(dirname "$(readlink -f $0)")/.zshrc.avenc"

joinstr() {
local sep=$1
local s=$2
shift
while [[ ! -z $2 ]]
do
s="${s}${sep}${2}"
shift
done
echo $s
}
source "${0:A:h}/.zshrc.avenc"

while [[ ! -z $1 ]]
do
Expand Down Expand Up @@ -150,7 +138,7 @@ do
vfilters+=(subtitles=$subs)
fi
fi
[[ -z $of ]] && of="${$(basename $f)%.*}.webm"
[[ -z $of ]] && of="${f:t:r}.webm" # strip path and extension
[[ $of == $f ]] && of=${f/webm/converted.webm}
af=${of/webm/audio.webm}
vf=${of/webm/video.webm}
Expand All @@ -170,8 +158,8 @@ do
fi
fi
opts+=(-t $length)
((${#afilters})) && aopts+=(-vf "$(joinstr , $afilters)")
((${#vfilters})) && vopts+=(-vf "$(joinstr , $vfilters)")
((${#afilters})) && aopts+=(-af ${(j:,:)afilters})
((${#vfilters})) && vopts+=(-vf ${(j:,:)vfilters})
(($best)) && opts+=(-quality best)
if [[ $audio == "n" ]]
then
Expand Down

0 comments on commit eb4707f

Please sign in to comment.