Skip to content

Commit 3c284b9

Browse files
committed
Add VAXPECT_OPTS (default: --crop 0:0:0:0). Write to temp file for atomic replace.
1 parent 8d2d0b4 commit 3c284b9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

vaxpect

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,32 @@
33
# Recode a video to x264 480p. Saves a copy in a subdirectory "vaxpect".
44
# Does nothing if the video is already 480p or less.
55
# Call as
6-
# env VAXPECT_HEIGHT=720 VAXPECT_Q=23 VAXPECT_AUDIO_BITRATE=160 vaxpect *.mp4
6+
# env VAXPECT_HEIGHT=720 VAXPECT_Q=29 VAXPECT_AUDIO_BITRATE=96 vaxpect *.mp4
77
# to encode to a different height or quality.
88
# x264 quality 26 is acceptable. Increase the value to compact more at
99
# the expense of quality; lower to 23 or 20 to increase quality but
1010
# with a significant file size increase.
1111

1212
target_hgt=${VAXPECT_HEIGHT:-"480"}
1313
target_q=${VAXPECT_Q:-"26"}
14-
target_br=${VAXPECT_AUDIO_BITRATE:-"96"}
14+
target_br=${VAXPECT_AUDIO_BITRATE:-"160"}
1515
target_codec=${VAXPECT_VIDEO_CODEC:-"x264"}
16+
target_opts=${VAXPECT_OPTS:-"--crop 0:0:0:0"}
1617

1718
for file in "$@"
1819
do
1920
height=`mediainfo --Inform="Video;%Height%" "$file"`
20-
if [ $height -gt $target_hgt ]; then
21+
if [ "$height" -gt "$target_hgt" ]; then
2122
[ -d vaxpect ] || mkdir vaxpect
2223
#out=`echo "$file" | sed -e 's/\.[A-Za-z0-9]*$/.$target_hgtp.mkv/'`
2324
out=vaxpect/`echo "$file" | sed -e 's/\.[A-Za-z0-9]*$/.mkv/'`
25+
outtmp=vaxpect/`echo "$file" | sed -e 's/\.[A-Za-z0-9]*$/.tmp.mkv/'`
2426
if [ -e "$out" ] ; then
2527
echo "Not overwriting $out"
2628
else
27-
HandBrakeCLI -i "$file" -o "$out" -e $target_codec -q $target_q -B $target_br --height $target_hgt
29+
HandBrakeCLI -i "$file" -o "$outtmp" -e $target_codec -q $target_q -B $target_br --height $target_hgt $target_opts &&
30+
mv "$outtmp" "$out" &&
31+
touch -r "$file" "$out"
2832
fi
2933
fi
3034
done

0 commit comments

Comments
 (0)