Improved -A (AWB Speed) option
parent
ae3db18582
commit
95da1ce3b2
99
convmlv.sh
99
convmlv.sh
|
@ -3,7 +3,7 @@
|
||||||
#BASIC CONSTANTS
|
#BASIC CONSTANTS
|
||||||
DEPS="imagemagick dcraw ffmpeg python3 pip3 exiftool xxd" #Dependency package names (Debian). List with -K option.
|
DEPS="imagemagick dcraw ffmpeg python3 pip3 exiftool xxd" #Dependency package names (Debian). List with -K option.
|
||||||
PIP_DEPS="numpy Pillow tifffile" #Technically, you don't need Pillow. I'm not really sure :).
|
PIP_DEPS="numpy Pillow tifffile" #Technically, you don't need Pillow. I'm not really sure :).
|
||||||
VERSION="1.5.2" #Version string.
|
VERSION="1.6.0" #Version string.
|
||||||
PYTHON="python3"
|
PYTHON="python3"
|
||||||
|
|
||||||
#NON-STANDARD FILE LOCATIONS
|
#NON-STANDARD FILE LOCATIONS
|
||||||
|
@ -42,7 +42,7 @@ isBP=false
|
||||||
WHITE=""
|
WHITE=""
|
||||||
GEN_WHITE=true
|
GEN_WHITE=true
|
||||||
CAMERA_WB=false
|
CAMERA_WB=false
|
||||||
WHITE_SPD=15
|
WHITE_SPD=10
|
||||||
|
|
||||||
#LUT
|
#LUT
|
||||||
LUT=""
|
LUT=""
|
||||||
|
@ -80,7 +80,7 @@ help () { #This is a little too much @ this point...
|
||||||
echo -e " -i IMAGE - Specify to create a TIFF sequence.\n"
|
echo -e " -i IMAGE - Specify to create a TIFF sequence.\n"
|
||||||
|
|
||||||
echo -e " -c COMPRESS - Specify to compress the TIFF sequence."
|
echo -e " -c COMPRESS - Specify to compress the TIFF sequence."
|
||||||
echo -e " --> Uses ZIP compression for best 16-bit compression."
|
echo -e " --> Uses ZIP compression for best 16-bit compression.\n"
|
||||||
|
|
||||||
echo -e " -m MOVIE - Specify to create a Prores4444 video.\n"
|
echo -e " -m MOVIE - Specify to create a Prores4444 video.\n"
|
||||||
|
|
||||||
|
@ -123,8 +123,8 @@ help () { #This is a little too much @ this point...
|
||||||
echo -e " --> Use -w<mode> (no space)."
|
echo -e " --> Use -w<mode> (no space)."
|
||||||
echo -e " --> 0: Auto WB (Requires Python Deps). 1: Camera WB. 2: No Change.\n"
|
echo -e " --> 0: Auto WB (Requires Python Deps). 1: Camera WB. 2: No Change.\n"
|
||||||
|
|
||||||
echo -e " -A[int] WHITE_SPD - This is the speed of the auto white balance, causing quality loss. Defaults to 15."
|
echo -e " -A[int] WHITE_SPD - This is the amount of samples from which AWB will be calculated."
|
||||||
echo -e " --> For AWB, the script averages the entire sequence, skipping n frames each time. This value is n.\n"
|
echo -e " -->About this many frames, averaged over the course of the sequence, will be used to do AWB."
|
||||||
|
|
||||||
echo -e " -l<path> LUT - This is a path to the 3D LUT. Specify the path to the LUT to use it."
|
echo -e " -l<path> LUT - This is a path to the 3D LUT. Specify the path to the LUT to use it."
|
||||||
echo -e " --> Compatibility determined by ffmpeg (.cube is supported)."
|
echo -e " --> Compatibility determined by ffmpeg (.cube is supported)."
|
||||||
|
@ -445,29 +445,31 @@ for ARG in $*; do
|
||||||
FPS=`$RAW_DUMP $ARG "${TMP}/${TRUNC_ARG}_" | awk '/FPS/ { print $3; }'` #Run the dump while awking for the FPS.
|
FPS=`$RAW_DUMP $ARG "${TMP}/${TRUNC_ARG}_" | awk '/FPS/ { print $3; }'` #Run the dump while awking for the FPS.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FRAMES=`expr $(ls -1U ${TMP} | wc -l) - 1`
|
FRAMES=$(find ${TMP} -name "*.dng" | wc -l)
|
||||||
|
|
||||||
#Get White Balance correction factor (or ignore it all).
|
#Get White Balance correction factor (or ignore it all).
|
||||||
echo -e "\e[1m${TRUNC_ARG}:\e[0m Generating WB...\n"
|
echo -e "\e[1m${TRUNC_ARG}:\e[0m Generating WB...\n"
|
||||||
if [ $GEN_WHITE == true ]; then
|
if [ $GEN_WHITE == true ]; then
|
||||||
n=`echo "${WHITE_SPD} + 1" | bc`
|
if [ $WHITE_SPD -gt $FRAMES ]; then
|
||||||
|
WHITE_SPD=$FRAMES
|
||||||
i=0
|
fi
|
||||||
trap "rm -rf ${FILE}; exit 1" INT
|
n=`echo "${FRAMES} / ${WHITE_SPD}" | bc`
|
||||||
for file in $TMP/*.dng; do
|
|
||||||
if [ `echo "${i} % ${n}" | bc` -eq 0 ] || [ $i -eq 1 ]; then #Only develop every nth file - we're averaging, after all!
|
|
||||||
dcraw -q 0 $BADPIXELS -r 1 1 1 1 -g $GAMMA -o 0 -T "${file}"
|
|
||||||
fi
|
|
||||||
echo -e "\e[2K\rWB Development: Frame ${i}/${FRAMES}.\c"
|
|
||||||
let i++
|
|
||||||
done
|
|
||||||
|
|
||||||
toBal="${TMP}/toBal"
|
toBal="${TMP}/toBal"
|
||||||
mkdirS $toBal
|
mkdirS $toBal
|
||||||
|
|
||||||
for tiff in $TMP/*.tiff; do
|
i=0
|
||||||
mv $tiff $toBal #TIFF MOVEMENT
|
t=0
|
||||||
|
trap "rm -rf ${FILE}; exit 1" INT
|
||||||
|
for file in $TMP/*.dng; do
|
||||||
|
if [ `echo "(${i}+1) % ${n}" | bc` -eq 0 ]; then # || [ $i -eq 1 ]; then #Only develop every nth file - we're averaging, after all!
|
||||||
|
dcraw -q 0 $BADPIXELS -r 1 1 1 1 -g $GAMMA -o 0 -T "${file}"
|
||||||
|
mv $file $toBal #TIFF MOVEMENT
|
||||||
|
let t++
|
||||||
|
fi
|
||||||
|
echo -e "\e[2K\rWB Development: Sample ${t}/$(echo "${FRAMES} / $n" | bc) (Frame: $(echo "${i} + 1" | bc)/${FRAMES})\c"
|
||||||
|
let i++
|
||||||
done
|
done
|
||||||
|
echo ""
|
||||||
|
|
||||||
#Read result into a form dcraw likes.
|
#Read result into a form dcraw likes.
|
||||||
echo -e "Calculating Auto White Balance..."
|
echo -e "Calculating Auto White Balance..."
|
||||||
|
@ -487,8 +489,6 @@ for ARG in $*; do
|
||||||
echo -e "Correction Factor (RGB): ${BALANCE} 1.0\n"
|
echo -e "Correction Factor (RGB): ${BALANCE} 1.0\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\e[1m${TRUNC_ARG}:\e[0m Converting ${FRAMES} DNGs to TIFF..."
|
|
||||||
|
|
||||||
#Move .wav.
|
#Move .wav.
|
||||||
SOUND_PATH="${TMP}/${TRUNC_ARG}_.wav"
|
SOUND_PATH="${TMP}/${TRUNC_ARG}_.wav"
|
||||||
|
|
||||||
|
@ -530,15 +530,15 @@ for ARG in $*; do
|
||||||
-loglevel panic -stats $SOUND -c:v libx264 -n -r $FPS -preset fast -vf "scale=trunc(iw/2)*${SCALE}:trunc(ih/2)*${SCALE}" -crf 23 $LUT -c:a mp3 "${VID}_lq.mp4"
|
-loglevel panic -stats $SOUND -c:v libx264 -n -r $FPS -preset fast -vf "scale=trunc(iw/2)*${SCALE}:trunc(ih/2)*${SCALE}" -crf 23 $LUT -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.
|
} #The option -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" fixes when x264 is unhappy about non-2 divisible dimensions.
|
||||||
|
|
||||||
|
|
||||||
|
TIFF="${FILE}/tiff_${TRUNC_ARG}"
|
||||||
|
PROXY="${FILE}/proxy_${TRUNC_ARG}"
|
||||||
|
|
||||||
#IMAGE PROCESSING
|
#IMAGE PROCESSING
|
||||||
if [ $IMAGES == true ] ; then
|
if [ $IMAGES == true ] ; then
|
||||||
echo -e "\e[1m${TRUNC_ARG}:\e[0m Processing Image Sequence...\n"
|
echo -e "\e[1m${TRUNC_ARG}:\e[0m Processing Image Sequence...\n"
|
||||||
|
|
||||||
#Define Image Directories, Create TIFF directory
|
#Define Image Directories, Create TIFF directory
|
||||||
TIFF="${FILE}/tiff_${TRUNC_ARG}"
|
|
||||||
PROXY="${FILE}/proxy_${TRUNC_ARG}"
|
|
||||||
|
|
||||||
mkdirS $TIFF
|
mkdirS $TIFF
|
||||||
|
|
||||||
if [ $isJPG == true ]; then
|
if [ $isJPG == true ]; then
|
||||||
|
@ -564,37 +564,56 @@ for ARG in $*; do
|
||||||
if [ $isLUT == true ]; then #Some way to package this into the development itself without piping hell?
|
if [ $isLUT == true ]; then #Some way to package this into the development itself without piping hell?
|
||||||
echo -e "\e[1m${TRUNC_ARG}:\e[0m Applying LUT to ${FRAMES} TIFFs...\n"
|
echo -e "\e[1m${TRUNC_ARG}:\e[0m Applying LUT to ${FRAMES} TIFFs...\n"
|
||||||
|
|
||||||
ffmpeg -f image2 -i "${TMP}/${TRUNC_ARG}_%06d.tiff" -loglevel panic -stats -vf $LUT "${TIFF}/LUT_${TRUNC_ARG}_%06d.tiff"
|
ffmpeg -f image2 -i "${TIFF}/${TRUNC_ARG}_%06d.tiff" -loglevel panic -stats -vf $LUT "${TIFF}/LUT_${TRUNC_ARG}_%06d.tiff"
|
||||||
|
|
||||||
rm $TMP/*.tiff
|
rm $TMP/*.tiff
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if [ $isJPG == true ]; then
|
||||||
|
mkdirS $PROXY
|
||||||
|
fi
|
||||||
|
|
||||||
|
i=0 #Very important variable. See functions called.
|
||||||
|
trap "rm -rf ${FILE}; exit 1" INT
|
||||||
|
for file in $TMP/*.dng; do
|
||||||
|
if [ $isJPG == true ]; then
|
||||||
|
dcrawFile $file | img_prox
|
||||||
|
echo -e "\e[2K\rDNG to JPG (dcraw): Frame ${i}/${FRAMES}.\c"
|
||||||
|
fi
|
||||||
|
let i++
|
||||||
|
done
|
||||||
|
echo -e "\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#MOVIE PROCESSING
|
#MOVIE PROCESSING
|
||||||
|
VID="${FILE}/${TRUNC_ARG}"
|
||||||
|
SCALE=`echo "($(echo "${PROXY_SCALE}" | sed 's/%//') / 100) * 2" | bc -l` #Get scale as factor for halved video, *2 for 50%
|
||||||
|
|
||||||
|
SOUND="-i ${TMP}/${TRUNC_ARG}_.wav"
|
||||||
|
SOUND_ACTION="-c:a mp3"
|
||||||
|
if [ ! -f $SOUND_PATH ]; then
|
||||||
|
SOUND=""
|
||||||
|
SOUND_ACTION=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $MOVIE = true ]; then
|
if [ $MOVIE = true ]; then
|
||||||
VID="${FILE}/${TRUNC_ARG}"
|
|
||||||
SCALE=`echo "($(echo "${PROXY_SCALE}" | sed 's/%//') / 100) * 2" | bc -l` #Get scale as factor for halved video, *2 for 50%
|
|
||||||
|
|
||||||
SOUND="-i ${TMP}/${TRUNC_ARG}_.wav"
|
|
||||||
SOUND_ACTION="-c:a mp3"
|
|
||||||
if [ ! -f $SOUND_PATH ]; then
|
|
||||||
SOUND=""
|
|
||||||
SOUND_ACTION=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
#LUT is automatically applied if argument was passed.
|
#LUT is automatically applied if argument was passed.
|
||||||
|
|
||||||
if [ $isH264 == true ]; then
|
if [ $isH264 == true ]; then
|
||||||
echo -e "\e[1m${TRUNC_ARG}:\e[0m Encoding to ProRes/H264...\n"
|
echo -e "\e[1m${TRUNC_ARG}:\e[0m Encoding to ProRes/H.264..."
|
||||||
runSim dcrawOpt mov_main mov_prox
|
runSim dcrawOpt mov_main mov_prox
|
||||||
|
|
||||||
else
|
else
|
||||||
echo -e "\e[1m${TRUNC_ARG}:\e[0m Encoding to ProRes...\n"
|
echo -e "\e[1m${TRUNC_ARG}:\e[0m Encoding to ProRes..."
|
||||||
dcrawOpt | mov_main
|
dcrawOpt | mov_main
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if [ $isH264 == true ]; then
|
||||||
|
echo -e "\e[1m${TRUNC_ARG}:\e[0m Encoding to H264..."
|
||||||
|
dcrawOpt | mov_prox
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n\e[1mCleaning Up.\e[0m\n\n"
|
echo -e "\n\e[1mCleaning Up.\e[0m\n"
|
||||||
|
|
||||||
#Potentially move DNGs.
|
#Potentially move DNGs.
|
||||||
if [ $KEEP_DNGS == true ]; then
|
if [ $KEEP_DNGS == true ]; then
|
||||||
|
|
Loading…
Reference in New Issue