Encode will add a bug and otherwise scale with filter_complex, not vf. Working on several videos.

This commit is contained in:
Matt McWilliams 2024-05-11 15:48:00 -04:00
parent 830e2b3dd4
commit 3484fb6c8f
1 changed files with 19 additions and 6 deletions

View File

@ -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)