Goodbye Google Browsers, Enhance Compress Video Script (#45)
* No longer favoriting Chromium-based browsers. Need to help reduce their marketshare before they make the Internet into proprietary DRM garbage. * Handle files with spaces. This is not the original author date.
This commit is contained in:
parent
4890d250f4
commit
046e767635
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
DIR=`dirname $0`
|
DIR=`dirname $0`
|
||||||
PROG=`basename $0`
|
PROG=`basename $0`
|
||||||
if [[ $DIR == '.' ]]; then
|
if [[ "$DIR" == '.' ]]; then
|
||||||
DIR=`pwd`
|
DIR=`pwd`
|
||||||
fi
|
fi
|
||||||
echo "Running $DIR/$PROG"
|
echo "Running $DIR/$PROG"
|
||||||
@ -64,7 +64,7 @@ while getopts ":i:v:a:c:rfmVxh" opt; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $set_x == "Y" ]]; then
|
if [[ "$set_x" == "Y" ]]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -73,23 +73,23 @@ if [[ -z "$input" ]]; then
|
|||||||
input="."
|
input="."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $video_bitrate ]]; then
|
if [[ -z "$video_bitrate" ]]; then
|
||||||
video_bitrate="2000k"
|
video_bitrate="2000k"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $audio_bitrate ]]; then
|
if [[ -z "$audio_bitrate" ]]; then
|
||||||
audio_bitrate="128k"
|
audio_bitrate="128k"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $codec ]]; then
|
if [[ -z "$codec" ]]; then
|
||||||
codec=""
|
codec=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $search_command ]]; then
|
if [[ -z "$search_command" ]]; then
|
||||||
search_command="ls"
|
search_command="ls"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $time_command ]]; then
|
if [[ -z "$time_command" ]]; then
|
||||||
time_command=""
|
time_command=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ date_YYYYMMDD="`date "+%Y%m%d"`"
|
|||||||
|
|
||||||
## Main ##
|
## Main ##
|
||||||
|
|
||||||
if [[ $verbose == "Y" ]]; then
|
if [[ "$verbose" == "Y" ]]; then
|
||||||
cat <<- EOF
|
cat <<- EOF
|
||||||
VERBOSE: Full list of variables.
|
VERBOSE: Full list of variables.
|
||||||
input='$input'
|
input='$input'
|
||||||
@ -122,29 +122,32 @@ SECONDS=0
|
|||||||
$search_command $input | sort | while read file; do
|
$search_command $input | sort | while read file; do
|
||||||
echo -e "\n$file"
|
echo -e "\n$file"
|
||||||
|
|
||||||
if [[ -n $time_command ]]; then
|
if [[ -n "$time_command" ]]; then
|
||||||
date
|
date
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Exception checks for the existing file.
|
# Exception checks for the existing file.
|
||||||
if [[ $file != *'.mp4' ]]; then
|
if [[ "$file" != *'.mp4' ]]; then
|
||||||
echo "SKIP: Not an MP4."
|
echo "SKIP: Not an MP4."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [[ $file == *"$filename_flag"* ]]; then
|
if [[ "$file" == *"$filename_flag"* ]]; then
|
||||||
echo "SKIP: Input is already compressed."
|
echo "SKIP: Input is already compressed."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build the new filename to signify it is different thn the original.
|
# Build the new filename to signify it is different than the original.
|
||||||
extension=${file##*.}
|
extension="${file##*.}"
|
||||||
newfile=${file//$extension/$filename_flag-$date_YYYYMMDD.$extension}
|
newfile="${file//$extension/$filename_flag-$date_YYYYMMDD.$extension}"
|
||||||
|
|
||||||
|
# Convert spaces to underscores.
|
||||||
|
newfile="${newfile// /_}"
|
||||||
|
|
||||||
# More exception checks based on the new file.
|
# More exception checks based on the new file.
|
||||||
if [[ -e $newfile ]]; then
|
if [[ -e "$newfile" ]]; then
|
||||||
if [[ $force == "Y" ]]; then
|
if [[ "$force" == "Y" ]]; then
|
||||||
echo "FORCE: Removing $newfile."
|
echo "FORCE: Removing $newfile."
|
||||||
rm -vf $newfile
|
rm -vf "$newfile"
|
||||||
else
|
else
|
||||||
echo "SKIP: Already has a compressed version ($newfile)."
|
echo "SKIP: Already has a compressed version ($newfile)."
|
||||||
continue
|
continue
|
||||||
@ -154,14 +157,14 @@ $search_command $input | sort | while read file; do
|
|||||||
# Convert the file.
|
# Convert the file.
|
||||||
echo "Converting to $newfile."
|
echo "Converting to $newfile."
|
||||||
$time_command bash -c "ffmpeg -nostdin -hide_banner -loglevel quiet \
|
$time_command bash -c "ffmpeg -nostdin -hide_banner -loglevel quiet \
|
||||||
-i $file -b:v $video_bitrate -b:a $audio_bitrate \
|
-i '$file' -b:v $video_bitrate -b:a $audio_bitrate \
|
||||||
$vcodec -movflags +faststart $newfile"
|
$vcodec -movflags +faststart $newfile"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "\nDone!"
|
echo "\nDone!"
|
||||||
|
|
||||||
# Display elapsed time
|
# Display elapsed time
|
||||||
if [[ -n $time_command ]]; then
|
if [[ -n "$time_command" ]]; then
|
||||||
typeset -i hours minutes seconds
|
typeset -i hours minutes seconds
|
||||||
hours=$(( SECONDS / 3600 ))
|
hours=$(( SECONDS / 3600 ))
|
||||||
minutes=$(( (SECONDS % 3600) / 60 ))
|
minutes=$(( (SECONDS % 3600) / 60 ))
|
||||||
|
@ -169,7 +169,7 @@
|
|||||||
key: "{{ item }}"
|
key: "{{ item }}"
|
||||||
value: "[ 'org.gnome.Terminal.desktop', 'gnome-system-monitor.desktop'
|
value: "[ 'org.gnome.Terminal.desktop', 'gnome-system-monitor.desktop'
|
||||||
, 'org.gnome.Nautilus.desktop'
|
, 'org.gnome.Nautilus.desktop'
|
||||||
, 'io.gitlab.librewolf-community.desktop', '{{ browser }}'
|
, 'io.gitlab.librewolf-community.desktop'
|
||||||
, 'org.gnome.Evolution.desktop', 'chat.delta.desktop.desktop'
|
, 'org.gnome.Evolution.desktop', 'chat.delta.desktop.desktop'
|
||||||
, 'com.vscodium.codium.desktop', 'org.shotcut.Shotcut.desktop'
|
, 'com.vscodium.codium.desktop', 'org.shotcut.Shotcut.desktop'
|
||||||
, 'io.lbry.lbry-app.desktop'
|
, 'io.lbry.lbry-app.desktop'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user