Skip to content

Commit 1999455

Browse files
committed
Add --crop detect option/argument for 5.9 to call crop-detect.sh
directly with `--values-only` option.
1 parent cbb73a7 commit 1999455

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

transcode-video.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
about() {
99
cat <<EOF
10-
$program 5.8 of January 21, 2015
10+
$program 5.9 of January 22, 2015
1111
Copyright (c) 2013-2015 Don Melton
1212
EOF
1313
exit 0
@@ -42,7 +42,7 @@ usage() {
4242
--slow, --slower, --veryslow
4343
use x264 encoder preset to trade speed for compression
4444
--crop T:B:L:R set video crop values (default: 0:0:0:0)
45-
(use \`detect-crop.sh\` script for optimal bounds)
45+
(use \`--crop detect\` to invoke \`detect-crop.sh\`)
4646
(use \`--crop auto\` for \`HandBrakeCLI\` behavior)
4747
--720p constrain video to fit within 1280x720 pixel bounds
4848
--audio TRACK select main audio track (default: 1)
@@ -51,6 +51,7 @@ usage() {
5151
--version output version information and exit
5252
5353
Requires \`HandBrakeCLI\` executable in \$PATH.
54+
Requires \`detect-crop.sh\` script in \$PATH when using \`--crop detect\`.
5455
Output and log file are written to current working directory.
5556
EOF
5657
exit 0
@@ -86,7 +87,7 @@ Quality options:
8687
8788
Video options:
8889
--crop T:B:L:R set video crop values (default: 0:0:0:0)
89-
(use \`detect-crop.sh\` script for optimal bounds)
90+
(use \`--crop detect\` to invoke \`detect-crop.sh\`)
9091
(use \`--crop auto\` for \`HandBrakeCLI\` behavior)
9192
--720p constrain video to fit within 1280x720 pixel bounds
9293
--1080p " " " " " 1920x1080 " "
@@ -173,6 +174,7 @@ Other options:
173174
--version output version information and exit
174175
175176
Requires \`HandBrakeCLI\` executable in \$PATH.
177+
Requires \`detect-crop.sh\` script in \$PATH when using \`--crop detect\`.
176178
May require \`mp4track\` and \`mkvpropedit\` executables in \$PATH for some options.
177179
Output and log file are written to current working directory.
178180
EOF
@@ -606,6 +608,19 @@ if [ -e "$output" ]; then
606608
die "output file already exists: $output"
607609
fi
608610

611+
if [ "$crop_values" == 'detect' ]; then
612+
613+
if ! $(which detect-crop.sh >/dev/null); then
614+
die 'script not in $PATH: detect-crop.sh'
615+
fi
616+
617+
crop_values="$(detect-crop.sh --title $media_title --values-only "$input")"
618+
619+
if [ ! "$crop_values" ]; then
620+
die "crop ambiguous or unavailable for: $input"
621+
fi
622+
fi
623+
609624
# VIDEO
610625
#
611626
readonly size_array=($(echo "$media_info" | sed -n 's/^ + size: \([0-9]\{1,\}\)x\([0-9]\{1,\}\).*$/\1 \2/p'))

0 commit comments

Comments
 (0)