From 3484fb6c8f726136e409317b001a59b5c86f1ddc Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sat, 11 May 2024 15:48:00 -0400 Subject: [PATCH] Encode will add a bug and otherwise scale with filter_complex, not vf. Working on several videos. --- encode.sh | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/encode.sh b/encode.sh index 95be108..9deabe1 100644 --- a/encode.sh +++ b/encode.sh @@ -11,21 +11,34 @@ if [ ${count} == 0 ]; then exit 1 fi -SCALE="scale=${WIDTH}:${HEIGHT}:force_original_aspect_ratio=decrease,pad=${WIDTH}:${HEIGHT}:(ow-iw)/2:(oh-ih)/2" +SCALE="-filter_complex scale=${WIDTH}:${HEIGHT}:force_original_aspect_ratio=decrease,pad=${WIDTH}:${HEIGHT}:(ow-iw)/2:(oh-ih)/2" +HWENCODE="-hwaccel auto" +SILENT="-loglevel quiet -stats" + +if [[ "${BUG}" != "" ]]; then + SCALE="-i ${BUG} -filter_complex [0]scale=${WIDTH}:${HEIGHT}:force_original_aspect_ratio=decrease,pad=${WIDTH}:${HEIGHT}:(ow-iw)/2:(oh-ih)/2,overlay=x=0:y=0[out] -map [out]" +fi Encode () { name=$(basename "${1}") nameNoExt=${name%.*} now=$(date '+%s') - output="${VIDEOS}/${nameNoExt}_${now}.flv" - if [ -f "${VIDEOS}/${nameNoExt}"*".flv" ]; then + output="${VIDEOS}/${nameNoExt}_${now}.mkv" + #echo $output + if [ -f "${VIDEOS}/${nameNoExt}"*".mkv" ]; then echo "File ${name} already exists" return fi echo "Encoding ${name}..." - ffmpeg -i "${1}" -c:v libx264 -tune zerolatency -pix_fmt yuv420p -vf "${SCALE}" \ - -c:a aac -b:a 190k -ac 2 -ar 44100 \ - -f flv "${output}" + if [[ "${name}" == *".jpg" ]] || [[ "${name}" == *".jpeg" ]] || [[ "${name}" == *".png" ]]; then + ffmpeg -nostdin -loop 1 -t 30 -i "${1}" ${SCALE} -c:v libx264 -tune zerolatency -pix_fmt yuv420p -r 30 -t 30 \ + -an ${SILENT} \ + "${output}" + else + ffmpeg -nostdin ${HWENCODE} -i "${1}" ${SCALE} -c:v libx264 -tune zerolatency -pix_fmt yuv420p \ + -c:a aac -b:a 190k -ac 2 -ar 44100 \ + -f flv ${SILENT} "${output}" + fi } fileList=$(mktemp)