From eb549a966cbdc2da841a3288bb1e291eef66b697 Mon Sep 17 00:00:00 2001 From: q3aql Date: Wed, 10 Mar 2021 00:38:53 +0100 Subject: [PATCH] Default preset slow & H265 detection (ks-avi) --- src/ks-avi | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ks-avi b/src/ks-avi index 383f782..4ca9adc 100755 --- a/src/ks-avi +++ b/src/ks-avi @@ -18,6 +18,9 @@ ksToolsTempFolder="/tmp/ks-tools" rel_size="720x480" vcodec="libxvid" b_vcodec="3000k" +# Presets: ultrafast, superfast, veryfast, faster, +# fast, medium (default), slow, slower, veryslow +v_preset="slow" acodec="libmp3lame" b_acodec="192k" default_lang_audio="spa" @@ -131,7 +134,16 @@ fi p_ffmpeg="ffmpeg -i" p_ffmpeg_patched="-max_muxing_queue_size 9999" f_conversion="-vsync 1 -async 1" -p_conversion="-s ${rel_size} -c:v ${vcodec} -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}" +# Check if video input uses H265 (HEVC) +codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265") +codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc") +yuv420p10le=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le") +codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}" +if [ -z "${codec_h265_hevc}" ] ; then + p_conversion="-s ${rel_size} -c:v ${vcodec} -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}" +else + p_conversion="-s ${rel_size} -c:v ${vcodec} -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}" +fi # Init conversion file current_date=$(date +%Y) @@ -146,6 +158,7 @@ if [ -z "${2}" ] ; then echo " - Resolution: ${rel_size}" echo " - Video codec: ${vcodec}" echo " - Bitrate video: ${b_vcodec}" + echo " - Preset: ${v_preset}" echo " - Audio codec: ${acodec} (stereo)" echo " - Bitrate audio: ${b_acodec}" echo " - Default Audio: ${default_lang_audio}" @@ -267,7 +280,11 @@ else resolution="${rel_size}" else rel_size="${resolution}" - p_conversion="-s ${rel_size} -c:v ${vcodec} -b:v ${b_vcodec} -c:a ${acodec} -b:a ${b_acodec}" + if [ -z "${codec_h265_hevc}" ] ; then + p_conversion="-s ${rel_size} -c:v ${vcodec} -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}" + else + p_conversion="-s ${rel_size} -c:v ${vcodec} -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec} -b:a ${b_acodec}" + fi fi echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread if [ "${patch_thread}" == "y" ] ; then