General Enhancements #2
@ -32,7 +32,14 @@ function usage {
|
|||||||
-i input : The input file or folder with which to search for video files.
|
-i input : The input file or folder with which to search for video files.
|
||||||
If nothing is provided, current directory (.) is assumed.
|
If nothing is provided, current directory (.) is assumed.
|
||||||
-v bitrate : The video bitrate to convert to.
|
-v bitrate : The video bitrate to convert to.
|
||||||
Defaults to '2000k'.
|
Defaults are based on the size passed.
|
||||||
|
>= 2160: '30M'
|
||||||
|
>= 1440: '12M'
|
||||||
|
>= 1080: '5M'
|
||||||
|
>= 720: '2000k'
|
||||||
|
>= 480: '750k'
|
||||||
|
>= 360: '250k'
|
||||||
|
< 360: '100k'
|
||||||
-a bitrate : The audio bitrate to convert to.
|
-a bitrate : The audio bitrate to convert to.
|
||||||
Defaults to '192k'.
|
Defaults to '192k'.
|
||||||
-c vcodec : The video codec you'd like to use, such as libopenh264.
|
-c vcodec : The video codec you'd like to use, such as libopenh264.
|
||||||
@ -96,13 +103,30 @@ if [[ -z "$input" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$video_bitrate" ]]; then
|
if [[ -z "$video_bitrate" ]]; then
|
||||||
|
# Based roughly on the 2.5 step iteration used for 720 and 1080.
|
||||||
|
if (( $size >= 2160 )); then
|
||||||
|
video_bitrate="30M"
|
||||||
|
elif (( $size >= 1440 )); then
|
||||||
|
video_bitrate="12M"
|
||||||
|
elif (( $size >= 1080 )); then
|
||||||
|
video_bitrate="5M"
|
||||||
|
elif (( $size >= 720 )); then
|
||||||
video_bitrate="2000k"
|
video_bitrate="2000k"
|
||||||
|
elif (( $size >= 480 )); then
|
||||||
|
video_bitrate="750k"
|
||||||
|
elif (( $size >= 360 )); then
|
||||||
|
video_bitrate="250k"
|
||||||
|
else
|
||||||
|
video_bitrate="100k"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
compress_tags="$video_bitrate"
|
||||||
video_bitrate="-b:v $video_bitrate -minrate 0 -maxrate $video_bitrate -bufsize $video_bitrate"
|
video_bitrate="-b:v $video_bitrate -minrate 0 -maxrate $video_bitrate -bufsize $video_bitrate"
|
||||||
|
|
||||||
if [[ -z "$audio_bitrate" ]]; then
|
if [[ -z "$audio_bitrate" ]]; then
|
||||||
audio_bitrate="192k"
|
audio_bitrate="192k"
|
||||||
fi
|
fi
|
||||||
|
compress_tags="$compress_tags-$audio_bitrate"
|
||||||
audio_bitrate="-b:a $audio_bitrate"
|
audio_bitrate="-b:a $audio_bitrate"
|
||||||
|
|
||||||
if [[ -z "$codec" ]]; then
|
if [[ -z "$codec" ]]; then
|
||||||
@ -124,7 +148,11 @@ fi
|
|||||||
if [[ -z $size ]]; then
|
if [[ -z $size ]]; then
|
||||||
size="720"
|
size="720"
|
||||||
fi
|
fi
|
||||||
size="-filter:v scale=-1:$size"
|
while (( ${#size} < 4 )); do
|
||||||
|
size="0$size"
|
||||||
|
done
|
||||||
|
compress_tags="$size-$compress_tags"
|
||||||
|
size="-filter:v scale=-2:$size"
|
||||||
|
|
||||||
## Main ##
|
## Main ##
|
||||||
|
|
||||||
@ -172,6 +200,9 @@ $search_command "$input" | sort | while read file; do
|
|||||||
# Build the new filename to signify it is different than the original.
|
# Build the new filename to signify it is different than the original.
|
||||||
newfile="${file//$extension/$filename_flag-$date_YYYYMMDD.$extension_lower}"
|
newfile="${file//$extension/$filename_flag-$date_YYYYMMDD.$extension_lower}"
|
||||||
|
|
||||||
|
# Add the size, video, and audio quality it was converted to.
|
||||||
|
newfile="${newfile//\.$extension_lower/_$compress_tags.$extension_lower}"
|
||||||
|
|
||||||
if [[ $newfile == $file ]]; then
|
if [[ $newfile == $file ]]; then
|
||||||
echo "ERROR: The new calculated filename matches the old, skipping." >&2
|
echo "ERROR: The new calculated filename matches the old, skipping." >&2
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user