1
0

Misc. fixes

Signed-off-by: James Ketrenos <jketreno@media.ketrenos.com>
This commit is contained in:
James Ketrenos 2022-10-11 11:32:57 -07:00
parent a70b1fc11b
commit 7745b3437a

View File

@ -17,6 +17,7 @@ usage: normalize-video [OPTIONS] [FILES]
Options: Options:
-h This help -h This help
-s Force software only encode and decode
-o OLDER Only process files older than OLDER. See 'find -newer' -o OLDER Only process files older than OLDER. See 'find -newer'
-f Force transcode even if already meets normalized -f Force transcode even if already meets normalized
settings. settings.
@ -26,8 +27,12 @@ EOF
force=0 force=0
older_than= older_than=
while getopts fho: opt; do sw_only=
while getopts fho:s opt; do
case "${opt}" in case "${opt}" in
s)
sw_only=1
;;
o) o)
older_than="-and -not -newer ${OPTARG}" older_than="-and -not -newer ${OPTARG}"
;; ;;
@ -49,7 +54,7 @@ shift $(( OPTIND-1 ))
VIDEO=$(getent group video | sed -E 's,^video:[^:]*:([^:]*):.*$,\1,') VIDEO=$(getent group video | sed -E 's,^video:[^:]*:([^:]*):.*$,\1,')
RENDER=$(getent group render | sed -E 's,^render:[^:]*:([^:]*):.*$,\1,') RENDER=$(getent group render | sed -E 's,^render:[^:]*:([^:]*):.*$,\1,')
sw_only=0 if [[ "${sw_only}" == "" ]]; then
if [[ "${VIDEO}" != "" ]]; then if [[ "${VIDEO}" != "" ]]; then
sw_only=0 sw_only=0
ADD_GROUPS="--group-add ${VIDEO}" ADD_GROUPS="--group-add ${VIDEO}"
@ -59,6 +64,7 @@ if [[ "${VIDEO}" != "" ]]; then
else else
sw_only=1 sw_only=1
fi fi
fi
quiet=" quiet="
-v quiet -v quiet
@ -129,9 +135,10 @@ ffmpeg_hw_or_sw() {
-c:a copy -c:a copy
-c:s copy -c:s copy
-c:v libx264 -c:v libx264
-vf scale=${width}:${height},format=yuv420p \ -max_muxing_queue_size 1024
-preset veryslow \ -vf scale=${width}:${height},format=yuv420p
-crf 20 \ -preset veryslow
-crf 20
" "
# -metadata "title='${TITLE}'" \ # -metadata "title='${TITLE}'" \
@ -249,21 +256,21 @@ function check_and_convert {
width=$(ffprobe \ width=$(ffprobe \
-v error \ -v error \
-select_streams v \ -select_streams v:0 \
-show_entries "stream=width" \ -show_entries "stream=width" \
"${IN}" | sed -ne 's,width=,,p' "${IN}" | sed -ne 's,width=,,p'
) )
height=$(ffprobe \ height=$(ffprobe \
-v error \ -v error \
-select_streams v \ -select_streams v:0 \
-show_entries "stream=height" \ -show_entries "stream=height" \
"${IN}" | sed -ne 's,height=,,p' "${IN}" | sed -ne 's,height=,,p'
) )
pix_fmt=$(ffprobe \ pix_fmt=$(ffprobe \
-v error \ -v error \
-select_streams v \ -select_streams v:0 \
-show_entries "stream=pix_fmt" \ -show_entries "stream=pix_fmt" \
"${IN}" | sed -ne 's,pix_fmt=,,p' "${IN}" | sed -ne 's,pix_fmt=,,p'
) )
@ -458,9 +465,10 @@ if [ -z "$1" ]; then
find . -name '* *' -type f | while read file; do mv "${file}" "${file// /_}" || fail "Unable to rename file ${file}"; done find . -name '* *' -type f | while read file; do mv "${file}" "${file// /_}" || fail "Unable to rename file ${file}"; done
matches=" matches="
\( \(
-name '*mkv' -iname '*.mkv'
-or -name '*mp4' -or -iname '*.mp4'
-or -name '*avi' -or -iname '*.avi'
-or -iname '*.mov'
\) \)
-and -not -path './backup/*' -and -not -path './backup/*'
${older_than} ${older_than}
@ -479,8 +487,9 @@ fi && {
cat << EOF cat << EOF
To transfer the updated files: To transfer the updated files:
cd /multimedia/Downloads
rsync -avprlP --remove-source-files /multimedia/Downloads/ azurite:/multimedia/ rsync -avprlP --remove-source-files /multimedia/Downloads/ azurite:/multimedia/
find /multimedia/Downloads/ -type d -empty -delete find . -type d -empty -delete
EOF EOF
} }