Camera WB is not default. Can specify frame range to process. Chroma smoothing now works with Dual ISO footage.

* Can reuse DNGs from previous run; used to speedup settings changes.
  * Semi-interactive usage is now possible due to fast, targeted redevelopment (specify a frame range)!
modularize
Sofus Albert Høgsbro Rose 2016-04-13 09:47:22 -04:00
parent f560d8f9c6
commit 5e061a4d73
2 changed files with 179 additions and 96 deletions

View File

@ -17,7 +17,7 @@ INFO:
A script allowing you to convert .MLV, .RAW, or a folder with a DNG sequence into a sequence/movie with optional proxies. Images A script allowing you to convert .MLV, .RAW, or a folder with a DNG sequence into a sequence/movie with optional proxies. Images
are auto compressed. Many useful options are exposed, including formats (EXR by default). are auto compressed. Many useful options are exposed, including formats (EXR by default).
VERSION: 1.8.0 VERSION: 1.8.1
DEPENDENCIES: If you don't use a feature, you don't need the dependency, though it's best to download them all. DEPENDENCIES: If you don't use a feature, you don't need the dependency, though it's best to download them all.
-mlv_dump: For DNG extraction from MLV. http://www.magiclantern.fm/forum/index.php?topic=7122.0 -mlv_dump: For DNG extraction from MLV. http://www.magiclantern.fm/forum/index.php?topic=7122.0
@ -61,7 +61,12 @@ OPTIONS, OUTPUT:
--> Use -s<percentage>% (no space). 50% is default. --> Use -s<percentage>% (no space). 50% is default.
-k KEEP_DNGS - Specify if you want to keep the DNG files. -k KEEP_DNGS - Specify if you want to keep the DNG files.
--> Besides testing, this makes the script a glorified mlv_dump... --> If you run convmlv on the dng_<name> folder, you will reuse those DNGs - no need to redevelop!
-E<range> FRAME_RANGE - Specify to process only this frame range.
--> DNGs will still all be generated. Use -k to reuse a previous iteration to get past this!
--> <range> must be written as <start>-<end>, indexed from 0 to (# of frames - 1).
--> If you write a single number, only that frame will be developed.
OPTIONS, RAW DEVELOPMENT: OPTIONS, RAW DEVELOPMENT:

View File

@ -28,7 +28,7 @@
#~ SOFTWARE. #~ SOFTWARE.
#BASIC VARS #BASIC VARS
VERSION="1.8.0" #Version string. VERSION="1.8.1" #Version string.
THREADS=8 THREADS=8
#DEPENDENCIES #DEPENDENCIES
@ -58,6 +58,12 @@ isJPG=false
isH264=false isH264=false
KEEP_DNGS=false KEEP_DNGS=false
#FRAME RANGE
FRAME_RANGE="" #UPDATED LATER WHEN FRAME # IS AVAILABLE.
FRAME_START="1"
FRAME_END=""
isFR=true
#RAW DEVELOPOMENT #RAW DEVELOPOMENT
HIGHLIGHT_MODE="0" HIGHLIGHT_MODE="0"
PROXY_SCALE="75%" PROXY_SCALE="75%"
@ -80,8 +86,8 @@ SETTINGS_OUTPUT=false
#White Balance #White Balance
WHITE="" WHITE=""
GEN_WHITE=true GEN_WHITE=false
CAMERA_WB=false CAMERA_WB=true
WHITE_SPD=15 WHITE_SPD=15
#LUT #LUT
@ -141,7 +147,12 @@ OPTIONS, OUTPUT:
--> Use -s<percentage>% (no space). 50% is default. --> Use -s<percentage>% (no space). 50% is default.
-k KEEP_DNGS - Specify if you want to keep the DNG files. -k KEEP_DNGS - Specify if you want to keep the DNG files.
--> Besides testing, this makes the script a glorified mlv_dump... --> If you run convmlv on the dng_<name> folder, you will reuse those DNGs - no need to redevelop!
-E<range> FRAME_RANGE - Specify to process only this frame range.
--> DNGs will still all be generated. Use -k to reuse a previous iteration to get past this!
--> <range> must be written as <start>-<end>, indexed from 0 to (# of frames - 1).
--> If you write a single number, only that frame will be developed.
OPTIONS, RAW DEVELOPMENT: OPTIONS, RAW DEVELOPMENT:
@ -216,6 +227,7 @@ EOF
mkdirS() { mkdirS() {
path=$1 path=$1
cleanup=$2
cont=false cont=false
if [ -d $path ]; then if [ -d $path ]; then
@ -224,7 +236,7 @@ mkdirS() {
case $yn in case $yn 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\e[0;31m\e[1mDirectory ${path} won't be created.\e[0m\n"; cont=true; break [Nn]* ) echo -e "\n\e[0;31m\e[1mDirectory ${path} won't be created.\e[0m\n"; cont=true; `$cleanup`; break
;; ;;
* ) echo -e "\e[0;31m\e[1mPlease answer yes or no.\e[0m\n" * ) echo -e "\e[0;31m\e[1mPlease answer yes or no.\e[0m\n"
;; ;;
@ -267,6 +279,14 @@ parseArgs() { #Fixing this would be difficult.
DUAL_ISO=true DUAL_ISO=true
let ARGNUM-- let ARGNUM--
fi fi
if [ `echo ${ARG} | cut -c2-2` = "E" ]; then
base=$(echo ${ARG} | cut -c3-${#ARG})
FRAME_RANGE="$(echo "$(echo $base | cut -d"-" -f1) + 1" | bc)-$(echo "$(echo $base | cut -d"-" -f2) + 1" | bc)"
FRAME_START=$(echo ${FRAME_RANGE} | cut -d"-" -f1)
FRAME_END=$(echo ${FRAME_RANGE} | cut -d"-" -f2)
isFR=false
let ARGNUM--
fi
if [ `echo ${ARG} | cut -c2-2` = "F" ]; then if [ `echo ${ARG} | cut -c2-2` = "F" ]; then
DARKFRAME=`echo ${ARG} | cut -c3-${#ARG}` DARKFRAME=`echo ${ARG} | cut -c3-${#ARG}`
let ARGNUM-- let ARGNUM--
@ -402,7 +422,7 @@ parseArgs() { #Fixing this would be difficult.
;; ;;
"1") CAMERA_WB=true; GEN_WHITE=false; "1") CAMERA_WB=true; GEN_WHITE=false;
;; ;;
"2") WHITE="-r 1 1 1 1"; CAMERA_WB=true; GEN_WHITE=false "2") WHITE="-r 1 1 1 1"; CAMERA_WB=false; GEN_WHITE=false
;; ;;
esac esac
@ -457,7 +477,7 @@ checkDeps() {
exit 1 exit 1
fi fi
if [ $(echo $(wc -c ${ARG} | cut -d " " -f1) / 1000 | bc) -lt 1000 ] && [ ! -d $ARG ]; then #Check that the file is not too small. if [ ! -d $ARG ] && [ $(echo $(wc -c ${ARG} | 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
read -p "${ARG} is unusually small at $(wc -c ${ARG})KB. Continue, skip, or remove? [c/s/r] " csr read -p "${ARG} is unusually small at $(wc -c ${ARG})KB. Continue, skip, or remove? [c/s/r] " csr
@ -569,14 +589,121 @@ for ARG in $*; do
fi fi
FILE="${OUTDIR}/${TRUNC_ARG}" FILE="${OUTDIR}/${TRUNC_ARG}"
TMP="${FILE}/tmp_${TRUNC_ARG}" TMP="${FILE}/tmp_${TRUNC_ARG}"
#Manage DNG argument/Create FILE and TMP.
DEVELOP=true
if [ -d $ARG ] && [ `basename ${ARG} | cut -c1-3` == "dng" ] && [ -f "${ARG}/../settings.txt" ]; then #If we're reusing a dng sequence, copy over before we delete the original.
echo -e "\e[1m${TRUNC_ARG}:\e[0m Moving DNGs from previous run...\n" #Use prespecified DNG sequence.
DNG_LOC=${OUTDIR}/tmp_reused
mkdir -p ${OUTDIR}/tmp_reused
find $ARG -iname "*.dng" | xargs -I {} mv {} $DNG_LOC #Copying DNGs to temporary location.
FPS=`cat ${ARG}/../settings.txt | grep "FPS" | cut -d $" " -f2` #Grab FPS from previous run.
FRAMES=`cat ${ARG}/../settings.txt | grep "Frames" | cut -d $" " -f2` #Grab FRAMES from previous run.
cp "${ARG}/../settings.txt" $DNG_LOC
TRUNC_ARG=`echo $TRUNC_ARG | cut -c5-${#TRUNC_ARG}`
oldARG=$ARG
ARG=$(dirname $ARG)/${TRUNC_ARG}
BASE="$(basename "$ARG")"
EXT="${BASE##*.}"
dngLocClean() {
find $DNG_LOC -iname "*.dng" | xargs -I {} mv {} $oldARG
rm -rf $DNG_LOC
}
FILE="${OUTDIR}/${TRUNC_ARG}"
TMP="${FILE}/tmp_${TRUNC_ARG}" #Remove dng_ from ARG by redefining basic constants. Ready to go!
mkdirS $FILE dngLocClean
mkdirS $TMP #Make the folders.
find $DNG_LOC -iname "*.dng" | xargs -I {} mv {} $TMP #Moving files to where they need to go.
cp "${DNG_LOC}/settings.txt" $FILE
DEVELOP=false
rm -r $DNG_LOC
elif [ -d $ARG ]; then #If it's a DNG sequence, but not a reused one.
mkdirS $FILE mkdirS $FILE
mkdirS $TMP mkdirS $TMP
FPS=24 #Set it to a safe default.
echo -e "\e[1m${TRUNC_ARG}:\e[0m Using specified folder of RAW sequences...\n" #Use prespecified DNG sequence.
find $ARG -iname "*.dng" | xargs -I {} cp {} $TMP #Copying DNGs to TMP.
FRAMES=$(find ${TMP} -name "*.dng" | wc -l)
else
mkdirS $FILE
mkdirS $TMP
fi
#Darkframe Averaging
if [ ! $DARKFRAME == "" ]; then
echo -e "\e[1m${TRUNC_ARG}:\e[0m Creating darkframe for subtraction...\n"
avgFrame="${TMP}/avg.darkframe" #The path to the averaged darkframe file.
darkBase="$(basename "$ARG")"
darkExt="${BASE##*.}"
if [ darkExt != 'darkframe' ]; then
$MLV_DUMP -o "${avgFrame}" -a $DARKFRAME >/dev/null 2>/dev/null
else
cp $DARKFRAME $avgFrame #Copy the preaveraged frame if the extension is .darkframe.
fi
DARK_PROC="-s ${avgFrame}"
fi
#Dump to/use DNG sequence, perhaps subtracting darkframe.
if [ $DEVELOP == true ]; then
echo -e "\e[1m${TRUNC_ARG}:\e[0m Dumping to DNG Sequence...\n"
if [ ! $DARKFRAME == "" ] && [ ! $CHROMA_SMOOTH == "--no-cs" ]; then #Just to let the user know that certain features are impossible with RAW.
rawStat="*Skipping Darkframe subtraction and Chroma Smoothing for RAW file ${TRUNC_ARG}."
elif [ ! $DARKFRAME == "" ]; then
rawStat="*Skipping Darkframe subtraction for RAW file ${TRUNC_ARG}."
elif [ ! $CHROMA_SMOOTH == "--no-cs" ]; then
rawStat="*Skipping Chroma Smoothing for RAW file ${TRUNC_ARG}."
else
rawStat="\c"
fi
if [ $EXT == "MLV" ] || [ $EXT == "mlv" ]; then
# Read the header for interesting settings :) .
FPS=`${MLV_DUMP} -v -m ${ARG} | grep FPS | awk 'FNR == 1 {print $3}'`
FRAMES=`${MLV_DUMP} -v -m ${ARG} | grep 'Frames Video' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
ISO=`${MLV_DUMP} -v -m ${ARG} | grep 'ISO' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f2`
APERTURE=`${MLV_DUMP} -v -m ${ARG} | grep 'Aperture' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
LEN_FOCAL=`${MLV_DUMP} -v -m ${ARG} | grep 'Focal Len' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
SHUTTER=`${MLV_DUMP} -v -m ${ARG} | grep 'Shutter' | sed 's/[[:alpha:] ]*: //' | grep -oP '\(\K[^)]+' | cut -d$'\n' -f1`
echo -e "FPS: ${FPS}\nFrames: ${FRAMES}\nISO: ${ISO}\nAperture: ${APERTURE}\nFocalLength: ${LEN_FOCAL}\nShutterSpeed: ${SHUTTER}" > $FILE/settings.txt
#Dual ISO might want to do the chroma smoothing.
if [ $DUAL_ISO == true ]; then
smooth=""
else
smooth=$CHROMA_SMOOTH
fi
$MLV_DUMP $ARG $DARK_PROC -o "${TMP}/${TRUNC_ARG}_" --dng $smooth >/dev/null 2>/dev/null
elif [ $EXT == "RAW" ] || [ $EXT == "raw" ]; then
echo -e $rawStat
FPS=`$RAW_DUMP $ARG "${TMP}/${TRUNC_ARG}_" | awk '/FPS/ { print $3; }'` #Run the dump while awking for the FPS.
fi
FRAMES=$(find ${TMP} -name "*.dng" | wc -l)
BLACK_LEVEL=$(exiftool -BlackLevel -s -s -s ${TMP}/${TRUNC_ARG}_$(printf "%06d" $(echo "$FRAME_START - 1" | bc)).dng) #Use the first DNG to get the correct black level.
fi
#Create badpixels file. #Create badpixels file.
if [ $isBP == true ]; then if [ $isBP == true ] && [ ! -d $DNG_LOC ]; then
echo -e "\e[1m${TRUNC_ARG}:\e[0m Generating badpixels file...\n" echo -e "\e[1m${TRUNC_ARG}:\e[0m Generating badpixels file...\n"
bad_name="badpixels_${TRUNC_ARG}.txt" bad_name="badpixels_${TRUNC_ARG}.txt"
@ -607,72 +734,12 @@ for ARG in $*; do
BADPIXELS="-P ${gen_bad}" BADPIXELS="-P ${gen_bad}"
fi fi
#Darkframe Averaging if [ $isFR == true ]; then #Ensure that FRAME_RANGE is set.
if [ ! $DARKFRAME == "" ]; then FRAME_RANGE="1-${FRAMES}"
echo -e "\e[1m${TRUNC_ARG}:\e[0m Creating darkframe for subtraction...\n" FRAME_START="0"
FRAME_END=$FRAMES
avgFrame="${TMP}/avg.darkframe" #The path to the averaged darkframe file.
darkBase="$(basename "$ARG")"
darkExt="${BASE##*.}"
if [ darkExt != 'darkframe' ]; then
$MLV_DUMP -o "${avgFrame}" -a $DARKFRAME >/dev/null 2>/dev/null
else
cp $DARKFRAME $avgFrame #Copy the preaveraged frame if the extension is .darkframe.
fi fi
DARK_PROC="-s ${avgFrame}"
fi
#Dump to/use DNG sequence, perhaps subtracting darkframe.
if [ -d $ARG ]; then
if [ $SETTINGS_OUTPUT == true ]; then
echo -e "\e[0;31m\e[1mFile ${ARG} is not an MLV file - cannot output settings!\e[0m"
fi
echo -e "\e[1m${TRUNC_ARG}:\e[0m Using specified folder of RAW sequences...\n" #Use prespecified DNG sequence.
find $ARG -iname "*.dng" | xargs -I {} cp {} $TMP #Copying DNGs to TMP.
FPS=24 #Set FPS just in case.
FRAMES=$(find ${TMP} -name "*.dng" | wc -l)
else
echo -e "\e[1m${TRUNC_ARG}:\e[0m Dumping to DNG Sequence...\n"
if [ ! $DARKFRAME == "" ] && [ ! $CHROMA_SMOOTH == "--no-cs" ]; then #Just to let the user know that certain features are impossible with RAW.
rawStat="*Skipping Darkframe subtraction and Chroma Smoothing for RAW file ${TRUNC_ARG}."
elif [ ! $DARKFRAME == "" ]; then
rawStat="*Skipping Darkframe subtraction for RAW file ${TRUNC_ARG}."
elif [ ! $CHROMA_SMOOTH == "--no-cs" ]; then
rawStat="*Skipping Chroma Smoothing for RAW file ${TRUNC_ARG}."
else
rawStat="\c"
fi
if [ $EXT == "MLV" ] || [ $EXT == "mlv" ]; then
# Read the header for interesting settings :) .
FPS=`${MLV_DUMP} -v -m ${ARG} | grep FPS | awk 'FNR == 1 {print $3}'`
FRAMES=`${MLV_DUMP} -v -m ${ARG} | grep 'Frames Video' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
ISO=`${MLV_DUMP} -v -m ${ARG} | grep 'ISO' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f2`
APERTURE=`${MLV_DUMP} -v -m ${ARG} | grep 'Aperture' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
LEN_FOCAL=`${MLV_DUMP} -v -m ${ARG} | grep 'Focal Len' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
SHUTTER=`${MLV_DUMP} -v -m ${ARG} | grep 'Shutter' | sed 's/[[:alpha:] ]*: //' | grep -oP '\(\K[^)]+' | cut -d$'\n' -f1`
echo -e "FPS: ${FPS}\nFrames: ${FRAMES}\nISO: ${ISO}\nAperture: ${APERTURE}\nFocal Length: ${LEN_FOCAL}\nShutter Speed: ${SHUTTER}" > $FILE/settings.txt
$MLV_DUMP $ARG $DARK_PROC -o "${TMP}/${TRUNC_ARG}_" --dng $CHROMA_SMOOTH >/dev/null 2>/dev/null
elif [ $EXT == "RAW" ] || [ $EXT == "raw" ]; then
echo -e $rawStat
FPS=`$RAW_DUMP $ARG "${TMP}/${TRUNC_ARG}_" | awk '/FPS/ { print $3; }'` #Run the dump while awking for the FPS.
fi
FRAMES=$(find ${TMP} -name "*.dng" | wc -l)
fi
BLACK_LEVEL=$(exiftool -BlackLevel -s -s -s ${TMP}/${TRUNC_ARG}_000000.dng) #Use the first DNG to get the correct black level.
#Dual ISO Conversion #Dual ISO Conversion
if [ $DUAL_ISO == true ]; then if [ $DUAL_ISO == true ]; then
echo -e "\e[1m${TRUNC_ARG}:\e[0m Combining Dual ISO...\n" echo -e "\e[1m${TRUNC_ARG}:\e[0m Combining Dual ISO...\n"
@ -681,10 +748,10 @@ for ARG in $*; do
oldFiles="${TMP}/orig_dng" oldFiles="${TMP}/orig_dng"
mkdirS $oldFiles mkdirS $oldFiles
inc_iso() { #6 args: {} $CR_HDR $TMP $FRAMES $oldFiles $CHROMA_SMOOTH. {} is a path. Progress is thread safe. Experiment gone right :). inc_iso() { #6 args: 1{} 2$CR_HDR 3$TMP 4$FRAMES 5$oldFiles 6$CHROMA_SMOOTH. {} is a path. Progress is thread safe. Experiment gone right :).
count=$(echo $(echo $1 | rev | cut -d "_" -f 1 | rev | cut -d "." -f 1 | grep "[0-9]") | bc) #Get count from filename. 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 #The LQ option, --mean23, is completely unusable in my opinion. $2 $1 $6 >/dev/null 2>/dev/null #The LQ option, --mean23, is completely unusable in my opinion.
name=$(basename "$1") name=$(basename "$1")
mv "${3}/${name%.*}.dng" $5 #Move away original dngs. mv "${3}/${name%.*}.dng" $5 #Move away original dngs.
@ -695,10 +762,18 @@ for ARG in $*; do
export -f inc_iso #Must expose function to subprocess. export -f inc_iso #Must expose function to subprocess.
find $TMP -name "*.dng" -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 bash -x -c "inc_iso {} $CR_HDR $TMP $FRAMES $oldFiles $CHROMA_SMOOTH" find $TMP -maxdepth 1 -name "*.dng" -print0 | sort -z | cut -d '' --complement -f $FRAME_RANGE | tr -d '\n' | xargs -0 -I {} -n 1 mv {} $oldFiles #Move all the others to correct position.
find $TMP -maxdepth 1 -name "*.dng" -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 bash -c "inc_iso '{}' '$CR_HDR' '$TMP' '$FRAMES' '$oldFiles' '$CHROMA_SMOOTH'"
FRAME_RANGE="1-${FRAMES}"
BLACK_LEVEL=$(exiftool -BlackLevel -s -s -s ${TMP}/${TRUNC_ARG}_$(printf "%06d" $(echo "$FRAME_START - 1" | bc)).dng) #Use the first DNG to get the correct black level.
echo -e "\n" echo -e "\n"
fi fi
echo -e "BlackLevel: ${BLACK_LEVEL}" >> $FILE/settings.txt #Black level must now be set.
#Get White Balance correction factor. #Get White Balance correction factor.
if [ $GEN_WHITE == true ]; then if [ $GEN_WHITE == true ]; then
echo -e "\e[1m${TRUNC_ARG}:\e[0m Generating WB...\n" echo -e "\e[1m${TRUNC_ARG}:\e[0m Generating WB...\n"
@ -732,10 +807,10 @@ for ARG in $*; do
echo -e "Calculating Auto White Balance..." echo -e "Calculating Auto White Balance..."
BALANCE=`$BAL $toBal` BALANCE=`$BAL $toBal`
WHITE="-r ${BALANCE} 1.000000" WHITE="-r ${BALANCE} 1.000000"
echo -e "Correction Factor (RGB): ${BALANCE} 1.0\n" echo -e "Correction Factor (RGBG): ${BALANCE} 1.000000\n"
elif [ $CAMERA_WB == true ]; then elif [ $CAMERA_WB == true ]; then
echo -e "Retrieving Camera White Balance..." echo -e "\e[1m${TRUNC_ARG}:\e[0m Retrieving Camera White Balance..."
trap "rm -rf ${FILE}; exit 1" INT trap "rm -rf ${FILE}; exit 1" INT
for file in $TMP/*.dng; do for file in $TMP/*.dng; do
@ -744,7 +819,10 @@ for ARG in $*; do
break break
done done
WHITE="-r ${BALANCE} 1.0" WHITE="-r ${BALANCE} 1.0"
echo -e "Correction Factor (RGB): ${BALANCE} 1.0\n" echo -e "Correction Factor (RGBG): ${BALANCE} 1.000000\n"
else
echo -e "\e[1m${TRUNC_ARG}:\e[0m Ignoring White Balance..."
echo -e "Correction Factor (RGBG): 1.000000 1.000000 1.000000 1.000000\n"
fi fi
#Move .wav. #Move .wav.
@ -760,12 +838,12 @@ for ARG in $*; do
#DEFINE PROCESSING FUNCTIONS #DEFINE PROCESSING FUNCTIONS
dcrawOpt() { #Find, develop, and splay raw DNG data as ppm, ready to be processed. dcrawOpt() { #Find, develop, and splay raw DNG data as ppm, ready to be processed.
find "${TMP}" -maxdepth 1 -iname "*.dng" -print0 | sort -z | xargs -0 \ find "${TMP}" -maxdepth 1 -iname "*.dng" -print0 | sort -z | cut -d '' -f $FRAME_RANGE | tr -d "\n" | xargs -0 \
dcraw -c -q $DEMO_MODE $FOUR_COLOR -k $BLACK_LEVEL $BADPIXELS $WHITE -H $HIGHLIGHT_MODE -g $GAMMA $NOISE_REDUC -o $SPACE $DEPTH dcraw -c -q $DEMO_MODE $FOUR_COLOR -k $BLACK_LEVEL $BADPIXELS $WHITE -H $HIGHLIGHT_MODE -g $GAMMA $NOISE_REDUC -o $SPACE $DEPTH
} #Is prepared to pipe all the files in TMP outwards. } #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. dcrawImg() { #Find and splay image sequence data as ppm, ready to be processed by ffmpeg.
find "${SEQ}" -maxdepth 1 -iname "*.${IMG_FMT}" -print0 | sort -z | xargs -0 -I {} convert {} ppm:- find "${SEQ}" -maxdepth 1 -iname "*.${IMG_FMT}" -print0 | sort -z | xargs -0 -I {} convert '{}' ppm:-
} #Finds all images, prints to stdout quickly without any operations using convert. } #Finds all images, prints to stdout quickly without any operations using convert.
mov_main() { mov_main() {
@ -801,7 +879,7 @@ for ARG in $*; do
#~ cat $PIPE | tr 'e' 'a' & echo 'hello' | tee $PIPE | tr 'e' 'o' #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 20 arguments: {} $DEMO_MODE $FOUR_COLOR $BADPIXELS $WHITE $HIGHLIGHT_MODE $GAMMA $NOISE_REDUC $DEPTH $SEQ $TRUNC_ARG $IMG_FMT $FRAMES $DEPTH_OUT $COMPRESS $isJPG $PROXY_SCALE $PROXY $BLACK_LEVEL $SPACE img_par() { #Takes 20 arguments: {} 2$DEMO_MODE 3$FOUR_COLOR 4$BADPIXELS 5$WHITE 6$HIGHLIGHT_MODE 7$GAMMA 8$NOISE_REDUC 9$DEPTH 10$SEQ 11$TRUNC_ARG 12$IMG_FMT 13$FRAMES 14$DEPTH_OUT 15$COMPRESS 16$isJPG $PROXY_SCALE $PROXY $BLACK_LEVEL $SPACE
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! 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!
if [ ${16} == true ]; then if [ ${16} == true ]; then
dcraw -c -q $2 $3 $4 $5 -H $6 -k ${19} -g $7 $8 -o ${20} $9 $1 | \ dcraw -c -q $2 $3 $4 $5 -H $6 -k ${19} -g $7 $8 -o ${20} $9 $1 | \
@ -848,15 +926,15 @@ for ARG in $*; do
fi fi
#Convert all the actual DNGs to IMG_FMT, in parallel. #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 \ find "${TMP}" -maxdepth 1 -name '*.dng' -print0 | sort -z | cut -d '' -f $FRAME_RANGE | tr -d "\n" | xargs -0 -I {} -P $THREADS -n 1 \
bash -c "img_par {} '$DEMO_MODE' '$FOUR_COLOR' '$BADPIXELS' '$WHITE' '$HIGHLIGHT_MODE' '$GAMMA' '$NOISE_REDUC' '$DEPTH' \ bash -c "img_par '{}' '$DEMO_MODE' '$FOUR_COLOR' '$BADPIXELS' '$WHITE' '$HIGHLIGHT_MODE' '$GAMMA' '$NOISE_REDUC' '$DEPTH' \
'$SEQ' '$TRUNC_ARG' '$IMG_FMT' '$FRAMES' '$DEPTH_OUT' '$COMPRESS' '$isJPG' '$PROXY_SCALE' '$PROXY' '$BLACK_LEVEL' '$SPACE'\ '$SEQ' '$TRUNC_ARG' '$IMG_FMT' '$FRAMES' '$DEPTH_OUT' '$COMPRESS' '$isJPG' '$PROXY_SCALE' '$PROXY' '$BLACK_LEVEL' '$SPACE'\
" "
if [ $isJPG == true ]; then #Make it print "Frame $FRAMES / $FRAMES" as the last output :). if [ $isJPG == true ]; then #Make it print "Frame $FRAMES / $FRAMES" as the last output :).
echo -e "\e[2K\rDNG to ${IMG_FMT^^}/JPG: Frame ${FRAMES}/${FRAMES}\c" echo -e "\e[2K\rDNG to ${IMG_FMT^^}/JPG: Frame ${FRAME_END}/${FRAMES}\c"
else else
echo -e "\e[2K\rDNG to ${IMG_FMT^^}: Frame ${FRAMES}/${FRAMES}\c" echo -e "\e[2K\rDNG to ${IMG_FMT^^}: Frame ${FRAME_END}/${FRAMES}\c"
fi fi
echo -e "\n" echo -e "\n"
@ -871,7 +949,7 @@ for ARG in $*; do
lutLoc="${TMP}/lut_conv" lutLoc="${TMP}/lut_conv"
mkdirS $lutLoc mkdirS $lutLoc
find $SEQ -name "*.${IMG_FMT}" | xargs -I '{}' mv {} "${lutLoc}" find $SEQ -name "*.${IMG_FMT}" -print0 | cut -d '' -f $FRAME_RANGE | tr -d "\n" | xargs -0 -I '{}' mv {} "${lutLoc}"
ffmpeg -f image2 -i "${lutLoc}/${TRUNC_ARG}_%06d.${IMG_FMT}" -loglevel panic -stats -vf $LUT "${SEQ}/${TRUNC_ARG}_%06d.${IMG_FMT}" ffmpeg -f image2 -i "${lutLoc}/${TRUNC_ARG}_%06d.${IMG_FMT}" -loglevel panic -stats -vf $LUT "${SEQ}/${TRUNC_ARG}_%06d.${IMG_FMT}"
fi fi
fi fi