Add calculate for ih crop height resolution (ks-crop)
This commit is contained in:
parent
a5475fa128
commit
2962e4aa1d
258
src/ks-crop
258
src/ks-crop
|
@ -172,256 +172,11 @@ detect_3=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -
|
||||||
detect_4=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 4 | cut -d "[" -f 1 | tr -s " " | grep x)
|
detect_4=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 4 | cut -d "[" -f 1 | tr -s " " | grep x)
|
||||||
detect_5=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 5 | cut -d "[" -f 1 | tr -s " " | grep x)
|
detect_5=$(ffmpeg -i ${2} 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 5 | cut -d "[" -f 1 | tr -s " " | grep x)
|
||||||
resolution_detected="${detect_2}${detect_3}${detect_4}${detect_5}"
|
resolution_detected="${detect_2}${detect_3}${detect_4}${detect_5}"
|
||||||
resolution_first=$(echo ${resolution_detected} | cut -d "x" -f 1)
|
resolution_height=$(echo ${resolution_detected} | cut -d "x" -f 2)
|
||||||
resolution_second=$(echo ${resolution_detected} | cut -d "x" -f 2)
|
|
||||||
|
|
||||||
# Set size crop to 16:9 (ih)
|
# Set size crop to 16:9 (ih)
|
||||||
ih_size="240"
|
calculate_crop=$(expr ${resolution_height} / 4)
|
||||||
# Detect by width size
|
ih_size="${calculate_crop}"
|
||||||
if [ ${resolution_first} == "6400" ] ; then
|
|
||||||
ih_size="1100"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "3840" ] ; then
|
|
||||||
ih_size="540"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "3200" ] ; then
|
|
||||||
ih_size="540"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "2560" ] ; then
|
|
||||||
ih_size="380"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "2048" ] ; then
|
|
||||||
ih_size="380"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "1920" ] ; then
|
|
||||||
ih_size="270"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "1680" ] ; then
|
|
||||||
ih_size="250"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "1600" ] ; then
|
|
||||||
ih_size="310"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "1366" ] ; then
|
|
||||||
ih_size="185"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "1280" ] ; then
|
|
||||||
ih_size="240"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "1024" ] ; then
|
|
||||||
ih_size="180"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "800" ] ; then
|
|
||||||
ih_size="150"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "720" ] ; then
|
|
||||||
ih_size="140"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "640" ] ; then
|
|
||||||
ih_size="120"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_first} == "426" ] ; then
|
|
||||||
ih_size="60"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Detect by height size
|
|
||||||
if [ ${resolution_second} == "4800" ] ; then
|
|
||||||
ih_size="1190"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "2400" ] ; then
|
|
||||||
ih_size="595"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "2160" ] ; then
|
|
||||||
ih_size="540"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "2048" ] ; then
|
|
||||||
ih_size="510"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1600" ] ; then
|
|
||||||
ih_size="400"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1540" ] ; then
|
|
||||||
ih_size="380"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1536" ] ; then
|
|
||||||
ih_size="383"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1440" ] ; then
|
|
||||||
ih_size="360"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1280" ] ; then
|
|
||||||
ih_size="320"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1200" ] ; then
|
|
||||||
ih_size="300"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1080" ] ; then
|
|
||||||
ih_size="270"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1050" ] ; then
|
|
||||||
ih_size="250"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1040" ] ; then
|
|
||||||
ih_size="260"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "1024" ] ; then
|
|
||||||
ih_size="255"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "960" ] ; then
|
|
||||||
ih_size="240"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "900" ] ; then
|
|
||||||
ih_size="222"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "864" ] ; then
|
|
||||||
ih_size="215"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "800" ] ; then
|
|
||||||
ih_size="200"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "768" ] ; then
|
|
||||||
ih_size="190"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "760" ] ; then
|
|
||||||
ih_size="187"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "720" ] ; then
|
|
||||||
ih_size="180"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "600" ] ; then
|
|
||||||
ih_size="150"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "576" ] ; then
|
|
||||||
ih_size="142"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "534" ] ; then
|
|
||||||
ih_size="132"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "536" ] ; then
|
|
||||||
ih_size="133"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "480" ] ; then
|
|
||||||
ih_size="120"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "384" ] ; then
|
|
||||||
ih_size="95"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "360" ] ; then
|
|
||||||
ih_size="90"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_second} == "240" ] ; then
|
|
||||||
ih_size="60"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Detect by specific resolution
|
|
||||||
if [ ${resolution_detected} == "6400x4800" ] ; then
|
|
||||||
ih_size="1190"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "3840x2160" ] ; then
|
|
||||||
ih_size="540"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "3200x2400" ] ; then
|
|
||||||
ih_size="595"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "2560x2048" ] ; then
|
|
||||||
ih_size="510"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "2560x1440" ] ; then
|
|
||||||
ih_size="360"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "2560x1600" ] ; then
|
|
||||||
ih_size="400"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "2048x1536" ] ; then
|
|
||||||
ih_size="383"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1920x1540" ] ; then
|
|
||||||
ih_size="380"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1920x1080" ] ; then
|
|
||||||
ih_size="270"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1920x1040" ] ; then
|
|
||||||
ih_size="260"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1920x1440" ] ; then
|
|
||||||
ih_size="360"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1920x960" ] ; then
|
|
||||||
ih_size="240"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1680x1050" ] ; then
|
|
||||||
ih_size="250"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1600x1280" ] ; then
|
|
||||||
ih_size="320"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1600x1200" ] ; then
|
|
||||||
ih_size="300"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1600x900" ] ; then
|
|
||||||
ih_size="222"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1440x900" ] ; then
|
|
||||||
ih_size="222"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1366x768" ] ; then
|
|
||||||
ih_size="190"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1366x760" ] ; then
|
|
||||||
ih_size="187"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1280x960" ] ; then
|
|
||||||
ih_size="240"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1280x800" ] ; then
|
|
||||||
ih_size="200"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1280x720" ] ; then
|
|
||||||
ih_size="180"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1280x1024" ] ; then
|
|
||||||
ih_size="255"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1280x534" ] ; then
|
|
||||||
ih_size="132"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1280x536" ] ; then
|
|
||||||
ih_size="133"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1152x864" ] ; then
|
|
||||||
ih_size="215"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1024x768" ] ; then
|
|
||||||
ih_size="190"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "1024x760" ] ; then
|
|
||||||
ih_size="187"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "854x480" ] ; then
|
|
||||||
ih_size="120"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "800x600" ] ; then
|
|
||||||
ih_size="150"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "720x480" ] ; then
|
|
||||||
ih_size="120"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "720x576" ] ; then
|
|
||||||
ih_size="142"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "640x480" ] ; then
|
|
||||||
ih_size="120"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "640x360" ] ; then
|
|
||||||
ih_size="90"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "512x384" ] ; then
|
|
||||||
ih_size="95"
|
|
||||||
fi
|
|
||||||
if [ ${resolution_detected} == "426x240" ] ; then
|
|
||||||
ih_size="60"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Function to crop videos
|
# Function to crop videos
|
||||||
function crop_video() {
|
function crop_video() {
|
||||||
|
@ -511,6 +266,7 @@ function crop_video() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "* COMMAND THAT WILL BE EXECUTED:"
|
echo "* COMMAND THAT WILL BE EXECUTED:"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " # File detected with resolution" ${resolution_detected} "(ih ${ih_size})"
|
||||||
echo " # Crop '${inputFile}' from 4:3/IMAX to 16:9 (1.77:1)"
|
echo " # Crop '${inputFile}' from 4:3/IMAX to 16:9 (1.77:1)"
|
||||||
if [ "${patch_thread}" == "y" ] ; then
|
if [ "${patch_thread}" == "y" ] ; then
|
||||||
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=iw:ih-${ih_size}\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
|
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=iw:ih-${ih_size}\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
|
||||||
|
@ -535,6 +291,7 @@ function crop_video() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "* COMMAND THAT WILL BE EXECUTED:"
|
echo "* COMMAND THAT WILL BE EXECUTED:"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " # File detected with resolution" ${resolution_detected}
|
||||||
echo " # Crop '${inputFile}' from 16:9 to 4:3 (1.33:1)"
|
echo " # Crop '${inputFile}' from 16:9 to 4:3 (1.33:1)"
|
||||||
if [ "${patch_thread}" == "y" ] ; then
|
if [ "${patch_thread}" == "y" ] ; then
|
||||||
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/3*4:ih\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
|
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/3*4:ih\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
|
||||||
|
@ -559,6 +316,7 @@ function crop_video() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "* COMMAND THAT WILL BE EXECUTED:"
|
echo "* COMMAND THAT WILL BE EXECUTED:"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " # File detected with resolution" ${resolution_detected}
|
||||||
echo " # Crop '${inputFile}' from 16:9 to 5:4 (1.25:1)"
|
echo " # Crop '${inputFile}' from 16:9 to 5:4 (1.25:1)"
|
||||||
if [ "${patch_thread}" == "y" ] ; then
|
if [ "${patch_thread}" == "y" ] ; then
|
||||||
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/4*5:ih\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
|
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/4*5:ih\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
|
||||||
|
@ -583,6 +341,7 @@ function crop_video() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "* COMMAND THAT WILL BE EXECUTED:"
|
echo "* COMMAND THAT WILL BE EXECUTED:"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " # File detected with resolution" ${resolution_detected}
|
||||||
echo " # Crop '${inputFile}' from 16:9 to IMAX (1.43:1)"
|
echo " # Crop '${inputFile}' from 16:9 to IMAX (1.43:1)"
|
||||||
if [ "${patch_thread}" == "y" ] ; then
|
if [ "${patch_thread}" == "y" ] ; then
|
||||||
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/2.79*4:ih\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
|
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/2.79*4:ih\" -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-crop.${v_ext}\""
|
||||||
|
@ -607,6 +366,7 @@ function crop_video() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "* COMMAND THAT WILL BE EXECUTED:"
|
echo "* COMMAND THAT WILL BE EXECUTED:"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " # File detected with resolution" ${resolution_detected}
|
||||||
echo " # Change '${inputFile}' aspect to 16:9 (stretched)"
|
echo " # Change '${inputFile}' aspect to 16:9 (stretched)"
|
||||||
if [ "${patch_thread}" == "y" ] ; then
|
if [ "${patch_thread}" == "y" ] ; then
|
||||||
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-aspect.${v_ext}\""
|
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-aspect.${v_ext}\""
|
||||||
|
@ -631,6 +391,7 @@ function crop_video() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "* COMMAND THAT WILL BE EXECUTED:"
|
echo "* COMMAND THAT WILL BE EXECUTED:"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " # File detected with resolution" ${resolution_detected}
|
||||||
echo " # Change '${inputFile}' aspect to 4:3 (stretched)"
|
echo " # Change '${inputFile}' aspect to 4:3 (stretched)"
|
||||||
if [ "${patch_thread}" == "y" ] ; then
|
if [ "${patch_thread}" == "y" ] ; then
|
||||||
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-aspect.${v_ext}\""
|
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-aspect.${v_ext}\""
|
||||||
|
@ -655,6 +416,7 @@ function crop_video() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "* COMMAND THAT WILL BE EXECUTED:"
|
echo "* COMMAND THAT WILL BE EXECUTED:"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " # File detected with resolution" ${resolution_detected}
|
||||||
echo " # Change '${inputFile}' aspect to 5:4 (stretched)"
|
echo " # Change '${inputFile}' aspect to 5:4 (stretched)"
|
||||||
if [ "${patch_thread}" == "y" ] ; then
|
if [ "${patch_thread}" == "y" ] ; then
|
||||||
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-aspect.${v_ext}\""
|
echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-aspect.${v_ext}\""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user