From 5247cac8a3056f04083fb25b9d41d8bbac4936a9 Mon Sep 17 00:00:00 2001 From: q3aql Date: Sun, 28 Mar 2021 01:56:41 +0100 Subject: [PATCH] Better indent in source code --- cygwin/cygwin-path | 162 ++-- src/ks-crop | 800 ++++++++--------- src/ks-mix | 2132 ++++++++++++++++++++++---------------------- src/ks-mp3 | 430 ++++----- src/ks-mp3-album | 420 ++++----- src/ks-mp4 | 604 ++++++------- src/ks-mp4k | 604 ++++++------- src/ks-mp4s | 604 ++++++------- src/ks-oga | 430 ++++----- src/ks-oga-album | 420 ++++----- src/ks-upa | 694 +++++++------- src/ks-upf | 730 +++++++-------- src/ks-upr | 630 ++++++------- src/ks-upv | 694 +++++++------- 14 files changed, 4677 insertions(+), 4677 deletions(-) diff --git a/cygwin/cygwin-path b/cygwin/cygwin-path index c831226..f960330 100755 --- a/cygwin/cygwin-path +++ b/cygwin/cygwin-path @@ -22,33 +22,33 @@ function convertCygwin() { echo "${wordToConvert}" > ${CygPathSedFile} # Apply changes sed -i 's/\\/\//g' "${CygPathSedFile}" &> /dev/null - sed -i 's/A:/\/cygdrive\/a/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/B:/\/cygdrive\/b/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/A:/\/cygdrive\/a/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/B:/\/cygdrive\/b/g' "${CygPathSedFile}" &> /dev/null sed -i 's/C:/\/cygdrive\/c/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/D:/\/cygdrive\/d/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/E:/\/cygdrive\/e/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/F:/\/cygdrive\/f/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/G:/\/cygdrive\/g/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/H:/\/cygdrive\/h/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/I:/\/cygdrive\/i/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/J:/\/cygdrive\/j/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/K:/\/cygdrive\/k/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/L:/\/cygdrive\/l/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/M:/\/cygdrive\/m/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/N:/\/cygdrive\/n/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/O:/\/cygdrive\/o/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/P:/\/cygdrive\/p/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/Q:/\/cygdrive\/q/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/R:/\/cygdrive\/r/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/S:/\/cygdrive\/s/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/T:/\/cygdrive\/t/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/U:/\/cygdrive\/u/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/V:/\/cygdrive\/v/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/W:/\/cygdrive\/w/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/X:/\/cygdrive\/x/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/Y:/\/cygdrive\/y/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/Z:/\/cygdrive\/z/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/ / /g' "${CygPathSedFile}" &> /dev/null + sed -i 's/D:/\/cygdrive\/d/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/E:/\/cygdrive\/e/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/F:/\/cygdrive\/f/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/G:/\/cygdrive\/g/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/H:/\/cygdrive\/h/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/I:/\/cygdrive\/i/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/J:/\/cygdrive\/j/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/K:/\/cygdrive\/k/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/L:/\/cygdrive\/l/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/M:/\/cygdrive\/m/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/N:/\/cygdrive\/n/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/O:/\/cygdrive\/o/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/P:/\/cygdrive\/p/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/Q:/\/cygdrive\/q/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/R:/\/cygdrive\/r/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/S:/\/cygdrive\/s/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/T:/\/cygdrive\/t/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/U:/\/cygdrive\/u/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/V:/\/cygdrive\/v/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/W:/\/cygdrive\/w/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/X:/\/cygdrive\/x/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/Y:/\/cygdrive\/y/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/Z:/\/cygdrive\/z/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/ / /g' "${CygPathSedFile}" &> /dev/null # Show file without extension wordToConvert=$(cat ${CygPathSedFile}) echo "\"${wordToConvert}\"" @@ -62,33 +62,33 @@ function convertWindows() { mkdir -p ${CygPathTempFolder} && chmod 777 -R ${CygPathTempFolder} 2> /dev/null echo "${wordToConvert}" > ${CygPathSedFile} # Apply changes - sed -i 's/\/cygdrive\/a/A:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/b/B:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/c/C:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/d/D:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/e/E:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/f/F:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/g/G:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/h/H:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/i/I:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/j/J:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/k/K:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/l/L:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/m/M:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/n/N:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/o/O:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/p/P:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/q/Q:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/r/R:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/s/S:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/t/T:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/u/U:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/v/V:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/w/W:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/y/Y:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\/cygdrive\/z/Z:/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\//\\/g' "${CygPathSedFile}" &> /dev/null - sed -i 's/\\ / /g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/a/A:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/b/B:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/c/C:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/d/D:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/e/E:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/f/F:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/g/G:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/h/H:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/i/I:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/j/J:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/k/K:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/l/L:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/m/M:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/n/N:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/o/O:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/p/P:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/q/Q:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/r/R:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/s/S:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/t/T:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/u/U:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/v/V:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/w/W:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/y/Y:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\/cygdrive\/z/Z:/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\//\\/g' "${CygPathSedFile}" &> /dev/null + sed -i 's/\\ / /g' "${CygPathSedFile}" &> /dev/null # Show file without extension wordToConvert=$(cat ${CygPathSedFile}) echo "\"${wordToConvert}\"" @@ -100,40 +100,40 @@ if [ -z "${1}" ] ; then echo "* cygwin-path v${VERSION} (${M_DATE})" echo "" echo "* Convert Windows paths in Cywin paths & vice versa" - echo "" + echo "" echo "+ Sintax: " echo "" echo " $ cygwin-path -c \"\" --> Convert Windows path to Cygwin path" - echo " $ cygwin-path -w \"\" --> Convert Cygwin path to Windows path" + echo " $ cygwin-path -w \"\" --> Convert Cygwin path to Windows path" echo "" echo "+ Examples: " - echo "" - echo " $ cygwin-path -c \"C:\\Users\\test\Desktop\\my-notes.txt\"" - echo " $ cygwin-path -w \"/cygdrive/c/Users/test/Desktop/my-notes.txt\"" + echo "" + echo " $ cygwin-path -c \"C:\\Users\\test\Desktop\\my-notes.txt\"" + echo " $ cygwin-path -w \"/cygdrive/c/Users/test/Desktop/my-notes.txt\"" echo "" exit else - if [ "${1}" == "-c" ] ; then - convertCygwin "${2}" - elif [ "${1}" == "-w" ] ; then - convertWindows "${2}" - else - # Show help if sintax is wrong - echo "" - echo "* cygwin-path v${VERSION} (${M_DATE})" - echo "" - echo "* Convert Windows paths in Cywin paths & vice versa" - echo "" - echo "+ Sintax: " - echo "" - echo " $ cygwin-path -c \"\" --> Convert Windows path to Cygwin path" - echo " $ cygwin-path -w \"\" --> Convert Cygwin path to Windows path" - echo "" - echo "+ Examples: " - echo "" - echo " $ cygwin-path -c \"C:\\Users\\test\Desktop\\my-notes.txt\"" - echo " $ cygwin-path -w \"/cygdrive/c/Users/test/Desktop/my-notes.txt\"" - echo "" - exit - fi + if [ "${1}" == "-c" ] ; then + convertCygwin "${2}" + elif [ "${1}" == "-w" ] ; then + convertWindows "${2}" + else + # Show help if sintax is wrong + echo "" + echo "* cygwin-path v${VERSION} (${M_DATE})" + echo "" + echo "* Convert Windows paths in Cywin paths & vice versa" + echo "" + echo "+ Sintax: " + echo "" + echo " $ cygwin-path -c \"\" --> Convert Windows path to Cygwin path" + echo " $ cygwin-path -w \"\" --> Convert Cygwin path to Windows path" + echo "" + echo "+ Examples: " + echo "" + echo " $ cygwin-path -c \"C:\\Users\\test\Desktop\\my-notes.txt\"" + echo " $ cygwin-path -w \"/cygdrive/c/Users/test/Desktop/my-notes.txt\"" + echo "" + exit + fi fi diff --git a/src/ks-crop b/src/ks-crop index 8f62b5e..8fb56a3 100755 --- a/src/ks-crop +++ b/src/ks-crop @@ -41,96 +41,96 @@ fi ffmpeg_test=$(ffmpeg --help 2>&1) error_ffmpeg=$? if [ ${error_ffmpeg} -ne 0 ] ; then - echo "" - echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})" - echo "" - echo "+ The 'ffmpeg' tool is not installed!" - echo "" - exit + echo "" + echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})" + echo "" + echo "+ The 'ffmpeg' tool is not installed!" + echo "" + exit fi # Function to remove extension from file # Syntax: removeExtension "" function removeExtension() { - wordToConvert=${1} - ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt" - mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null - echo "${wordToConvert}" > ${ksToolsSedFile} - # Remove extensions - sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null - sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null - sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null - sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null - sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null - sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null - sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null - sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null - sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null - sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null - sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null - # Show file without extension - wordToConvert=$(cat ${ksToolsSedFile}) - echo ${wordToConvert} + wordToConvert=${1} + ksToolsSedFile="${ksToolsTempFolder}/ks-tools-${RANDOM}.txt" + mkdir -p ${ksToolsTempFolder} && chmod 777 -R ${ksToolsTempFolder} 2> /dev/null + echo "${wordToConvert}" > ${ksToolsSedFile} + # Remove extensions + sed -i 's/.avi//g' "${ksToolsSedFile}" &> /dev/null + sed -i 's/.mp4//g' "${ksToolsSedFile}" &> /dev/null + sed -i 's/.mkv//g' "${ksToolsSedFile}" &> /dev/null + sed -i "s/.mov//g" "${ksToolsSedFile}" &> /dev/null + sed -i 's/.vob//g' "${ksToolsSedFile}" &> /dev/null + sed -i 's/.mpg//g' "${ksToolsSedFile}" &> /dev/null + sed -i 's/.mpeg//g' "${ksToolsSedFile}" &> /dev/null + sed -i 's/.wmv//g' "${ksToolsSedFile}" &> /dev/null + sed -i 's/.ogv//g' "${ksToolsSedFile}" &> /dev/null + sed -i 's/.webm//g' "${ksToolsSedFile}" &> /dev/null + sed -i 's/.flv//g' "${ksToolsSedFile}" &> /dev/null + # Show file without extension + wordToConvert=$(cat ${ksToolsSedFile}) + echo ${wordToConvert} } # Function to show files with spaces. # Syntax: showFileWithSpace function showFileWithSpace() { - echo "${1}" > ${dirTemp}/name.tmp - sed -i 's/_/ /g' ${dirTemp}/name.tmp - DisplayName=$(cat ${dirTemp}/name.tmp) - rm -rf ${dirTemp}/name.tmp - echo ${DisplayName} + echo "${1}" > ${dirTemp}/name.tmp + sed -i 's/_/ /g' ${dirTemp}/name.tmp + DisplayName=$(cat ${dirTemp}/name.tmp) + rm -rf ${dirTemp}/name.tmp + echo ${DisplayName} } # Function to show menu again when syntax is wrong function show_menu() { - echo "" - echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})" - echo "" - echo "- Crop or change aspect ratio of a video" - echo "" - echo "+ Config:" - echo "" - echo " - Resolutions: " - echo " + ${to4_3} (4:3)" - echo " + ${to16_9} (16:9)" - echo " + ${to5_4} (5:4)" - echo " + ${toImax} (IMAX)" - echo " - Video codec: ${vcodec}" - echo " - Bitrate video: ${b_vcodec}" - echo " - Preset: ${v_preset}" - echo " - Audio codec: ${acodec}" - echo " - Default Audio: ${default_lang_audio}" - echo " - Container: ${v_ext}" - echo "" - echo "+ Syntax: " - echo "" - echo " $ ks-crop -16:9-crop --> Crop from 4:3/IMAX to 16:9 (1.77:1)" - echo " $ ks-crop -4:3-crop --> Crop from 16:9 to 4:3 (1.33:1)" - echo " $ ks-crop -5:4-crop --> Crop from 16:9 to 5:4 (1.25:1)" - echo " $ ks-crop -imax-crop --> Crop from 16:9 to IMAX (1.43:1)" - echo "" - echo " $ ks-crop -16:9-aspect --> Change aspect to 16:9 (stretched)" - echo " $ ks-crop -4:3-aspect --> Change aspect to 4:3 (stretched)" - echo " $ ks-crop -5:4-aspect --> Change aspect to 5:4 (stretched)" - echo "" - echo " + Examples: " - echo " ks-crop -16:9-crop /data/movies/Example.mkv" - echo " ks-crop -4:3-aspect /data/movies/Video.avi" - echo "" - exit + echo "" + echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})" + echo "" + echo "- Crop or change aspect ratio of a video" + echo "" + echo "+ Config:" + echo "" + echo " - Resolutions: " + echo " + ${to4_3} (4:3)" + echo " + ${to16_9} (16:9)" + echo " + ${to5_4} (5:4)" + echo " + ${toImax} (IMAX)" + echo " - Video codec: ${vcodec}" + echo " - Bitrate video: ${b_vcodec}" + echo " - Preset: ${v_preset}" + echo " - Audio codec: ${acodec}" + echo " - Default Audio: ${default_lang_audio}" + echo " - Container: ${v_ext}" + echo "" + echo "+ Syntax: " + echo "" + echo " $ ks-crop -16:9-crop --> Crop from 4:3/IMAX to 16:9 (1.77:1)" + echo " $ ks-crop -4:3-crop --> Crop from 16:9 to 4:3 (1.33:1)" + echo " $ ks-crop -5:4-crop --> Crop from 16:9 to 5:4 (1.25:1)" + echo " $ ks-crop -imax-crop --> Crop from 16:9 to IMAX (1.43:1)" + echo "" + echo " $ ks-crop -16:9-aspect --> Change aspect to 16:9 (stretched)" + echo " $ ks-crop -4:3-aspect --> Change aspect to 4:3 (stretched)" + echo " $ ks-crop -5:4-aspect --> Change aspect to 5:4 (stretched)" + echo "" + echo " + Examples: " + echo " ks-crop -16:9-crop /data/movies/Example.mkv" + echo " ks-crop -4:3-aspect /data/movies/Video.avi" + echo "" + exit } # Function to show error reading file # Syntax: errorReadingFile function errorReadingFile() { - echo "" - echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})" - echo "" - echo "* The file '${1}' does not exist!" - echo "" - exit + echo "" + echo "* ks-crop (ks-tools) v${VERSION} (${M_DATE})" + echo "" + echo "* The file '${1}' does not exist!" + echo "" + exit } # Conversion parameters @@ -143,33 +143,33 @@ codec_hevc=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | yuv420p10le=$(${p_ffmpeg} "${2}" 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="-c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}" + p_conversion="-c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}" else - p_conversion="-c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}" + p_conversion="-c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}" fi # Show menu with bad syntax if [ "${1}" == "-16:9-crop" ] ; then - echo > /dev/null + echo > /dev/null elif [ "${1}" == "-4:3-crop" ] ; then - echo > /dev/null + echo > /dev/null elif [ "${1}" == "-5:4-crop" ] ; then - echo > /dev/null + echo > /dev/null elif [ "${1}" == "-imax-crop" ] ; then - echo > /dev/null + echo > /dev/null elif [ "${1}" == "-16:9-aspect" ] ; then - echo > /dev/null + echo > /dev/null elif [ "${1}" == "-4:3-aspect" ] ; then - echo > /dev/null + echo > /dev/null elif [ "${1}" == "-5:4-aspect" ] ; then - echo > /dev/null + echo > /dev/null else - show_menu + show_menu fi if [ -f "${2}" ] ; then - echo "detected" > /dev/null + echo "detected" > /dev/null else - errorReadingFile "${2}" + errorReadingFile "${2}" fi # Detect resolution of video file @@ -187,345 +187,345 @@ expr ${calculate_crop} + 1 &> /tmp/ks-tools.error ih_error="$?" if [ ${ih_error} -eq 0 ] ; then - ih_size="${calculate_crop}" + ih_size="${calculate_crop}" else - ih_size="0" + ih_size="0" fi # Function to crop videos function crop_video() { - echo "" - echo "* Information of ${inputFile}:" - echo "" - echo "+ Video Tracks:" - ${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1 - echo "" - echo "+ Audio Tracks:" - ${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1 - echo "" - # Check de video track by default - video_default=$(${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1) - if [ -z "${video_default}" ] ; then - video_default="0:0" - else - video_default_patch=$(echo ${video_default} | cut -c4) - if [ "${video_default_patch}" == ":" ] ; then - video_default=$(echo ${video_default} | cut -c1-3) - else - video_default="${video_default}" - fi - fi - # Ask for video - echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track - if [ -z "${video_track}" ] ; then - video_track="${video_default}" - else - video_track="${video_track}" - fi - # Check the audio track by default - audio_default=$(${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1) - if [ -z "${audio_default}" ] ; then - audio_default=$(${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1) - if [ -z "${audio_default}" ] ; then - audio_default="0:1" - else - audio_default_patch=$(echo ${audio_default} | cut -c4) - if [ "${audio_default_patch}" == ":" ] ; then - audio_default=$(echo ${audio_default} | cut -c1-3) - else - audio_default="${audio_default}" - fi - fi - else - audio_default_patch=$(echo ${audio_default} | cut -c4) - if [ "${audio_default_patch}" == ":" ] ; then - audio_default=$(echo ${audio_default} | cut -c1-3) - else - audio_default="${audio_default}" - fi - fi - # Ask for audio - echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track - if [ -z "${audio_track}" ] ; then - audio_track="${audio_default}" - else - audio_track="${audio_track}" - fi - # Ask for bitrate video - bitrate_default="${b_vcodec}" - echo -n "* (Default: ${b_vcodec}) Type the bitrate (${vcodec}): " ; read bitrate_video - if [ -z "${bitrate_video}" ] ; then - b_vcodec="${bitrate_default}" - else - b_vcodec="${bitrate_video}" - fi - # Reload p_conversion variable - if [ -z "${codec_h265_hevc}" ] ; then - p_conversion="-c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}" - else - p_conversion="-c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}" - fi - # Ask for patched - echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread - if [ "${patch_thread}" == "y" ] ; then - patch_thread="y" - else - patch_thread="n" - fi + echo "" + echo "* Information of ${inputFile}:" + echo "" + echo "+ Video Tracks:" + ${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d "," -f 1 + echo "" + echo "+ Audio Tracks:" + ${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d "," -f 1 + echo "" + # Check de video track by default + video_default=$(${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1) + if [ -z "${video_default}" ] ; then + video_default="0:0" + else + video_default_patch=$(echo ${video_default} | cut -c4) + if [ "${video_default_patch}" == ":" ] ; then + video_default=$(echo ${video_default} | cut -c1-3) + else + video_default="${video_default}" + fi + fi + # Ask for video + echo -n "* (Default: ${video_default}) Type the number of video track: " ; read video_track + if [ -z "${video_track}" ] ; then + video_track="${video_default}" + else + video_track="${video_track}" + fi + # Check the audio track by default + audio_default=$(${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "(${default_lang_audio})" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1) + if [ -z "${audio_default}" ] ; then + audio_default=$(${p_ffmpeg} "${inputFile}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | cut -d " " -f 3 | cut -c2-5 | cut -d "(" -f 1 | cut -d "[" -f 1 | head -1) + if [ -z "${audio_default}" ] ; then + audio_default="0:1" + else + audio_default_patch=$(echo ${audio_default} | cut -c4) + if [ "${audio_default_patch}" == ":" ] ; then + audio_default=$(echo ${audio_default} | cut -c1-3) + else + audio_default="${audio_default}" + fi + fi + else + audio_default_patch=$(echo ${audio_default} | cut -c4) + if [ "${audio_default_patch}" == ":" ] ; then + audio_default=$(echo ${audio_default} | cut -c1-3) + else + audio_default="${audio_default}" + fi + fi + # Ask for audio + echo -n "* (Default: ${audio_default}) Type the number of audio track: " ; read audio_track + if [ -z "${audio_track}" ] ; then + audio_track="${audio_default}" + else + audio_track="${audio_track}" + fi + # Ask for bitrate video + bitrate_default="${b_vcodec}" + echo -n "* (Default: ${b_vcodec}) Type the bitrate (${vcodec}): " ; read bitrate_video + if [ -z "${bitrate_video}" ] ; then + b_vcodec="${bitrate_default}" + else + b_vcodec="${bitrate_video}" + fi + # Reload p_conversion variable + if [ -z "${codec_h265_hevc}" ] ; then + p_conversion="-c:v ${vcodec} -profile:v high -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}" + else + p_conversion="-c:v ${vcodec} -profile:v high -pix_fmt yuv420p -b:v ${b_vcodec} -preset ${v_preset} -c:a ${acodec}" + fi + # Ask for patched + echo -n "* (Default: n) Do you want apply '-max_muxing_queue_size 9999' patch? (y/n): " ; read patch_thread + if [ "${patch_thread}" == "y" ] ; then + patch_thread="y" + else + patch_thread="n" + fi - # Check diferent modes - if [ "${modeCrop}" == "16:9-crop" ] ; then - inputFileOut=$(removeExtension ${inputFile}) - # Show commands for conversion - echo "" - echo "* COMMAND THAT WILL BE EXECUTED:" - echo "" - inputFileSave="${inputFile}" - ih_sizeSave="${ih_size}" - if [ ${ih_size} -eq 0 ] ; then - if [ "${patch_thread}" == "y" ] ; then - echo " # Error detecting file resolution. The generic solution is applied (slower)" - echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-resize.${v_ext}\"" - echo "" - inputFile="${inputFileOut}-resize.${v_ext}" - ih_size="360" - else - echo " # Error detecting file resolution. The generic solution is applied (slower)" - echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} \"${inputFileOut}-resize.${v_ext}\"" - echo "" - inputFile="${inputFileOut}-resize.${v_ext}" - ih_size="360" - fi - else - echo " # File detected with resolution" ${resolution_detected} "(ih ${ih_size})" - fi - echo " # Crop '${inputFile}' from 4:3/IMAX to 16:9 (1.77:1)" - 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}\"" - else - echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=iw:ih-${ih_size}\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\"" - fi - # Execute commands for conversion - echo "" - echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg - if [ "${run_commands_ffmpeg}" == "n" ] ; then - exit - else - inputFile="${inputFileSave}" - ih_size="${ih_sizeSave}" - inputFileOut=$(removeExtension ${inputFile}) - if [ ${ih_size} -eq 0 ] ; then - if [ "${patch_thread}" == "y" ] ; then - ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-resize.${v_ext}" - inputFile="${inputFileOut}-resize.${v_ext}" - ih_size="360" - else - ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} "${inputFileOut}-resize.${v_ext}" - inputFile="${inputFileOut}-resize.${v_ext}" - ih_size="360" - fi - fi - if [ "${patch_thread}" == "y" ] ; then - ${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}" - else - ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v "crop=iw:ih-${ih_size}" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}" - fi - fi - elif [ "${modeCrop}" == "4:3-crop" ] ; then - inputFileOut=$(removeExtension ${inputFile}) - # Show commands for conversion - echo "" - echo "* COMMAND THAT WILL BE EXECUTED:" - echo "" - echo " # File detected with resolution" ${resolution_detected} - echo " # Crop '${inputFile}' from 16:9 to 4:3 (1.33:1)" - 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}\"" - else - echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/3*4:ih\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\"" - fi - # Execute commands for conversion - echo "" - echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg - if [ "${run_commands_ffmpeg}" == "n" ] ; then - exit - else - if [ "${patch_thread}" == "y" ] ; then - ${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}" - else - ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/3*4:ih" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}" - fi - fi - elif [ "${modeCrop}" == "5:4-crop" ] ; then - inputFileOut=$(removeExtension ${inputFile}) - # Show commands for conversion - echo "" - echo "* COMMAND THAT WILL BE EXECUTED:" - echo "" - echo " # File detected with resolution" ${resolution_detected} - echo " # Crop '${inputFile}' from 16:9 to 5:4 (1.25:1)" - 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}\"" - else - echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/4*5:ih\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\"" - fi - # Execute commands for conversion - echo "" - echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg - if [ "${run_commands_ffmpeg}" == "n" ] ; then - exit - else - if [ "${patch_thread}" == "y" ] ; then - ${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}" - else - ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/4*5:ih" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}" - fi - fi - elif [ "${modeCrop}" == "imax-crop" ] ; then - inputFileOut=$(removeExtension ${inputFile}) - # Show commands for conversion - echo "" - echo "* COMMAND THAT WILL BE EXECUTED:" - echo "" - echo " # File detected with resolution" ${resolution_detected} - echo " # Crop '${inputFile}' from 16:9 to IMAX (1.43:1)" - 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}\"" - else - echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/2.79*4:ih\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\"" - fi - # Execute commands for conversion - echo "" - echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg - if [ "${run_commands_ffmpeg}" == "n" ] ; then - exit - else - if [ "${patch_thread}" == "y" ] ; then - ${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}" - else - ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/2.79*4:ih" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}" - fi - fi - elif [ "${modeCrop}" == "16:9-aspect" ] ; then - inputFileOut=$(removeExtension ${inputFile}) - # Show commands for conversion - echo "" - echo "* COMMAND THAT WILL BE EXECUTED:" - echo "" - echo " # File detected with resolution" ${resolution_detected} - echo " # Change '${inputFile}' aspect to 16:9 (stretched)" - 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}\"" - else - echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} \"${inputFileOut}-aspect.${v_ext}\"" - fi - # Execute commands for conversion - echo "" - echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg - if [ "${run_commands_ffmpeg}" == "n" ] ; then - exit - else - if [ "${patch_thread}" == "y" ] ; then - ${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}" - else - ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} "${inputFileOut}-aspect.${v_ext}" - fi - fi - elif [ "${modeCrop}" == "4:3-aspect" ] ; then - inputFileOut=$(removeExtension ${inputFile}) - # Show commands for conversion - echo "" - echo "* COMMAND THAT WILL BE EXECUTED:" - echo "" - echo " # File detected with resolution" ${resolution_detected} - echo " # Change '${inputFile}' aspect to 4:3 (stretched)" - 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}\"" - else - echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} \"${inputFileOut}-aspect.${v_ext}\"" - fi - # Execute commands for conversion - echo "" - echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg - if [ "${run_commands_ffmpeg}" == "n" ] ; then - exit - else - if [ "${patch_thread}" == "y" ] ; then - ${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}" - else - ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} "${inputFileOut}-aspect.${v_ext}" - fi - fi - elif [ "${modeCrop}" == "5:4-aspect" ] ; then - inputFileOut=$(removeExtension ${inputFile}) - # Show commands for conversion - echo "" - echo "* COMMAND THAT WILL BE EXECUTED:" - echo "" - echo " # File detected with resolution" ${resolution_detected} - echo " # Change '${inputFile}' aspect to 5:4 (stretched)" - 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}\"" - else - echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} \"${inputFileOut}-aspect.${v_ext}\"" - fi - # Execute commands for conversion - echo "" - echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg - if [ "${run_commands_ffmpeg}" == "n" ] ; then - exit - else - if [ "${patch_thread}" == "y" ] ; then - ${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}" - else - ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} "${inputFileOut}-aspect.${v_ext}" - fi - fi - else - show_menu - fi + # Check diferent modes + if [ "${modeCrop}" == "16:9-crop" ] ; then + inputFileOut=$(removeExtension ${inputFile}) + # Show commands for conversion + echo "" + echo "* COMMAND THAT WILL BE EXECUTED:" + echo "" + inputFileSave="${inputFile}" + ih_sizeSave="${ih_size}" + if [ ${ih_size} -eq 0 ] ; then + if [ "${patch_thread}" == "y" ] ; then + echo " # Error detecting file resolution. The generic solution is applied (slower)" + echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} ${p_ffmpeg_patched} \"${inputFileOut}-resize.${v_ext}\"" + echo "" + inputFile="${inputFileOut}-resize.${v_ext}" + ih_size="360" + else + echo " # Error detecting file resolution. The generic solution is applied (slower)" + echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} \"${inputFileOut}-resize.${v_ext}\"" + echo "" + inputFile="${inputFileOut}-resize.${v_ext}" + ih_size="360" + fi + else + echo " # File detected with resolution" ${resolution_detected} "(ih ${ih_size})" + fi + echo " # Crop '${inputFile}' from 4:3/IMAX to 16:9 (1.77:1)" + 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}\"" + else + echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=iw:ih-${ih_size}\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\"" + fi + # Execute commands for conversion + echo "" + echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg + if [ "${run_commands_ffmpeg}" == "n" ] ; then + exit + else + inputFile="${inputFileSave}" + ih_size="${ih_sizeSave}" + inputFileOut=$(removeExtension ${inputFile}) + if [ ${ih_size} -eq 0 ] ; then + if [ "${patch_thread}" == "y" ] ; then + ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} ${p_ffmpeg_patched} "${inputFileOut}-resize.${v_ext}" + inputFile="${inputFileOut}-resize.${v_ext}" + ih_size="360" + else + ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -s 1920x1440 ${p_conversion} "${inputFileOut}-resize.${v_ext}" + inputFile="${inputFileOut}-resize.${v_ext}" + ih_size="360" + fi + fi + if [ "${patch_thread}" == "y" ] ; then + ${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}" + else + ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v "crop=iw:ih-${ih_size}" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}" + fi + fi + elif [ "${modeCrop}" == "4:3-crop" ] ; then + inputFileOut=$(removeExtension ${inputFile}) + # Show commands for conversion + echo "" + echo "* COMMAND THAT WILL BE EXECUTED:" + echo "" + echo " # File detected with resolution" ${resolution_detected} + echo " # Crop '${inputFile}' from 16:9 to 4:3 (1.33:1)" + 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}\"" + else + echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/3*4:ih\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\"" + fi + # Execute commands for conversion + echo "" + echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg + if [ "${run_commands_ffmpeg}" == "n" ] ; then + exit + else + if [ "${patch_thread}" == "y" ] ; then + ${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}" + else + ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/3*4:ih" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}" + fi + fi + elif [ "${modeCrop}" == "5:4-crop" ] ; then + inputFileOut=$(removeExtension ${inputFile}) + # Show commands for conversion + echo "" + echo "* COMMAND THAT WILL BE EXECUTED:" + echo "" + echo " # File detected with resolution" ${resolution_detected} + echo " # Crop '${inputFile}' from 16:9 to 5:4 (1.25:1)" + 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}\"" + else + echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/4*5:ih\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\"" + fi + # Execute commands for conversion + echo "" + echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg + if [ "${run_commands_ffmpeg}" == "n" ] ; then + exit + else + if [ "${patch_thread}" == "y" ] ; then + ${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}" + else + ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/4*5:ih" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}" + fi + fi + elif [ "${modeCrop}" == "imax-crop" ] ; then + inputFileOut=$(removeExtension ${inputFile}) + # Show commands for conversion + echo "" + echo "* COMMAND THAT WILL BE EXECUTED:" + echo "" + echo " # File detected with resolution" ${resolution_detected} + echo " # Crop '${inputFile}' from 16:9 to IMAX (1.43:1)" + 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}\"" + else + echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v \"crop=ih/2.79*4:ih\" -s ${resolution} ${p_conversion} \"${inputFileOut}-crop.${v_ext}\"" + fi + # Execute commands for conversion + echo "" + echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg + if [ "${run_commands_ffmpeg}" == "n" ] ; then + exit + else + if [ "${patch_thread}" == "y" ] ; then + ${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}" + else + ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -filter:v "crop=ih/2.79*4:ih" -s ${resolution} ${p_conversion} "${inputFileOut}-crop.${v_ext}" + fi + fi + elif [ "${modeCrop}" == "16:9-aspect" ] ; then + inputFileOut=$(removeExtension ${inputFile}) + # Show commands for conversion + echo "" + echo "* COMMAND THAT WILL BE EXECUTED:" + echo "" + echo " # File detected with resolution" ${resolution_detected} + echo " # Change '${inputFile}' aspect to 16:9 (stretched)" + 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}\"" + else + echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} \"${inputFileOut}-aspect.${v_ext}\"" + fi + # Execute commands for conversion + echo "" + echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg + if [ "${run_commands_ffmpeg}" == "n" ] ; then + exit + else + if [ "${patch_thread}" == "y" ] ; then + ${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}" + else + ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 16:9 -s ${resolution} ${p_conversion} "${inputFileOut}-aspect.${v_ext}" + fi + fi + elif [ "${modeCrop}" == "4:3-aspect" ] ; then + inputFileOut=$(removeExtension ${inputFile}) + # Show commands for conversion + echo "" + echo "* COMMAND THAT WILL BE EXECUTED:" + echo "" + echo " # File detected with resolution" ${resolution_detected} + echo " # Change '${inputFile}' aspect to 4:3 (stretched)" + 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}\"" + else + echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} \"${inputFileOut}-aspect.${v_ext}\"" + fi + # Execute commands for conversion + echo "" + echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg + if [ "${run_commands_ffmpeg}" == "n" ] ; then + exit + else + if [ "${patch_thread}" == "y" ] ; then + ${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}" + else + ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 4:3 -s ${resolution} ${p_conversion} "${inputFileOut}-aspect.${v_ext}" + fi + fi + elif [ "${modeCrop}" == "5:4-aspect" ] ; then + inputFileOut=$(removeExtension ${inputFile}) + # Show commands for conversion + echo "" + echo "* COMMAND THAT WILL BE EXECUTED:" + echo "" + echo " # File detected with resolution" ${resolution_detected} + echo " # Change '${inputFile}' aspect to 5:4 (stretched)" + 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}\"" + else + echo " ${p_ffmpeg} \"${inputFile}\" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} \"${inputFileOut}-aspect.${v_ext}\"" + fi + # Execute commands for conversion + echo "" + echo -n "* (Default: y) Do you want run the conversion? (y/n): " ; read run_commands_ffmpeg + if [ "${run_commands_ffmpeg}" == "n" ] ; then + exit + else + if [ "${patch_thread}" == "y" ] ; then + ${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}" + else + ${p_ffmpeg} "${inputFile}" ${f_conversion} -map ${video_track} -map ${audio_track} -aspect 5:4 -s ${resolution} ${p_conversion} "${inputFileOut}-aspect.${v_ext}" + fi + fi + else + show_menu + fi } # Syntax: ks-crop