Read configuration from file on ~/.ks-tools/

This commit is contained in:
q3aql 2022-01-02 12:03:27 +01:00
parent b8a51234bf
commit 27656677d3
4 changed files with 234 additions and 6 deletions

View File

@ -13,6 +13,8 @@ M_DATE="030521"
dirTemp="/tmp" dirTemp="/tmp"
listTemp="ks-tools.list" listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools" ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-avi
# Basic parameters # Basic parameters
rel_size="720x480" rel_size="720x480"
@ -27,6 +29,61 @@ default_lang_audio="spa"
default_lang_subt="spa" default_lang_subt="spa"
v_ext="avi" v_ext="avi"
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
# Check cygwin alias (for Windows) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
@ -106,7 +163,7 @@ if [ -z "${1}" ] ; then
echo "" echo ""
echo "- Convert video file(s) to compact and efficient AVI" echo "- Convert video file(s) to compact and efficient AVI"
echo "" echo ""
echo "+ Config:" echo "+ Config: ${configFile}"
echo "" echo ""
echo " - Resolution: ${rel_size}" echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}" echo " - Video codec: ${vcodec}"

View File

@ -13,8 +13,10 @@ M_DATE="030521"
dirTemp="/tmp" dirTemp="/tmp"
listTemp="ks-tools.list" listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools" ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4
# Basic parameters # Basic parameters creating config file.
rel_size="1280x534" rel_size="1280x534"
vcodec="libx264" vcodec="libx264"
b_vcodec="2400k" b_vcodec="2400k"
@ -27,6 +29,61 @@ default_lang_audio="spa"
default_lang_subt="spa" default_lang_subt="spa"
v_ext="mp4" v_ext="mp4"
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
# Check cygwin alias (for Windows) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
@ -106,7 +163,7 @@ if [ -z "${1}" ] ; then
echo "" echo ""
echo "- Convert video file(s) to compact and efficient MP4" echo "- Convert video file(s) to compact and efficient MP4"
echo "" echo ""
echo "+ Config:" echo "+ Config: ${configFile}"
echo "" echo ""
echo " - Resolution: ${rel_size}" echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}" echo " - Video codec: ${vcodec}"

View File

@ -13,8 +13,10 @@ M_DATE="030521"
dirTemp="/tmp" dirTemp="/tmp"
listTemp="ks-tools.list" listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools" ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4k
# Basic parameters # Basic parameters creating config file.
rel_size="3840x2160" rel_size="3840x2160"
vcodec="libx264" vcodec="libx264"
b_vcodec="6000k" b_vcodec="6000k"
@ -27,6 +29,61 @@ default_lang_audio="spa"
default_lang_subt="spa" default_lang_subt="spa"
v_ext="mp4" v_ext="mp4"
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
# Check cygwin alias (for Windows) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
@ -106,7 +163,7 @@ if [ -z "${1}" ] ; then
echo "" echo ""
echo "- Convert video file(s) to compact and efficient MP4 (4K)" echo "- Convert video file(s) to compact and efficient MP4 (4K)"
echo "" echo ""
echo "+ Config:" echo "+ Config: ${configFile}"
echo "" echo ""
echo " - Resolution: ${rel_size}" echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}" echo " - Video codec: ${vcodec}"

View File

@ -13,6 +13,8 @@ M_DATE="030521"
dirTemp="/tmp" dirTemp="/tmp"
listTemp="ks-tools.list" listTemp="ks-tools.list"
ksToolsTempFolder="/tmp/ks-tools" ksToolsTempFolder="/tmp/ks-tools"
configFolder=${HOME}/.ks-tools
configFile=${configFolder}/ks-mp4s
# Basic parameters # Basic parameters
rel_size="720x480" rel_size="720x480"
@ -27,6 +29,61 @@ default_lang_audio="spa"
default_lang_subt="spa" default_lang_subt="spa"
v_ext="mp4" v_ext="mp4"
# Create inicial config file
mkdir -p ${configFolder}
if [ -f ${configFile} ] ; then
exist_rel_size=$(cat ${configFile} | grep "rel_size=")
exist_vcodec=$(cat ${configFile} | grep "vcodec=" | cut -c2 | cut -d "_" -f 1)
exist_b_vcodec=$(cat ${configFile} | grep "b_vcodec=")
exist_v_preset=$(cat ${configFile} | grep "v_preset=")
exist_acodec=$(cat ${configFile} | grep "acodec" | cut -c2 | cut -d "_" -f 1)
exist_b_acodec=$(cat ${configFile} | grep "b_acodec=")
exist_default_lang_audio=$(cat ${configFile} | grep "default_lang_audio=")
exist_default_lang_subt=$(cat ${configFile} | grep "default_lang_subt=")
exist_v_ext=$(cat ${configFile} | grep "v_ext=")
if [ -z ${exist_rel_size} ] ; then
echo "rel_size=${rel_size}" >> ${configFile}
fi
if [ -z ${exist_vcodec} ] ; then
echo "vcodec=${vcodec}" >> ${configFile}
fi
if [ -z ${exist_b_vcodec} ] ; then
echo "b_vcodec=${b_vcodec}" >> ${configFile}
fi
if [ -z ${exist_v_preset} ] ; then
echo "v_preset=${v_preset}" >> ${configFile}
fi
if [ -z ${exist_acodec} ] ; then
echo "acodec=${acodec}" >> ${configFile}
fi
if [ -z ${exist_b_acodec} ] ; then
echo "b_acodec=${b_acodec}" >> ${configFile}
fi
if [ -z ${exist_default_lang_audio} ] ; then
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
fi
if [ -z ${exist_default_lang_subt} ] ; then
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
fi
if [ -z ${exist_v_ext} ] ; then
echo "v_ext=${v_ext}" >> ${configFile}
fi
source ${configFile}
else
echo "#!/bin/bash" > ${configFile}
echo "" >> ${configFile}
echo "rel_size=${rel_size}" >> ${configFile}
echo "vcodec=${vcodec}" >> ${configFile}
echo "b_vcodec=${b_vcodec}" >> ${configFile}
echo "v_preset=${v_preset}" >> ${configFile}
echo "acodec=${acodec}" >> ${configFile}
echo "b_acodec=${b_acodec}" >> ${configFile}
echo "default_lang_audio=${default_lang_audio}" >> ${configFile}
echo "default_lang_subt=${default_lang_subt}" >> ${configFile}
echo "v_ext=${v_ext}" >> ${configFile}
source ${configFile}
fi
# Check cygwin alias (for Windows) # Check cygwin alias (for Windows)
if [ -f "/usr/bin/cygwin-alias.sh" ] ; then if [ -f "/usr/bin/cygwin-alias.sh" ] ; then
shopt -s expand_aliases shopt -s expand_aliases
@ -106,7 +163,7 @@ if [ -z "${1}" ] ; then
echo "" echo ""
echo "- Convert video file(s) to compact and efficient MP4 (Series)" echo "- Convert video file(s) to compact and efficient MP4 (Series)"
echo "" echo ""
echo "+ Config:" echo "+ Config: ${configFile}"
echo "" echo ""
echo " - Resolution: ${rel_size}" echo " - Resolution: ${rel_size}"
echo " - Video codec: ${vcodec}" echo " - Video codec: ${vcodec}"