Even more modularization. Working on using locals vs. globals in the new internal functions as best as at all possible.
parent
369d928368
commit
054d282ba6
44
convmlv.sh
44
convmlv.sh
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
VERSION="2.1.0a1" #Version string.
|
#desc: Main file - uses convmlv components as needed.
|
||||||
INPUT_ARGS=$(echo "$@") #The original input argument string.
|
|
||||||
|
|
||||||
#~ The MIT License (MIT)
|
#~ The MIT License (MIT)
|
||||||
|
|
||||||
|
@ -25,6 +24,9 @@ INPUT_ARGS=$(echo "$@") #The original input argument string.
|
||||||
#~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
#~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
#~ SOFTWARE.
|
#~ SOFTWARE.
|
||||||
|
|
||||||
|
VERSION="2.1.0a2" #Version string.
|
||||||
|
INPUT_ARGS=$(echo "$@") #The original input argument string.
|
||||||
|
|
||||||
if [ $# == 0 ]; then #No given arguments.
|
if [ $# == 0 ]; then #No given arguments.
|
||||||
echo -e "\033[0;31m\033[1mNo arguments given.\033[0m\n\tType 'convmlv -h/--help' to see help page, or 'convmlv -v/--version' for current version string."
|
echo -e "\033[0;31m\033[1mNo arguments given.\033[0m\n\tType 'convmlv -h/--help' to see help page, or 'convmlv -v/--version' for current version string."
|
||||||
fi
|
fi
|
||||||
|
@ -214,6 +216,8 @@ source "$SRC_PATH/helpers/utility.sh"
|
||||||
source "$SRC_PATH/core/parsing.sh"
|
source "$SRC_PATH/core/parsing.sh"
|
||||||
source "$SRC_PATH/helpers/error.sh"
|
source "$SRC_PATH/helpers/error.sh"
|
||||||
source "$SRC_PATH/core/develop.sh"
|
source "$SRC_PATH/core/develop.sh"
|
||||||
|
source "$SRC_PATH/core/proc.sh"
|
||||||
|
source "$SRC_PATH/imgProcessing/imgMath.sh"
|
||||||
|
|
||||||
|
|
||||||
#OPTION PARSING FROM CONFIG AND CLI - same as at bottom of develop().
|
#OPTION PARSING FROM CONFIG AND CLI - same as at bottom of develop().
|
||||||
|
@ -259,7 +263,41 @@ case "$PROGRAM" in
|
||||||
;;
|
;;
|
||||||
develop)
|
develop)
|
||||||
checkDeps #Check static dependencies.
|
checkDeps #Check static dependencies.
|
||||||
develop #Do the development step, using the globals that exist.
|
|
||||||
|
ARG_INC=0
|
||||||
|
for ARG in "${FILE_ARGS_ARRAY[@]}"; do #Go through FILE_ARGS_ARRAY array, copied from parsed $@ because $@ is going to be changing on 'set --'
|
||||||
|
#Check the argument
|
||||||
|
fReturn=$(checkArg "$ARG")
|
||||||
|
if [[ $fReturn = "false" ]]; then continue; fi
|
||||||
|
|
||||||
|
#Evaluate local configuration file for file-specific blocks.
|
||||||
|
parseConf "$LCONFIG" true
|
||||||
|
|
||||||
|
#Do the development step, using the globals that exist.
|
||||||
|
develop "$ARG"
|
||||||
|
|
||||||
|
#RESET ARGS & REPARSE OPTIONS - same as in convmlv.sh.
|
||||||
|
#Big parse/reparse, making sure global, local, command line options all override each other correctly.
|
||||||
|
set -- $INPUT_ARGS #Reset the argument input for reparsing.
|
||||||
|
setDefaults #Hard set/reset all the lovely globals.
|
||||||
|
OPTIND=1 #Reset argument parsing.
|
||||||
|
|
||||||
|
parseConf "$GCONFIG" false #Parse global config file.
|
||||||
|
|
||||||
|
parseArgs "$@" #First, parse all cli args. We only need the -C flag, but that forces us to just parse everything.
|
||||||
|
shift $((OPTIND-1)) #Shift past all of the options to the file arguments.
|
||||||
|
|
||||||
|
parseConf "$LCONFIG" false #Parse local config file.
|
||||||
|
set -- $INPUT_ARGS #Reset $@ for cli option reparsing.
|
||||||
|
OPTIND=1 #To reset argument parsing, we must set OPTIND to 1.
|
||||||
|
|
||||||
|
parseArgs "$@" #Reparse cli to overwrite local config options.
|
||||||
|
shift $((OPTIND-1)) #Shift past all of the options to the file arguments.
|
||||||
|
OPTIND=1 #Reset argument index.
|
||||||
|
|
||||||
|
#Decrement the arguments that are left.
|
||||||
|
let ARG_INC++
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
setRange() {
|
setRange() {
|
||||||
#FRAMES must be set at this point.
|
#FRAMES must be set at this point.
|
||||||
|
#usage: setRange
|
||||||
|
#desc: Using FRAMES, sets the variables pertaining to frame range.
|
||||||
|
|
||||||
if [[ $isFR == true ]]; then #Ensure that FRAME_RANGE is set with $FRAMES.
|
if [[ $isFR == true ]]; then #Ensure that FRAME_RANGE is set with $FRAMES.
|
||||||
FRAME_RANGE="1-${FRAMES}"
|
FRAME_RANGE="1-${FRAMES}"
|
||||||
FRAME_START="1"
|
FRAME_START="1"
|
||||||
|
@ -22,46 +25,42 @@ setRange() {
|
||||||
}
|
}
|
||||||
|
|
||||||
develop() {
|
develop() {
|
||||||
trap "rm -rf ${TMP}; exit 1" INT #TMP will be removed if you CTRL+C.
|
#Usage: develop arg -- globals are treated as a large, passed in data structure.
|
||||||
for ARG in "${FILE_ARGS_ARRAY[@]}"; do #Go through FILE_ARGS_ARRAY array, copied from parsed $@ because $@ is going to be changing on 'set --'
|
#Desc: Develops footage according to the current configuration of global variables.
|
||||||
ARG=$(readlinkF "$ARG") #Use platform-independent readline.
|
|
||||||
|
local ARG=$(readlinkF "$1") #ARG is the MLV, RAW, or DNG sequence to be processed.
|
||||||
|
|
||||||
|
local DIRNAME=$(dirname "$ARG") #DIRNAME is the name of the folder containing the ARG.
|
||||||
|
|
||||||
#The Very Basics
|
#The Very Basics
|
||||||
BASE="$(basename "$ARG")"
|
local BASE="$(basename "$ARG")" #BASE is the name of the file.
|
||||||
EXT="${BASE##*.}"
|
local TRUNC_ARG="${BASE%.*}" #TRUNC_ARG is the name of the file, sans extension.
|
||||||
if [[ "${EXT}" == ".${BASE}" ]]; then EXT=""; fi #This means the input is a folder, which has no extension.
|
|
||||||
DIRNAME=$(dirname "$ARG")
|
|
||||||
TRUNC_ARG="${BASE%.*}"
|
|
||||||
SCALE=`echo "($(echo "${PROXY_SCALE}" | sed 's/%//') / 100) * 2" | bc -l` #Get scale as factor for halved video, *2 for 50%
|
|
||||||
setBL=true
|
|
||||||
#Evaluate local configuration file for file-specific blocks.
|
|
||||||
parseConf "$LCONFIG" true
|
|
||||||
|
|
||||||
#Check that ARG exists and works.
|
local EXT="${BASE##*.}" #EXT is the file's extension.
|
||||||
local action=$(checkArg)
|
if [[ "${EXT}" == ".${BASE}" ]]; then EXT=""; fi #If the input is a folder, it will have no extension.
|
||||||
if [[ $action = "skip" ]]; then
|
|
||||||
let ARGNUM--; continue
|
local SCALE=`echo "($(echo "${PROXY_SCALE}" | sed 's/%//') / 100) * 2" | bc -l` #Get scale as factor for halved video, *2 for 50%
|
||||||
fi
|
setBL=true
|
||||||
|
|
||||||
#Color Management - The Color LUT is chosen + applied.
|
#Color Management - The Color LUT is chosen + applied.
|
||||||
|
|
||||||
#We define what "STANDARD" means. Gamma 2.2 if it's not specifically defined.
|
#We define what "STANDARD" means. Gamma 2.2 if it's not specifically defined.
|
||||||
if [[ $COLOR_GAMUT != "xyz" ]]; then
|
if [[ $COLOR_GAMUT != "xyz" ]]; then
|
||||||
|
|
||||||
#~ if [[ $COLOR_GAMUT == "aces" ]]; then #List of Linear Only gamuts. XYZ excluded, in that that's default output; no filtering needed.
|
#This block defines what a "STANDARD" gamma means for each gamut.
|
||||||
#~ COLOR_GAMMA="lin"
|
|
||||||
#~ fi
|
|
||||||
|
|
||||||
if [[ $COLOR_GAMMA == "STANDARD" ]]; then
|
if [[ $COLOR_GAMMA == "STANDARD" ]]; then
|
||||||
if [[ $COLOR_GAMUT == "argb" || $COLOR_GAMUT == "ssg3c" ]]; then #List of gamuts with Gamma 2.2 .
|
if [[ $COLOR_GAMUT == "argb" || $COLOR_GAMUT == "ssg3c" ]]; then #List of gamuts with Gamma 2.2 .
|
||||||
COLOR_GAMMA="y2*2"
|
COLOR_GAMMA="y2*2"
|
||||||
|
elif [[ $COLOR_GAMUT == "aces" ]]; then #ACES is linear.
|
||||||
|
COLOR_GAMMA="lin"
|
||||||
else
|
else
|
||||||
COLOR_GAMMA=$COLOR_GAMUT
|
COLOR_GAMMA=$COLOR_GAMUT #Otherwise, "standard" is the name of the gamut.
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for source in "${COLOR_LUTS[@]}"; do
|
for lutSource in "${COLOR_LUTS[@]}"; do
|
||||||
colorName="${source}/lin_xyz--${COLOR_GAMMA}_${COLOR_GAMUT}.cube"
|
colorName="${lutSource}/lin_xyz--${COLOR_GAMMA}_${COLOR_GAMUT}.cube"
|
||||||
|
#~ colorName="${lutSource}/lin_srgb--${COLOR_GAMMA}_${COLOR_GAMUT}.cube"
|
||||||
if [[ -f $colorName ]]; then
|
if [[ -f $colorName ]]; then
|
||||||
COLOR_VF="lut3d=$colorName"
|
COLOR_VF="lut3d=$colorName"
|
||||||
colorDesc="Color Management LUT"
|
colorDesc="Color Management LUT"
|
||||||
|
@ -70,7 +69,7 @@ develop() {
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $COLOR_VF == "" ]]; then
|
if [[ $COLOR_VF == "" ]]; then
|
||||||
echo -e "\033[0;31m\033[1mSpecified LUT not found! Is color-ext loaded?.\033[0m\n"
|
error "Specified LUT not found! Is color-ext loaded?\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi #COLOR_VF is nothing if the gamut is xyz - it'll pass directly out of dcraw/IM, without LUT application.
|
fi #COLOR_VF is nothing if the gamut is xyz - it'll pass directly out of dcraw/IM, without LUT application.
|
||||||
|
@ -90,31 +89,33 @@ develop() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#List remaining files to process.
|
#List remaining files to process.
|
||||||
remFiles=${@:`echo "$# - ($ARGNUM - 1)" | bc`:$#}
|
local remFiles=("${FILE_ARGS_ARRAY[@]:$ARG_INC:$ARGNUM}") #Make a new array from slice.
|
||||||
remArr=$(echo $remFiles)
|
|
||||||
|
|
||||||
|
#Assemble list of files left to process.
|
||||||
list=""
|
list=""
|
||||||
for item in $remArr; do
|
for item in "${remFiles[@]}"; do
|
||||||
itemBase=$(basename $item)
|
local itemBase=$(basename $item)
|
||||||
itemExt=".${itemBase##*.}" #Dot must be in here.
|
local itemExt=".${itemBase##*.}" #Dot must be in here.
|
||||||
if [[ "${itemExt}" == ".${itemBase}" ]]; then itemExt=""; fi #This means the input is a folder, which has no extension.
|
if [[ "${itemExt}" == ".${itemBase}" ]]; then itemExt=""; fi #This means the input is a folder, which has no extension.
|
||||||
itemDir=$(dirname "$item")
|
|
||||||
|
local itemDir=$(dirname "$item")
|
||||||
|
|
||||||
if [ -z "${list}" ]; then
|
if [ -z "${list}" ]; then
|
||||||
if [[ $itemBase == $(basename $ARG) ]]; then
|
list=$(formArg "$ARG" "selected")
|
||||||
list="${itemDir}/\033[1m\033[32m${itemBase%.*}\033[0m${itemExt}"
|
#~ if [[ $itemBase == $(basename $ARG) ]]; then
|
||||||
|
#~ list="${itemDir}/$(selected "${itemBase%.*}")${itemExt}"
|
||||||
|
#~ else
|
||||||
|
#~ list="${itemDir}/$(bold ${itemBase%.*})${itemExt}"
|
||||||
|
#~ fi
|
||||||
else
|
else
|
||||||
list="${itemDir}/\033[1m${itemBase%.*}\033[0m${itemExt}"
|
list="${list}, $(formArg "$ARG" "deselected")"
|
||||||
fi
|
|
||||||
else
|
|
||||||
list="${list}, ${itemDir}/\033[1m${itemBase%.*}\033[0m${itemExt}"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $ARGNUM == 1 ]; then
|
if [[ ${#remFiles[@]} == 1 ]]; then
|
||||||
echo -e "\n\033[1m${ARGNUM} File Left to Process:\033[0m ${list}\n"
|
echo -e "\n$(bold "${#remFiles[@]} File Left to Process:") ${list}\n"
|
||||||
else
|
else
|
||||||
echo -e "\n\033[1m${ARGNUM} Files Left to Process:\033[0m ${list}\n"
|
echo -e "\n$(bold "${#remFiles[@]} Files Left to Process:") ${list}\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#PREPARATION
|
#PREPARATION
|
||||||
|
@ -127,8 +128,8 @@ develop() {
|
||||||
isOutGen=true
|
isOutGen=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FILE="${OUTDIR}/${TRUNC_ARG}"
|
local FILE="${OUTDIR}/${TRUNC_ARG}"
|
||||||
TMP="${FILE}/tmp_${TRUNC_ARG}"
|
local TMP="${FILE}/tmp_${TRUNC_ARG}"
|
||||||
|
|
||||||
#DNG argument, reused or not. Also, create FILE and TMP.
|
#DNG argument, reused or not. Also, create FILE and TMP.
|
||||||
DEVELOP=true
|
DEVELOP=true
|
||||||
|
@ -142,18 +143,19 @@ develop() {
|
||||||
TRUNC_ARG=`echo $TRUNC_ARG | cut -c5-${#TRUNC_ARG}`
|
TRUNC_ARG=`echo $TRUNC_ARG | cut -c5-${#TRUNC_ARG}`
|
||||||
else
|
else
|
||||||
echo -e "\033[0;31m\033[1mCannot reuse - DNG folder does not exist! Skipping argument.\033[0m"
|
echo -e "\033[0;31m\033[1mCannot reuse - DNG folder does not exist! Skipping argument.\033[0m"
|
||||||
continue
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DNG_LOC=${OUTDIR}/tmp_reused
|
DNG_LOC=${OUTDIR}/tmp_reused
|
||||||
mkdir -p ${OUTDIR}/tmp_reused
|
mkdir -p ${OUTDIR}/tmp_reused
|
||||||
|
|
||||||
find $ARG -iname "*.dng" | xargs -I {} mv {} $DNG_LOC #Copying DNGs to temporary location.
|
find $ARG -iname "*.dng" | xargs -I {} mv {} $DNG_LOC #Moving DNGs to temporary location.
|
||||||
|
|
||||||
dngSet "$DNG_LOC"
|
reuseSet "$ARG"
|
||||||
FPS=`cat ${ARG}/../settings.txt | grep "FPS" | cut -d $" " -f2` #Grab FPS from previous run.
|
#~ dngSet "$DNG_LOC"
|
||||||
FRAMES=`cat ${ARG}/../settings.txt | grep "Frames" | cut -d $" " -f2` #Grab FRAMES from previous run.
|
#~ FPS=`cat ${ARG}/../settings.txt | grep "FPS" | cut -d $" " -f2` #Grab FPS from previous run.
|
||||||
KELVIN=`cat ${ARG}/../settings.txt | grep "WBKelvin" | cut -d $" " -f2`
|
#~ FRAMES=`cat ${ARG}/../settings.txt | grep "Frames" | cut -d $" " -f2` #Grab FRAMES from previous run.
|
||||||
|
#~ KELVIN=`cat ${ARG}/../settings.txt | grep "WBKelvin" | cut -d $" " -f2`
|
||||||
cp "${ARG}/../settings.txt" $DNG_LOC
|
cp "${ARG}/../settings.txt" $DNG_LOC
|
||||||
|
|
||||||
oldARG="${ARG}"
|
oldARG="${ARG}"
|
||||||
|
@ -171,8 +173,8 @@ develop() {
|
||||||
rm -rf $DNG_LOC
|
rm -rf $DNG_LOC
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdirS $FILE dngLocClean
|
mkdirS $FILE dngLocClean; if [ $? -eq 1 ]; then return 1; fi
|
||||||
mkdirS $TMP #Make the folders.
|
mkdirS $TMP; if [ $? -eq 1 ]; then return 1; fi #Make the folders.
|
||||||
|
|
||||||
find $DNG_LOC -iname "*.dng" | xargs -I {} mv {} $TMP #Moving files to where they need to go.
|
find $DNG_LOC -iname "*.dng" | xargs -I {} mv {} $TMP #Moving files to where they need to go.
|
||||||
cp "${DNG_LOC}/settings.txt" $FILE
|
cp "${DNG_LOC}/settings.txt" $FILE
|
||||||
|
@ -181,8 +183,8 @@ develop() {
|
||||||
DEVELOP=false
|
DEVELOP=false
|
||||||
rm -r $DNG_LOC
|
rm -r $DNG_LOC
|
||||||
elif [ -d $ARG ]; then #If it's a DNG sequence, but not a reused one.
|
elif [ -d $ARG ]; then #If it's a DNG sequence, but not a reused one.
|
||||||
mkdirS $FILE
|
mkdirS $FILE; if [ $? -eq 1 ]; then return 1; fi
|
||||||
mkdirS $TMP
|
mkdirS $TMP; if [ $? -eq 1 ]; then return 1; fi
|
||||||
|
|
||||||
echo -e "\033[1m${TRUNC_ARG}:\033[0m Using specified folder of RAW sequences...\n" #Use prespecified DNG sequence.
|
echo -e "\033[1m${TRUNC_ARG}:\033[0m Using specified folder of RAW sequences...\n" #Use prespecified DNG sequence.
|
||||||
|
|
||||||
|
@ -202,8 +204,8 @@ develop() {
|
||||||
|
|
||||||
DEVELOP=false #We're not developing DNG's; we already have them!
|
DEVELOP=false #We're not developing DNG's; we already have them!
|
||||||
else
|
else
|
||||||
mkdirS $FILE
|
mkdirS $FILE; if [ $? -eq 1 ]; then return 1; fi
|
||||||
mkdirS $TMP
|
mkdirS $TMP; if [ $? -eq 1 ]; then return 1; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Darkframe Averaging
|
#Darkframe Averaging
|
||||||
|
@ -272,47 +274,11 @@ develop() {
|
||||||
fileRanges=(`echo $($SRANGE $REAL_FRAMES $THREADS)`) #Get an array of frame ranges from the amount of frames and threads. I used a python script for this.
|
fileRanges=(`echo $($SRANGE $REAL_FRAMES $THREADS)`) #Get an array of frame ranges from the amount of frames and threads. I used a python script for this.
|
||||||
#Looks like this: 0-1 2-2 3-4 5-5 6-7 8-8 9-10. Put that in an array.
|
#Looks like this: 0-1 2-2 3-4 5-5 6-7 8-8 9-10. Put that in an array.
|
||||||
|
|
||||||
devDNG() { #Takes n arguments: 1{}, the frame range 2$MLV_DUMP 3$REAL_MLV 4$DARK_PROC 5$no_data 6$smooth 7$TMP 8$FRAME_END 9$TRUNC_ARG 10$FRAME_START
|
|
||||||
range=$1
|
|
||||||
firstFrame=false
|
|
||||||
if [[ $range == "0-0" ]]; then #mlv_dump can't handle 0-0, so we develop 0-1.
|
|
||||||
range="0-1"
|
|
||||||
firstFrame=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
tmpOut=${7}/${range} #Each output will number from 0, so give each its own folder.
|
|
||||||
mkdir -p $tmpOut
|
|
||||||
|
|
||||||
start=$(echo "$range" | cut -d'-' -f1)
|
|
||||||
end=$(echo "$range" | cut -d'-' -f2) #Get start and end frames from the frame range
|
|
||||||
|
|
||||||
$2 $3 $4 -o "${tmpOut}/${9}_" -f ${range} $6 --dng --batch | { #mlv_dump command. Uses frame range.
|
|
||||||
lastCur=0
|
|
||||||
while IFS= read -r line; do
|
|
||||||
output=$(echo $line | grep -Po 'V.*A' | cut -d':' -f2 | cut -d$' ' -f1) #Hacked my way to the important bit.
|
|
||||||
if [[ $output == "" ]]; then continue; fi #If there's no important bit, don't print.
|
|
||||||
|
|
||||||
cur=$(echo "$output" | cut -d'/' -f1) #Current frame.
|
|
||||||
if [[ $cur == $lastCur ]] || [[ $cur -gt $end ]] || [[ $cur -lt $start ]]; then continue; fi #Turns out, it goes through all the frames, even if cutting the frame range. So, clamp it!
|
|
||||||
|
|
||||||
lastCur=$cur #It likes to repeat itself.
|
|
||||||
echo -e "\033[2K\rMLV to DNG: Frame $(echo "${cur} + ${10}" | bc)/${8}\c" #Print out beautiful progress bar, in parallel!
|
|
||||||
done
|
|
||||||
|
|
||||||
} #Progress Bar
|
|
||||||
if [[ $firstFrame == true ]]; then #If 0-0.
|
|
||||||
rm $(printf "${tmpOut}/${9}_%06d.dng" 1) 2>/dev/null #Remove frame #1, leaving us only with frame #0.
|
|
||||||
mv $tmpOut "${7}/0-0" #Move back to 0-0, as if that's how it was developed all along.
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
export -f devDNG #Export to run in subshell.
|
|
||||||
|
|
||||||
for range in "${fileRanges[@]}"; do echo $range; done | #For each frame range, assign a thread.
|
for range in "${fileRanges[@]}"; do echo $range; done | #For each frame range, assign a thread.
|
||||||
xargs -I {} -P $THREADS -n 1 \
|
xargs -I {} -P $THREADS -n 1 \
|
||||||
bash -c "devDNG '{}' '$MLV_DUMP' '$REAL_MLV' '$DARK_PROC' 'no_data' '$smooth' '$TMP' '$FRAME_END' '$TRUNC_ARG' '$FRAME_START'"
|
bash -c "dng_par '{}' '$MLV_DUMP' '$REAL_MLV' '$DARK_PROC' 'no_data' '$smooth' '$TMP' '$FRAME_END' '$TRUNC_ARG' '$FRAME_START'"
|
||||||
|
|
||||||
#Since devDNG must run in a subshell, globals don't follow. Must pass *everything* in.
|
#Since dng_par must run in a subshell, globals don't follow. Must pass *everything* in.
|
||||||
echo -e "\033[2K\rMLV to DNG: Frame ${FRAME_END}/${FRAME_END}\c" #Ensure it looks right at the end.
|
echo -e "\033[2K\rMLV to DNG: Frame ${FRAME_END}/${FRAME_END}\c" #Ensure it looks right at the end.
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
|
|
||||||
|
@ -388,29 +354,14 @@ develop() {
|
||||||
|
|
||||||
#Original DNGs will be moved here.
|
#Original DNGs will be moved here.
|
||||||
oldFiles="${TMP}/orig_dng"
|
oldFiles="${TMP}/orig_dng"
|
||||||
mkdirS $oldFiles
|
mkdirS $oldFiles; if [ $? -eq 1 ]; then return 1; fi
|
||||||
|
|
||||||
inc_iso() { #6 args: 1{} 2$CR_HDR 3$TMP 4$FRAME_END 5$oldFiles 6$CHROMA_SMOOTH. {} is a path. Progress is thread safe. Experiment gone right :).
|
|
||||||
count=$(echo "$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) + 1" | bc) #Get count from filename.
|
|
||||||
|
|
||||||
$2 $1 $6 >/dev/null 2>/dev/null #The LQ option, --mean23, is completely unusable in my opinion.
|
|
||||||
|
|
||||||
name=$(basename "$1")
|
|
||||||
mv "${3}/${name%.*}.dng" $5 #Move away original dngs.
|
|
||||||
mv "${3}/${name%.*}.DNG" "${3}/${name%.*}.dng" #Rename *.DNG to *.dng.
|
|
||||||
|
|
||||||
echo -e "\033[2K\rDual ISO Development: Frame ${count}/${4}\c"
|
|
||||||
}
|
|
||||||
|
|
||||||
export -f inc_iso #Must expose function to subprocess.
|
|
||||||
|
|
||||||
#~ echo "${CR_HDR} ${TMP}/${TRUNC_ARG}_$(printf "%06d" $FRAME_START).dng"
|
|
||||||
if [[ $(${CR_HDR} "${TMP}/${TRUNC_ARG}_$(printf "%06d" $FRAME_START).dng") == *"ISO blending didn't work"* ]]; then
|
if [[ $(${CR_HDR} "${TMP}/${TRUNC_ARG}_$(printf "%06d" $FRAME_START).dng") == *"ISO blending didn't work"* ]]; then
|
||||||
invOption "The input wasn't shot Dual ISO!"
|
invOption "The input wasn't shot Dual ISO!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $TMP -maxdepth 1 -name "*.dng" -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 \
|
find $TMP -maxdepth 1 -name "*.dng" -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 \
|
||||||
bash -c "inc_iso '{}' '$CR_HDR' '$TMP' '$FRAME_END' '$oldFiles' '$CHROMA_SMOOTH'"
|
bash -c "iso_par '{}' '$CR_HDR' '$TMP' '$FRAME_END' '$oldFiles' '$CHROMA_SMOOTH'"
|
||||||
|
|
||||||
BLACK_LEVEL=$(exiftool -BlackLevel -s -s -s ${TMP}/${TRUNC_ARG}_$(printf "%06d" $(echo "$FRAME_START" | bc)).dng) #Use the first DNG to get the new correct black level.
|
BLACK_LEVEL=$(exiftool -BlackLevel -s -s -s ${TMP}/${TRUNC_ARG}_$(printf "%06d" $(echo "$FRAME_START" | bc)).dng) #Use the first DNG to get the new correct black level.
|
||||||
|
|
||||||
|
@ -421,33 +372,6 @@ develop() {
|
||||||
echo -e "BlackLevel: ${BLACK_LEVEL}" >> $FILE/settings.txt #Black level must now be set.
|
echo -e "BlackLevel: ${BLACK_LEVEL}" >> $FILE/settings.txt #Black level must now be set.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
normToOne() {
|
|
||||||
wBal=$1
|
|
||||||
|
|
||||||
max=0.0
|
|
||||||
for mult in $wBal; do
|
|
||||||
if [ $(echo " $mult > $max" | bc) -eq 1 ]; then
|
|
||||||
max=$mult
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
for mult in $wBal; do
|
|
||||||
echo -e "$(echo "scale=6; x=${mult} / ${max}; if(x<1) print 0; x" | bc -l) \c" #BC is bae.
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
getGreen() {
|
|
||||||
wBal=$1
|
|
||||||
|
|
||||||
i=0
|
|
||||||
for mult in $wBal; do
|
|
||||||
if [ $i -eq 1 ]; then
|
|
||||||
echo -e "${mult}"
|
|
||||||
fi
|
|
||||||
let i++
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
#Get White Balance correction factor.
|
#Get White Balance correction factor.
|
||||||
if [ $GEN_WHITE == true ]; then
|
if [ $GEN_WHITE == true ]; then
|
||||||
echo -e "\033[1m${TRUNC_ARG}:\033[0m Generating WB...\n"
|
echo -e "\033[1m${TRUNC_ARG}:\033[0m Generating WB...\n"
|
||||||
|
@ -462,7 +386,7 @@ develop() {
|
||||||
n=`echo "${frameLen} / ${WHITE_SPD}" | bc`
|
n=`echo "${frameLen} / ${WHITE_SPD}" | bc`
|
||||||
|
|
||||||
toBal="${TMP}/toBal"
|
toBal="${TMP}/toBal"
|
||||||
mkdirS $toBal
|
mkdirS $toBal; if [ $? -eq 1 ]; then return 1; fi
|
||||||
|
|
||||||
#Develop every nth file for averaging.
|
#Develop every nth file for averaging.
|
||||||
local i=0
|
local i=0
|
||||||
|
@ -516,162 +440,24 @@ develop() {
|
||||||
cp $SOUND_PATH $FILE
|
cp $SOUND_PATH $FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#DEFINE PROCESSING FUNCTIONS
|
|
||||||
dcrawOpt() { #Find, develop, and splay raw DNG data as ppm, ready to be processed.
|
|
||||||
find "${TMP}" -maxdepth 1 -iname "*.dng" -print0 | sort -z | tr -d "\n" | xargs -0 \
|
|
||||||
$DCRAW -c -q $DEMO_MODE $FOUR_COLOR -k $BLACK_LEVEL $SATPOINT $BADPIXELS $WHITE -H $HIGHLIGHT_MODE -g $GAMMA $WAVE_NOISE -o $SPACE $DEPTH
|
|
||||||
} #Is prepared to pipe all the files in TMP outwards.
|
|
||||||
|
|
||||||
dcrawImg() { #Find and splay image sequence data as ppm, ready to be processed by ffmpeg. Not working well.
|
|
||||||
find "${SEQ}" -maxdepth 1 -iname "*.${IMG_FMT}" -print0 | sort -z | xargs -0 -I {} convert '{}' -set colorspace sRGB -colorspace RGB ppm:-
|
|
||||||
} #Finds all images, prints to stdout, without any operations, using convert. ppm conversion is inevitably slow, however...
|
|
||||||
|
|
||||||
mov_main() {
|
|
||||||
ffmpeg -f image2pipe -vcodec ppm -r $FPS -i pipe:0 \
|
|
||||||
-loglevel panic -stats $SOUND -vcodec prores_ks -pix_fmt rgb48be -n -r $FPS -profile:v 4444 -alpha_bits 0 -vendor ap4h $V_FILTERS $SOUND_ACTION "${VID}_hq.mov"
|
|
||||||
} #-loglevel panic -stats
|
|
||||||
|
|
||||||
mov_prox() {
|
|
||||||
ffmpeg -f image2pipe -vcodec ppm -r $FPS -i pipe:0 \
|
|
||||||
-loglevel panic -stats $SOUND -c:v libx264 -n -r $FPS -preset fast $V_FILTERS_PROX -crf 23 -c:a mp3 "${VID}_lq.mp4"
|
|
||||||
} #The option -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" fixes when x264 is unhappy about non-2 divisible dimensions.
|
|
||||||
|
|
||||||
mov_main_img() {
|
|
||||||
ffmpeg -start_number $FRAME_START -loglevel panic -stats -f image2 -i ${SEQ}/${TRUNC_ARG}_%06d.${IMG_FMT} $SOUND -vcodec prores_ks \
|
|
||||||
-pix_fmt rgb48le -n -r $FPS -profile:v 4444 -alpha_bits 0 -vendor ap4h $V_FILTERS $SOUND_ACTION "${VID}_hq.mov"
|
|
||||||
}
|
|
||||||
|
|
||||||
mov_prox_img() {
|
|
||||||
ffmpeg -start_number $FRAME_START -loglevel panic -stats -f image2 -i ${SEQ}/${TRUNC_ARG}_%06d.${IMG_FMT} $V_FILTERS_PROX $SOUND -c:v libx264 \
|
|
||||||
-n -r $FPS -preset veryfast -crf 21 -c:a mp3 -b:a 320k "${VID}_lq.mp4"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
runSim() {
|
|
||||||
# Command: cat $PIPE | cmd1 & cmdOrig | tee $PIPE | cmd2
|
|
||||||
|
|
||||||
# cat $PIPE | cmd1 - gives output of pipe live. Pipes it into cmd1. Nothing yet; just setup.
|
|
||||||
# & - runs the next part in the background.
|
|
||||||
# cmdOrig | tee $PIPE | cmd2 - cmdOrig pipes into the tee, which splits it back into the previous pipe, piping on to cmd2!
|
|
||||||
|
|
||||||
# End Result: Output of cmdOrig is piped into cmd1 and cmd2, which execute, both printing to stdout.
|
|
||||||
|
|
||||||
cmdOrig=$1
|
|
||||||
cmd1=$2
|
|
||||||
cmd2=$3
|
|
||||||
|
|
||||||
#~ echo $cmdOrig $cmd1 $cmd2
|
|
||||||
#~ echo $($cmdOrig)
|
|
||||||
|
|
||||||
PIPE="${TMP}/pipe_vid" # $(date +%s%N | cut -b1-13)"
|
|
||||||
mkfifo $PIPE 2>/dev/null
|
|
||||||
|
|
||||||
cat $PIPE | $cmd1 & $cmdOrig | tee $PIPE | $cmd2 #The magic of simultaneous execution ^_^
|
|
||||||
#~ cat $PIPE | tr 'e' 'a' & echo 'hello' | tee $PIPE | tr 'e' 'o' #The magic of simultaneous execution ^_^
|
|
||||||
}
|
|
||||||
|
|
||||||
img_par() { #Takes 22 arguments: {} 2$DEMO_MODE 3$FOUR_COLOR 4$BADPIXELS 5$WHITE 6$HIGHLIGHT_MODE 7$GAMMA 8$WAVE_NOISE 9$DEPTH 10$SEQ 11$TRUNC_ARG 12$IMG_FMT 13$FRAME_END 14$DEPTH_OUT 15$COMPRESS 16$isJPG 17$PROXY_SCALE 18$PROXY 19$BLACK_LEVEL 20$SPACE 21$SATPOINT 22$DCRAW 23$FFMPEG_FILTERS
|
|
||||||
count=$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) #Instead of count from file, count from name!
|
|
||||||
DCRAW=${22}
|
|
||||||
|
|
||||||
DPXHACK=""
|
|
||||||
if [[ ${12^^} == "DPX" && ( ${23} == false ) ]]; then DPXHACK="-colorspace sRGB"; else DPXHACK=""; fi
|
|
||||||
#Trust me, I've tried everything else; but this sRGB transform works. Must be an IM bug. Keep an eye on it!
|
|
||||||
#The sRGB curve is only applied if going to DPX while DPX is the target image format. Aka. At the end; not in the middle.
|
|
||||||
|
|
||||||
if [ ${16} == true ]; then
|
|
||||||
$DCRAW -c -q $2 $3 $4 $5 -H $6 -k ${19} ${21} -g $7 $8 -o ${20} $9 $1 | \
|
|
||||||
tee >(convert ${14} - -set colorspace RGB ${DPXHACK} ${15} $(printf "${10}/${11}_%06d.${12}" ${count})) | \
|
|
||||||
convert - -set colorspace XYZ -quality 80 -colorspace sRGB -resize ${17} $(printf "${18}/${11}_%06d.jpg" ${count})
|
|
||||||
#JPGs don't get ffmpeg filters applied. They simply can't handle it.
|
|
||||||
echo -e "\033[2K\rDNG to ${12^^}/JPG: Frame ${count^^}/${13}\c"
|
|
||||||
else
|
|
||||||
$DCRAW -c -q $2 $3 $4 $5 -H $6 -k ${19} ${21} -g $7 $8 -o ${20} $9 $1 | \
|
|
||||||
convert ${14} - -set colorspace RGB ${DPXHACK} ${15} $(printf "${10}/${11}_%06d.${12}" ${count})
|
|
||||||
echo -e "\033[2K\rDNG to ${12^^}: Frame ${count^^}/${13}\c"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
#~ See http://www.imagemagick.org/discourse-server/viewtopic.php?t=21161
|
|
||||||
|
|
||||||
export -f img_par
|
|
||||||
|
|
||||||
|
|
||||||
#PROCESSING
|
#PROCESSING
|
||||||
|
|
||||||
#IMAGE PROCESSING
|
#IMAGE PROCESSING
|
||||||
if [ $IMAGES == true ] ; then
|
if [ $IMAGES == true ] ; then
|
||||||
echo -e "\033[1m${TRUNC_ARG}:\033[0m Processing Image Sequence from Frame ${FRAME_START} to ${FRAME_END}...\n"
|
echo -e "$(bold ${TRUNC_ARG}:) Processing Image Sequence from Frame ${FRAME_START} to ${FRAME_END}...\n"
|
||||||
|
|
||||||
#Define Image Directories, Create SEQ directory
|
#Define Image Directories, Create SEQ directory
|
||||||
SEQ="${FILE}/${IMG_FMT}_${TRUNC_ARG}"
|
local SEQ="${FILE}/${IMG_FMT}_${TRUNC_ARG}"
|
||||||
PROXY="${FILE}/proxy_${TRUNC_ARG}"
|
local PROXY="${FILE}/proxy_${TRUNC_ARG}"
|
||||||
|
|
||||||
mkdirS $SEQ
|
mkdirS $SEQ; if [ $? -eq 1 ]; then return 1; fi
|
||||||
|
|
||||||
if [ $isJPG == true ]; then
|
if [ $isJPG == true ]; then
|
||||||
mkdirS $PROXY
|
mkdirS $PROXY; if [ $? -eq 1 ]; then return 1; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Define hardcoded compression based on IMG_FMT
|
#Run the parallel image processing
|
||||||
if [ $isCOMPRESS == true ]; then
|
iProc
|
||||||
if [ $IMG_FMT == "exr" ]; then
|
|
||||||
COMPRESS="-compress piz"
|
|
||||||
elif [ $IMG_FMT == "tiff" ]; then
|
|
||||||
COMPRESS="-compress zip"
|
|
||||||
elif [ $IMG_FMT == "png" ]; then
|
|
||||||
COMPRESS="-quality 0"
|
|
||||||
elif [ $IMG_FMT == "dpx" ]; then
|
|
||||||
COMPRESS="-compress rle"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Convert all the actual DNGs to IMG_FMT, in parallel.
|
|
||||||
find "${TMP}" -maxdepth 1 -name '*.dng' -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 \
|
|
||||||
bash -c "img_par '{}' '$DEMO_MODE' '$FOUR_COLOR' '$BADPIXELS' '$WHITE' '$HIGHLIGHT_MODE' '$GAMMA' '$WAVE_NOISE' '$DEPTH' \
|
|
||||||
'$SEQ' '$TRUNC_ARG' '$IMG_FMT' '$FRAME_END' '$DEPTH_OUT' '$COMPRESS' '$isJPG' '$PROXY_SCALE' '$PROXY' '$BLACK_LEVEL' '$SPACE' '$SATPOINT' '$DCRAW' '$FFMPEG_FILTERS'"
|
|
||||||
|
|
||||||
# Removed | cut -d '' -f $FRAME_RANGE , as this happens when creating the DNGs in the first place.
|
|
||||||
|
|
||||||
if [ $isJPG == true ]; then #Make it print "Frame $FRAMES / $FRAMES" as the last output :).
|
|
||||||
echo -e "\033[2K\rDNG to ${IMG_FMT^^}/JPG: Frame ${FRAME_END}/${FRAME_END}\c"
|
|
||||||
else
|
|
||||||
echo -e "\033[2K\rDNG to ${IMG_FMT^^}: Frame ${FRAME_END}/${FRAME_END}\c"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "\n"
|
|
||||||
|
|
||||||
tConvert() { #Arguments: 1$inFolder 2$outFolder 3$fromFMT 4$toFMT
|
|
||||||
inFolder=$1
|
|
||||||
outFolder=$2
|
|
||||||
fromFMT=$3
|
|
||||||
toFMT=$4
|
|
||||||
iccProf=$5
|
|
||||||
|
|
||||||
if [[ ! -z $iccProf ]]; then iccProf="+profile icm -profile $iccProf"; fi
|
|
||||||
|
|
||||||
conv_par() { # Arguments: 1${} 2$TRUNC_ARG 3$outFolder 4$fromFMT 5$iccProf 6$toFMT 7$DEPTH_OUT 8$compress 9$FRAME_END 10$IMG_FMT
|
|
||||||
count=$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) #Get count from filename.
|
|
||||||
|
|
||||||
echo -e "\033[2K\rMiddle-step: ${4^^} to ${6^^}, Frame ${count^^}/${9}\c"
|
|
||||||
|
|
||||||
DPXHACK=""
|
|
||||||
if [[ ${6^^} == "DPX" && ${10^^} == ${6^^} ]]; then DPXHACK="-colorspace sRGB"; else DPXHACK=""; fi
|
|
||||||
#Trust me, I've tried everything else; but this sRGB transform works. Must be an IM bug. Keep an eye on it!
|
|
||||||
#The sRGB curve is only applied if going to DPX while DPX is the target image format. Aka. At the end; not in the middle.
|
|
||||||
|
|
||||||
convert ${7} ${1} ${5} $8 -set colorspace RGB ${DPXHACK} "${3}/$(printf "${2}_%06d" ${count}).${6}"
|
|
||||||
}
|
|
||||||
|
|
||||||
export -f conv_par
|
|
||||||
|
|
||||||
compress=""
|
|
||||||
if [[ ${IMG_FMT^^} == ${toFMT^^} ]]; then compress=${COMPRESS}; fi
|
|
||||||
|
|
||||||
find $inFolder -iname "*.${fromFMT}" -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 \
|
|
||||||
bash -c "conv_par '{}' '$TRUNC_ARG' '$outFolder' '$fromFMT' '$iccProf' '$toFMT' '$DEPTH_OUT' '$compress' '$FRAME_END' '$IMG_FMT'"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
#FFMPEG Filter Application: Temporal Denoising, 3D LUTs, Deshake, hqdn Denoising, removegrain denoising, unsharp so far.
|
#FFMPEG Filter Application: Temporal Denoising, 3D LUTs, Deshake, hqdn Denoising, removegrain denoising, unsharp so far.
|
||||||
#See construction of $V_FILTERS in PREPARATION.
|
#See construction of $V_FILTERS in PREPARATION.
|
||||||
|
@ -684,18 +470,6 @@ develop() {
|
||||||
#Give correct output.
|
#Give correct output.
|
||||||
echo -e "\033[1mApplying Filters:\033[0m $(joinArgs ", " "${FILTER_ARR[@]}")...\n"
|
echo -e "\033[1mApplying Filters:\033[0m $(joinArgs ", " "${FILTER_ARR[@]}")...\n"
|
||||||
|
|
||||||
applyFilters() { #Ideally, this would be all we need. But alas, ffmpeg + exr is broken.
|
|
||||||
IO=$1
|
|
||||||
FMT=$2
|
|
||||||
|
|
||||||
if [[ -z $FMT ]]; then FMT="${IMG_FMT}"; fi
|
|
||||||
|
|
||||||
ffmpeg -start_number $FRAME_START -f image2 -i "${IO}/${TRUNC_ARG}_%06d.${FMT}" -loglevel panic -stats $V_FILTERS \
|
|
||||||
-pix_fmt rgb48be -start_number $FRAME_START "${tmpFiltered}/${TRUNC_ARG}_%06d.${FMT}"
|
|
||||||
|
|
||||||
tConvert "$tmpFiltered" "$IO" "$FMT" "$FMT" # "/home/sofus/subhome/src/convmlv/color/lin_xyz--srgb_srgb.icc" - profile application didn't work...
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ $IMG_FMT == "exr" ]]; then
|
if [[ $IMG_FMT == "exr" ]]; then
|
||||||
echo -e "Note: EXR filtering lags due to middle-step conversion (ffmpeg has no EXR encoder).\n"
|
echo -e "Note: EXR filtering lags due to middle-step conversion (ffmpeg has no EXR encoder).\n"
|
||||||
|
|
||||||
|
@ -769,7 +543,7 @@ develop() {
|
||||||
if [ $KEEP_DNGS == true ]; then
|
if [ $KEEP_DNGS == true ]; then
|
||||||
echo -e "\033[1mMoving DNGs...\033[0m"
|
echo -e "\033[1mMoving DNGs...\033[0m"
|
||||||
DNG="${FILE}/dng_${TRUNC_ARG}"
|
DNG="${FILE}/dng_${TRUNC_ARG}"
|
||||||
mkdirS $DNG
|
mkdirS $DNG; if [ $? -eq 1 ]; then return 1; fi
|
||||||
|
|
||||||
if [ $DUAL_ISO == true ]; then
|
if [ $DUAL_ISO == true ]; then
|
||||||
oldFiles="${TMP}/orig_dng"
|
oldFiles="${TMP}/orig_dng"
|
||||||
|
@ -783,26 +557,4 @@ develop() {
|
||||||
|
|
||||||
#Delete tmp
|
#Delete tmp
|
||||||
rm -rf $TMP
|
rm -rf $TMP
|
||||||
|
|
||||||
#RESET ARGS & REPARSE OPTIONS - same as in convmlv.sh.
|
|
||||||
#Big parse/reparse, making sure global, local, command line options all override each other correctly.
|
|
||||||
set -- $INPUT_ARGS #Reset the argument input for reparsing.
|
|
||||||
setDefaults #Hard set/reset all the lovely globals.
|
|
||||||
OPTIND=1 #Reset argument parsing.
|
|
||||||
|
|
||||||
parseConf "$GCONFIG" false #Parse global config file.
|
|
||||||
|
|
||||||
parseArgs "$@" #First, parse all cli args. We only need the -C flag, but that forces us to just parse everything.
|
|
||||||
shift $((OPTIND-1)) #Shift past all of the options to the file arguments.
|
|
||||||
|
|
||||||
parseConf "$LCONFIG" false #Parse local config file.
|
|
||||||
set -- $INPUT_ARGS #Reset $@ for cli option reparsing.
|
|
||||||
OPTIND=1 #To reset argument parsing, we must set OPTIND to 1.
|
|
||||||
|
|
||||||
parseArgs "$@" #Reparse cli to overwrite local config options.
|
|
||||||
shift $((OPTIND-1)) #Shift past all of the options to the file arguments.
|
|
||||||
OPTIND=1 #Reset argument index.
|
|
||||||
|
|
||||||
let ARGNUM--
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: All config and command line parsing happens here.
|
||||||
|
|
||||||
parseConf() {
|
parseConf() {
|
||||||
file=$1 #The File to Parse
|
file=$1 #The File to Parse
|
||||||
|
|
|
@ -0,0 +1,247 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: The bulk image processing operations; from dcraw, to ffmpeg, to parallel functions.
|
||||||
|
|
||||||
|
dcrawOpt() {
|
||||||
|
#usage: dcrawOpt | >>ppm data
|
||||||
|
#desc: Find, develop, and splay raw DNG data as ppm, ready to be processed.
|
||||||
|
|
||||||
|
find "${TMP}" -maxdepth 1 -iname "*.dng" -print0 | sort -z | tr -d "\n" | xargs -0 \
|
||||||
|
$DCRAW -c -q $DEMO_MODE $FOUR_COLOR -k $BLACK_LEVEL $SATPOINT $BADPIXELS $WHITE -H $HIGHLIGHT_MODE -g $GAMMA $WAVE_NOISE -o $SPACE $DEPTH
|
||||||
|
} #Is prepared to pipe all the files in TMP outwards.
|
||||||
|
|
||||||
|
dcrawImg() { #
|
||||||
|
#usage: dcrawImg | >>ppm data
|
||||||
|
#desc: Find and splay image sequence data as ppm, ready to be processed by ffmpeg.
|
||||||
|
#note: Not working well. IM has trouble keeping itself linear. Kinda slow b/c ppm conversion, even if it worked...
|
||||||
|
|
||||||
|
find "${SEQ}" -maxdepth 1 -iname "*.${IMG_FMT}" -print0 | sort -z | xargs -0 -I {} convert '{}' -set colorspace sRGB -colorspace RGB ppm:-
|
||||||
|
} #Finds all images, prints to stdout, without any operations, using convert. ppm conversion is inevitably slow, however...
|
||||||
|
|
||||||
|
mov_main() {
|
||||||
|
#usage: >>ppm data | mov_main
|
||||||
|
#desc: Creates the primary, high quality movie MOV file from input ppm data.
|
||||||
|
|
||||||
|
ffmpeg -f image2pipe -vcodec ppm -r $FPS -i pipe:0 \
|
||||||
|
-loglevel panic -stats $SOUND -vcodec prores_ks -pix_fmt rgb48be -n -r $FPS -profile:v 4444 -alpha_bits 0 -vendor ap4h $V_FILTERS $SOUND_ACTION "${VID}_hq.mov"
|
||||||
|
} #-loglevel panic -stats
|
||||||
|
|
||||||
|
mov_prox() {
|
||||||
|
#usage: >>ppm data | mov_prox
|
||||||
|
#desc: Creates the lower quality movie MP4 file from input ppm data.
|
||||||
|
|
||||||
|
ffmpeg -f image2pipe -vcodec ppm -r $FPS -i pipe:0 \
|
||||||
|
-loglevel panic -stats $SOUND -c:v libx264 -n -r $FPS -preset fast $V_FILTERS_PROX -crf 23 -c:a mp3 "${VID}_lq.mp4"
|
||||||
|
} #The option -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" fixes when x264 is unhappy about non-2 divisible dimensions.
|
||||||
|
|
||||||
|
mov_main_img() {
|
||||||
|
#usage: mov_main_img
|
||||||
|
#desc: Creates the primary, high quality movie MOV file from the image sequence.
|
||||||
|
|
||||||
|
ffmpeg -start_number $FRAME_START -loglevel panic -stats -f image2 -i ${SEQ}/${TRUNC_ARG}_%06d.${IMG_FMT} $SOUND -vcodec prores_ks \
|
||||||
|
-pix_fmt rgb48le -n -r $FPS -profile:v 4444 -alpha_bits 0 -vendor ap4h $V_FILTERS $SOUND_ACTION "${VID}_hq.mov"
|
||||||
|
}
|
||||||
|
|
||||||
|
mov_prox_img() {
|
||||||
|
#usage: mov_prox_img
|
||||||
|
#desc: Creates the lower quality movie MP4 file from the image sequence.
|
||||||
|
|
||||||
|
ffmpeg -start_number $FRAME_START -loglevel panic -stats -f image2 -i ${SEQ}/${TRUNC_ARG}_%06d.${IMG_FMT} $V_FILTERS_PROX $SOUND -c:v libx264 \
|
||||||
|
-n -r $FPS -preset veryfast -crf 21 -c:a mp3 -b:a 320k "${VID}_lq.mp4"
|
||||||
|
}
|
||||||
|
|
||||||
|
#PARALLEL FUNCTIONS
|
||||||
|
|
||||||
|
dng_par() {
|
||||||
|
#usage: dng_par 1${} (frame range) 2$MLV_DUMP 3$REAL_MLV 4$DARK_PROC 5$no_data 6$smooth 7$TMP 8$FRAME_END 9$TRUNC_ARG 10$FRAME_START
|
||||||
|
#arglength: Takes 10 args.
|
||||||
|
#desc: Called by xargs; is capable of dumping DNGs with the mlv_dump backend in parallel by being run in a subshell.
|
||||||
|
#note: Unfortunately, this means the entire relevant environment needs to be passed along too.
|
||||||
|
|
||||||
|
range=$1
|
||||||
|
firstFrame=false
|
||||||
|
if [[ $range == "0-0" ]]; then #mlv_dump can't handle 0-0, so we develop 0-1.
|
||||||
|
range="0-1"
|
||||||
|
firstFrame=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmpOut=${7}/${range} #Each output will number from 0, so give each its own folder.
|
||||||
|
mkdir -p $tmpOut
|
||||||
|
|
||||||
|
start=$(echo "$range" | cut -d'-' -f1)
|
||||||
|
end=$(echo "$range" | cut -d'-' -f2) #Get start and end frames from the frame range
|
||||||
|
|
||||||
|
$2 $3 $4 -o "${tmpOut}/${9}_" -f ${range} $6 --dng --batch | { #mlv_dump command. Uses frame range.
|
||||||
|
lastCur=0
|
||||||
|
while IFS= read -r line; do
|
||||||
|
output=$(echo $line | grep -Po 'V.*A' | cut -d':' -f2 | cut -d$' ' -f1) #Hacked my way to the important bit.
|
||||||
|
if [[ $output == "" ]]; then continue; fi #If there's no important bit, don't print.
|
||||||
|
|
||||||
|
cur=$(echo "$output" | cut -d'/' -f1) #Current frame.
|
||||||
|
if [[ $cur == $lastCur ]] || [[ $cur -gt $end ]] || [[ $cur -lt $start ]]; then continue; fi #Turns out, it goes through all the frames, even if cutting the frame range. So, clamp it!
|
||||||
|
|
||||||
|
lastCur=$cur #It likes to repeat itself.
|
||||||
|
echo -e "\033[2K\rMLV to DNG: Frame $(echo "${cur} + ${10}" | bc)/${8}\c" #Print out beautiful progress bar, in parallel!
|
||||||
|
done
|
||||||
|
|
||||||
|
} #Progress Bar
|
||||||
|
if [[ $firstFrame == true ]]; then #If 0-0.
|
||||||
|
rm $(printf "${tmpOut}/${9}_%06d.dng" 1) 2>/dev/null #Remove frame #1, leaving us only with frame #0.
|
||||||
|
mv $tmpOut "${7}/0-0" #Move back to 0-0, as if that's how it was developed all along.
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f dng_par #Export to run in subshell.
|
||||||
|
|
||||||
|
iso_par() {
|
||||||
|
#usage: inc_iso 1${} 2$CR_HDR 3$TMP 4$FRAME_END 5$oldFiles 6$CHROMA_SMOOTH.
|
||||||
|
#arglength: Takes 6 args.
|
||||||
|
#desc: Called by xargs; is capable of processing Dual ISO DNGs in parallel by being run in a subshell.
|
||||||
|
#note: Progress bar is thread safe. Experiment gone right :).
|
||||||
|
#note: Unfortunately, this means the entire relevant environment needs to be passed along too.
|
||||||
|
|
||||||
|
count=$(echo "$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) + 1" | bc) #Get count from filename.
|
||||||
|
|
||||||
|
$2 $1 $6 >/dev/null 2>/dev/null #The LQ option, --mean23, is completely unusable in my opinion.
|
||||||
|
|
||||||
|
name=$(basename "$1")
|
||||||
|
mv "${3}/${name%.*}.dng" $5 #Move away original dngs.
|
||||||
|
mv "${3}/${name%.*}.DNG" "${3}/${name%.*}.dng" #Rename *.DNG to *.dng.
|
||||||
|
|
||||||
|
echo -e "\033[2K\rDual ISO Development: Frame ${count}/${4}\c"
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f iso_par #Must expose function to subprocess.
|
||||||
|
|
||||||
|
img_par() {
|
||||||
|
#usage: img_par 1${} 2$DEMO_MODE 3$FOUR_COLOR 4$BADPIXELS 5$WHITE 6$HIGHLIGHT_MODE 7$GAMMA 8$WAVE_NOISE 9$DEPTH 10$SEQ 11$TRUNC_ARG 12$IMG_FMT 13$FRAME_END 14$DEPTH_OUT 15$COMPRESS 16$isJPG 17$PROXY_SCALE 18$PROXY 19$BLACK_LEVEL 20$SPACE 21$SATPOINT 22$DCRAW 23$FFMPEG_FILTERS
|
||||||
|
#arglength: Takes 22 arguments.
|
||||||
|
#desc: Called by xargs; is capable of developing images in parallel by being run in a subshell.
|
||||||
|
#note: Unfortunately, this means the entire relevantenvironment needs to be passed along too.
|
||||||
|
|
||||||
|
count=$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) #Instead of count from file, count from name!
|
||||||
|
DCRAW=${22}
|
||||||
|
|
||||||
|
DPXHACK=""
|
||||||
|
if [[ ${12^^} == "DPX" && ( ${23} == false ) ]]; then DPXHACK="-colorspace sRGB"; else DPXHACK=""; fi
|
||||||
|
#Trust me, I've tried everything else; but this sRGB transform works. Must be an IM bug. Keep an eye on it!
|
||||||
|
#The sRGB curve is only applied if going to DPX while DPX is the target image format. Aka. At the end; not in the middle.
|
||||||
|
|
||||||
|
if [ ${16} == true ]; then
|
||||||
|
$DCRAW -c -q $2 $3 $4 $5 -H $6 -k ${19} ${21} -g $7 $8 -o ${20} $9 $1 | \
|
||||||
|
tee >(convert ${14} - -set colorspace RGB ${DPXHACK} ${15} $(printf "${10}/${11}_%06d.${12}" ${count})) | \
|
||||||
|
convert - -set colorspace XYZ -quality 80 -colorspace sRGB -resize ${17} $(printf "${18}/${11}_%06d.jpg" ${count})
|
||||||
|
#JPGs don't get ffmpeg filters applied. They simply can't handle it.
|
||||||
|
echo -e "\033[2K\rDNG to ${12^^}/JPG: Frame ${count^^}/${13}\c"
|
||||||
|
else
|
||||||
|
$DCRAW -c -q $2 $3 $4 $5 -H $6 -k ${19} ${21} -g $7 $8 -o ${20} $9 $1 | \
|
||||||
|
convert ${14} - -set colorspace RGB ${DPXHACK} ${15} $(printf "${10}/${11}_%06d.${12}" ${count})
|
||||||
|
echo -e "\033[2K\rDNG to ${12^^}: Frame ${count^^}/${13}\c"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f img_par #Need to export the function for it to be used in child functions.
|
||||||
|
|
||||||
|
#~ See http://www.imagemagick.org/discourse-server/viewtopic.php?t=21161
|
||||||
|
|
||||||
|
|
||||||
|
conv_par() {
|
||||||
|
#usage: conv_par 1${} 2$TRUNC_ARG 3$outFolder 4$fromFMT 5$iccProf 6$toFMT 7$DEPTH_OUT 8$compress 9$FRAME_END 10$IMG_FMT
|
||||||
|
#arglength: Takes 10 arguments.
|
||||||
|
#desc: Called by xargs; is capable of converting images in parallel by being run in a subshell. Automatically applies the DPX hack.
|
||||||
|
#note: Unfortunately, this means the entire relevant environment needs to be passed along too.
|
||||||
|
|
||||||
|
count=$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) #Get count from filename.
|
||||||
|
|
||||||
|
echo -e "\033[2K\rMiddle-step: ${4^^} to ${6^^}, Frame ${count^^}/${9}\c"
|
||||||
|
|
||||||
|
DPXHACK=""
|
||||||
|
if [[ ${6^^} == "DPX" && ${10^^} == ${6^^} ]]; then DPXHACK="-colorspace sRGB"; else DPXHACK=""; fi
|
||||||
|
#Trust me, I've tried everything else; but this sRGB transform works. Must be an IM bug. Keep an eye on it!
|
||||||
|
#The sRGB curve is only applied if going to DPX while DPX is the target image format. Aka. At the end; not in the middle.
|
||||||
|
|
||||||
|
convert ${7} ${1} ${5} $8 -set colorspace RGB ${DPXHACK} "${3}/$(printf "${2}_%06d" ${count}).${6}"
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f conv_par
|
||||||
|
|
||||||
|
|
||||||
|
#PRACTICAL PARALLEL FUNCTIONS
|
||||||
|
|
||||||
|
iProc() {
|
||||||
|
#usage: iProc
|
||||||
|
#desc: Develop the sequence from the current global settings.
|
||||||
|
|
||||||
|
#Define hardcoded compression based on IMG_FMT
|
||||||
|
local COMPRESS=""
|
||||||
|
if [ $isCOMPRESS == true ]; then
|
||||||
|
case ${IMG_FMT} in
|
||||||
|
exr)
|
||||||
|
COMPRESS="-compress piz"
|
||||||
|
;;
|
||||||
|
tiff)
|
||||||
|
COMPRESS="-compress zip"
|
||||||
|
;;
|
||||||
|
png)
|
||||||
|
COMPRESS="-quality 0"
|
||||||
|
;;
|
||||||
|
dpx)
|
||||||
|
COMPRESS="-compress rle"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Convert all the actual DNGs to IMG_FMT, in parallel.
|
||||||
|
find "${TMP}" -maxdepth 1 -name '*.dng' -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 \
|
||||||
|
bash -c "img_par '{}' '$DEMO_MODE' '$FOUR_COLOR' '$BADPIXELS' '$WHITE' '$HIGHLIGHT_MODE' '$GAMMA' '$WAVE_NOISE' '$DEPTH' \
|
||||||
|
'$SEQ' '$TRUNC_ARG' '$IMG_FMT' '$FRAME_END' '$DEPTH_OUT' '$COMPRESS' '$isJPG' '$PROXY_SCALE' '$PROXY' '$BLACK_LEVEL' '$SPACE' '$SATPOINT' '$DCRAW' '$FFMPEG_FILTERS'"
|
||||||
|
|
||||||
|
# Removed | cut -d '' -f $FRAME_RANGE , as this happens when creating the DNGs in the first place.
|
||||||
|
|
||||||
|
if [ $isJPG == true ]; then #Make it print "Frame $FRAMES / $FRAMES" as the last output.
|
||||||
|
echo -e "\033[2K\rDNG to ${IMG_FMT^^}/JPG: Frame ${FRAME_END}/${FRAME_END}\c"
|
||||||
|
else
|
||||||
|
echo -e "\033[2K\rDNG to ${IMG_FMT^^}: Frame ${FRAME_END}/${FRAME_END}\c"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
tConvert() {
|
||||||
|
#usage: tConvert 1$inFolder 2$outFolder 3$fromFMT 4$toFMT
|
||||||
|
#desc: Convert an image sequence from fromFMT to toFMT, with i/o inFolder and outFolder.
|
||||||
|
#note: optional icc profile. Wouldn't suggest using it right now...
|
||||||
|
|
||||||
|
inFolder=$1
|
||||||
|
outFolder=$2
|
||||||
|
fromFMT=$3
|
||||||
|
toFMT=$4
|
||||||
|
iccProf=$5
|
||||||
|
|
||||||
|
if [[ ! -z $iccProf ]]; then iccProf="+profile icm -profile $iccProf"; fi
|
||||||
|
|
||||||
|
compress=""
|
||||||
|
if [[ ${IMG_FMT^^} == ${toFMT^^} ]]; then compress=${COMPRESS}; fi
|
||||||
|
|
||||||
|
find $inFolder -iname "*.${fromFMT}" -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 \
|
||||||
|
bash -c "conv_par '{}' '$TRUNC_ARG' '$outFolder' '$fromFMT' '$iccProf' '$toFMT' '$DEPTH_OUT' '$compress' '$FRAME_END' '$IMG_FMT'"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
applyFilters() {
|
||||||
|
#usage: applyFilters IO <FMT>
|
||||||
|
#desc: Applies all ffmpeg filters to the given IO sequence of FMT format.
|
||||||
|
#note: If FMT isn't defined, IMG_FMT is automatically used.
|
||||||
|
#note: Ideally, this would be all we need. But alas, ffmpeg + exr is broken. So there's a custom middle step for that scenario.
|
||||||
|
|
||||||
|
IO=$1
|
||||||
|
FMT=$2
|
||||||
|
|
||||||
|
if [[ -z $FMT ]]; then FMT="${IMG_FMT}"; fi
|
||||||
|
|
||||||
|
ffmpeg -start_number $FRAME_START -f image2 -i "${IO}/${TRUNC_ARG}_%06d.${FMT}" -loglevel panic -stats $V_FILTERS \
|
||||||
|
-pix_fmt rgb48be -start_number $FRAME_START "${tmpFiltered}/${TRUNC_ARG}_%06d.${FMT}"
|
||||||
|
|
||||||
|
tConvert "$tmpFiltered" "$IO" "$FMT" "$FMT" # "/home/sofus/subhome/src/convmlv/color/lin_xyz--srgb_srgb.icc" - profile application didn't work...
|
||||||
|
}
|
|
@ -1,3 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: Kinda standalone TODO list.
|
||||||
|
|
||||||
less -R << EOF
|
less -R << EOF
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: The help function lives here, as well as helper functions thereof.
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
less -R << EOF
|
less -R << EOF
|
||||||
Usage:
|
Usage:
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: Error checking and consequence functions.
|
||||||
|
|
||||||
invOption() {
|
invOption() {
|
||||||
str=$1
|
str=$1
|
||||||
|
@ -13,50 +16,55 @@ invOption() {
|
||||||
}
|
}
|
||||||
|
|
||||||
checkArg() {
|
checkArg() {
|
||||||
#stderr is for printing; stdout is for return values.
|
#usage: checkArg arg
|
||||||
|
#desc: Checks the argument to see if it's a valid MLV, RAW, or DNG sequence.
|
||||||
|
#return: 'false' if not valid, 'true' if it is.
|
||||||
|
#print (stderr): Error stuff.
|
||||||
|
|
||||||
argBase="$(basename "$ARG")"
|
local arg="$1"
|
||||||
argExt="${argBase##*.}"
|
|
||||||
argTrunc="${argBase%.*}"
|
local argBase="$(basename "$arg")"
|
||||||
|
local argExt="${argBase##*.}"
|
||||||
|
local argTrunc="${argBase%.*}"
|
||||||
local cont
|
local cont
|
||||||
|
|
||||||
#Argument Checks
|
#Argument Checks
|
||||||
if [ ! -f $ARG ] && [ ! -d $ARG ]; then
|
if [ ! -f $arg ] && [ ! -d $arg ]; then
|
||||||
nFound "File" "${ARG}" "Skipping File"
|
nFound "File" "${arg}" "Skipping File"
|
||||||
echo "skip" >&1; return
|
echo "false" >&1; return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d $ARG && ! ( $argExt == "MLV" || $argExt == "mlv" || $argExt == "RAW" || $argExt == "raw" ) ]]; then
|
if [[ ! -d $arg && ! ( $argExt == "MLV" || $argExt == "mlv" || $argExt == "RAW" || $argExt == "raw" ) ]]; then
|
||||||
echo -e "\033[0;31m\033[1mFile ${ARG} has invalid extension!\033[0m\n" >&2
|
error "File ${arg} has invalid extension!\n" >&2
|
||||||
echo "skip" >&1; return
|
echo "false" >&1; return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ( ( ! -f $ARG ) && $(ls -1 ${ARG%/}/*.[Dd][Nn][Gg] 2>/dev/null | wc -l) == 0 ) && ( `folderName ${ARG}` != $argTrunc ) ]]; then
|
if [[ ( ( ! -f $arg ) && $(ls -1 ${arg%/}/*.[Dd][Nn][Gg] 2>/dev/null | wc -l) == 0 ) && ( `folderName ${arg}` != $argTrunc ) ]]; then
|
||||||
echo -e "\033[0;31m\033[1mFolder ${ARG} contains no DNG files!\033[0m\n" >&2
|
error "Folder ${arg} contains no DNG files!" >&2
|
||||||
echo "skip" >&1; return
|
echo "false" >&1; return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $ARG ] && [[ $(echo $(wc -c ${ARG} | xargs | cut -d " " -f1) / 1000 | bc) -lt 1000 ]]; then #Check that the file is not too small.
|
if [ ! -d $arg ] && [[ $(echo $(wc -c ${arg} | xargs | cut -d " " -f1) / 1000 | bc) -lt 1000 ]]; then #Check that the file is not too small.
|
||||||
cont=false
|
cont=false
|
||||||
while true; do
|
while true; do
|
||||||
#xargs easily trims the cut statement, which has a leading whitespace on Mac.
|
#xargs easily trims the cut statement, which has a leading whitespace on Mac.
|
||||||
read -p "${ARG} is unusually small at $(echo "$(echo "$(wc -c ${ARG})" | xargs | cut -d$' ' -f1) / 1000" | bc)KB. Continue, skip, remove, or quit? [c/s/r/q] " csr
|
read -p "${arg} is unusually small at $(echo "$(echo "$(wc -c ${arg})" | xargs | cut -d$' ' -f1) / 1000" | bc)KB. Continue, skip, remove, or quit? [c/s/r/q] " csr
|
||||||
case $csr in
|
case $csr in
|
||||||
[Cc]* ) "\n\033[0;31m\033[1mContinuing.\033[0m\n"; break
|
[Cc]* ) error "\nContinuing.\n"; break
|
||||||
;;
|
;;
|
||||||
[Ss]* ) echo -e "\n\033[0;31m\033[1mSkipping.\033[0m\n"; cont=true; break
|
[Ss]* ) error "\nSkipping.\n"; cont=true; break
|
||||||
;;
|
;;
|
||||||
[Rr]* ) echo -e "\n\033[0;31m\033[1mRemoving ${ARG}.\033[0m\n"; cont=true; rm $ARG; break
|
[Rr]* ) error "\nRemoving ${arg}.\n"; cont=true; rm $arg; break
|
||||||
;;
|
;;
|
||||||
[Qq]* ) echo -e "\n\033[0;31m\033[1mQuitting.\033[0m\n"; isExit=true; break
|
[Qq]* ) error "\nQuitting.\n"; isExit=true; break
|
||||||
;;
|
;;
|
||||||
* ) echo -e "\033[0;31m\033[1mPlease answer continue, skip, or remove.\033[0m\n"
|
* ) error "Please answer continue, skip, or remove.\n"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $cont == true ]; then
|
if [ $cont == true ]; then
|
||||||
echo "skip" >&1; return
|
echo "false" >&1; return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,39 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: Text formatting functions.
|
||||||
|
|
||||||
bold() {
|
bold() {
|
||||||
echo -e "\033[1m${1}\033[0m"
|
echo -e "\033[1m${1}\033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selected() {
|
||||||
|
echo -e "$(bold "\033[32m${1}\033[0m")"
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo -e "$(bold "\033[31m${1}\033[0m")"
|
||||||
|
}
|
||||||
|
|
||||||
|
formArg() {
|
||||||
|
#usage: formArg item selection
|
||||||
|
#desc: Formats ARG values prettily; param can be "selected" or "deselected".
|
||||||
|
#return: Formatted path.
|
||||||
|
local item="$1"
|
||||||
|
local selection="$2"
|
||||||
|
|
||||||
|
local itemBase=$(basename $item)
|
||||||
|
local itemExt=".${itemBase##*.}" #Dot must be in here.
|
||||||
|
if [[ "${itemExt}" == ".${itemBase}" ]]; then itemExt=""; fi #This means the input is a folder, which has no extension.
|
||||||
|
|
||||||
|
local itemDir=$(dirname "$item")
|
||||||
|
|
||||||
|
if [[ $selection == "selected" ]]; then
|
||||||
|
echo -e "${itemDir}/$(selected "${itemBase%.*}")${itemExt}"
|
||||||
|
elif [[ $selection == "deselected" ]]; then
|
||||||
|
echo -e "${itemDir}/$(bold ${itemBase%.*})${itemExt}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
cVal() {
|
cVal() {
|
||||||
#usage: cVal value
|
#usage: cVal value
|
||||||
#desc: Formats config file values, as bolded grey.
|
#desc: Formats config file values, as bolded grey.
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: Platform-specific functions.
|
||||||
|
|
||||||
getThreads() {
|
getThreads() {
|
||||||
local threads=4 #4 threads by default
|
local threads=4 #4 threads by default
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: Portable utility functions that could live in their own library.
|
||||||
|
|
||||||
nFound() { #Prints: ${type} ${name} not found! ${exec_instr}.\n\t${down_instr} to stderr.
|
nFound() { #Prints: ${type} ${name} not found! ${exec_instr}.\n\t${down_instr} to stderr.
|
||||||
type=$1
|
type=$1
|
||||||
name="$2"
|
name="$2"
|
||||||
|
@ -12,6 +16,11 @@ nFound() { #Prints: ${type} ${name} not found! ${exec_instr}.\n\t${down_instr} t
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdirS() {
|
mkdirS() {
|
||||||
|
#usage: mkdirS path; if [ $? -eq 1 ]; then return 1; fi
|
||||||
|
#desc: A function that allows the user to decide whether to overwrite an existing directory.
|
||||||
|
#note: The user must use return codes to provide the return from develop().
|
||||||
|
#return: Exit code 1 denotes that we must continue.
|
||||||
|
|
||||||
path=$1
|
path=$1
|
||||||
cleanup=$2
|
cleanup=$2
|
||||||
cont=false
|
cont=false
|
||||||
|
@ -22,11 +31,11 @@ mkdirS() {
|
||||||
case $ynq in
|
case $ynq in
|
||||||
[Yy]* ) echo -e ""; rm -rf $path; mkdir -p $path >/dev/null 2>/dev/null; break
|
[Yy]* ) echo -e ""; rm -rf $path; mkdir -p $path >/dev/null 2>/dev/null; break
|
||||||
;;
|
;;
|
||||||
[Nn]* ) echo -e "\n\033[0;31m\033[1mDirectory ${path} won't be created.\033[0m\n"; cont=true; `$cleanup`; break
|
[Nn]* ) error "\nDirectory ${path} won't be created.\n"; cont=true; `$cleanup`; break
|
||||||
;;
|
;;
|
||||||
[Qq]* ) echo -e "\n\033[0;31m\033[1mHalting execution. Directory ${path} won't be created.\033[0m\n"; `$cleanup`; exit 1;
|
[Qq]* ) error "\nHalting execution. Directory ${path} won't be created.\n"; `$cleanup`; exit 1;
|
||||||
;;
|
;;
|
||||||
* ) echo -e "\033[0;31m\033[1mPlease answer yes or no.\033[0m\n"
|
* ) error "Please answer yes or no, or quit.\n"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -35,8 +44,7 @@ mkdirS() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $cont == true ]; then
|
if [ $cont == true ]; then
|
||||||
let ARGNUM--
|
return 1
|
||||||
continue
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,3 +58,26 @@ joinArgs() {
|
||||||
#Joins the arguments of the input array using commas.
|
#Joins the arguments of the input array using commas.
|
||||||
local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"
|
local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runSim() {
|
||||||
|
# Command: cat $PIPE | cmd1 & cmdOrig | tee $PIPE | cmd2
|
||||||
|
|
||||||
|
# cat $PIPE | cmd1 - gives output of pipe live. Pipes it into cmd1. Nothing yet; just setup.
|
||||||
|
# & - runs the next part in the background.
|
||||||
|
# cmdOrig | tee $PIPE | cmd2 - cmdOrig pipes into the tee, which splits it back into the previous pipe, piping on to cmd2!
|
||||||
|
|
||||||
|
# End Result: Output of cmdOrig is piped into cmd1 and cmd2, which execute, both printing to stdout.
|
||||||
|
|
||||||
|
cmdOrig=$1
|
||||||
|
cmd1=$2
|
||||||
|
cmd2=$3
|
||||||
|
|
||||||
|
#~ echo $cmdOrig $cmd1 $cmd2
|
||||||
|
#~ echo $($cmdOrig)
|
||||||
|
|
||||||
|
PIPE="${TMP}/pipe_vid" # $(date +%s%N | cut -b1-13)"
|
||||||
|
mkfifo $PIPE 2>/dev/null
|
||||||
|
|
||||||
|
cat $PIPE | $cmd1 & $cmdOrig | tee $PIPE | $cmd2 #The magic of simultaneous execution ^_^
|
||||||
|
#~ cat $PIPE | tr 'e' 'a' & echo 'hello' | tee $PIPE | tr 'e' 'o' #The magic of simultaneous execution ^_^
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: Math for bash regarding image operations. So that we don't have to hop over to python!
|
||||||
|
|
||||||
|
normToOne() {
|
||||||
|
wBal=$1
|
||||||
|
|
||||||
|
max=0.0
|
||||||
|
for mult in $wBal; do
|
||||||
|
if [ $(echo " $mult > $max" | bc) -eq 1 ]; then
|
||||||
|
max=$mult
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for mult in $wBal; do
|
||||||
|
echo -e "$(echo "scale=6; x=${mult} / ${max}; if(x<1) print 0; x" | bc -l) \c" #BC is bae.
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
getGreen() {
|
||||||
|
wBal=$1
|
||||||
|
|
||||||
|
i=0
|
||||||
|
for mult in $wBal; do
|
||||||
|
if [ $i -eq 1 ]; then
|
||||||
|
echo -e "${mult}"
|
||||||
|
fi
|
||||||
|
let i++
|
||||||
|
done
|
||||||
|
}
|
|
@ -1,3 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: Calibration frame code.
|
||||||
|
|
||||||
mkDarkframe() {
|
mkDarkframe() {
|
||||||
echo -e "\n\033[1m\033[0;32m\033[1mAveraging Darkframe File\033[0m: ${ARG}"
|
echo -e "\n\033[1m\033[0;32m\033[1mAveraging Darkframe File\033[0m: ${ARG}"
|
||||||
$MLV_DUMP -o $DARK_OUT ${FILE_ARGS_ARRAY[0]} 2>/dev/null 1>/dev/null
|
$MLV_DUMP -o $DARK_OUT ${FILE_ARGS_ARRAY[0]} 2>/dev/null 1>/dev/null
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#desc: Functions dealing with getting and printing footage (ARG) settings.
|
||||||
|
|
||||||
prntSet() {
|
prntSet() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
$(bold CameraName): ${CAM_NAME}
|
$(bold CameraName): ${CAM_NAME}
|
||||||
|
@ -74,6 +78,23 @@ dngSet() { #Set as many options as the RAW spec will allow. Grey out the rest.
|
||||||
rm $dataDNG
|
rm $dataDNG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reuseSet() {
|
||||||
|
local dng_loc="$1"
|
||||||
|
|
||||||
|
FPS=`cat ${dng_loc}/../settings.txt | grep "FPS" | cut -d $" " -f2`
|
||||||
|
|
||||||
|
CAM_NAME=`cat ${dng_loc}/../settings.txt | grep "CameraName" | cut -d $" " -f2`
|
||||||
|
FRAMES=`cat ${dng_loc}/../settings.txt | grep "Frames" | cut -d $" " -f2` #Grab FRAMES from previous run.
|
||||||
|
RES_IN=`cat ${dng_loc}/../settings.txt | grep "Resolution" | cut -d $" " -f2`
|
||||||
|
ISO=`cat ${dng_loc}/../settings.txt | grep "ISO" | cut -d $" " -f2`
|
||||||
|
APERTURE=`cat ${dng_loc}/../settings.txt | grep "Aperture" | cut -d $" " -f2`
|
||||||
|
LEN_FOCAL=`cat ${dng_loc}/../settings.txt | grep "FocalLength" | cut -d $" " -f2`
|
||||||
|
SHUTTER=`cat ${dng_loc}/../settings.txt | grep "ShutterSpeed" | cut -d $" " -f2`
|
||||||
|
REC_DATE=`cat ${dng_loc}/../settings.txt | grep "RecordingDate" | cut -d $" " -f2`
|
||||||
|
REC_TIME=`cat ${dng_loc}/../settings.txt | grep "RecordingTime" | cut -d $" " -f2`
|
||||||
|
KELVIN=`cat ${dng_loc}/../settings.txt | grep "WBKelvin" | cut -d $" " -f2`
|
||||||
|
}
|
||||||
|
|
||||||
printFileSettings() {
|
printFileSettings() {
|
||||||
ARG="${FILE_ARGS_ARRAY[0]}"
|
ARG="${FILE_ARGS_ARRAY[0]}"
|
||||||
checkArg
|
checkArg
|
||||||
|
|
Loading…
Reference in New Issue