2016-03-05 21:29:51 +01:00
#!/bin/bash
2016-12-07 05:06:56 +01:00
#desc: Main file - uses convmlv components as needed.
2016-04-12 18:47:47 +02:00
2016-03-21 00:48:10 +01:00
#~ The MIT License (MIT)
2016-03-28 21:55:58 +02:00
#~ Copyright (c) 2016 Sofus Rose
2016-03-21 00:48:10 +01:00
#~ Permission is hereby granted, free of charge, to any person obtaining a copy
#~ of this software and associated documentation files (the "Software"), to deal
#~ in the Software without restriction, including without limitation the rights
#~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#~ copies of the Software, and to permit persons to whom the Software is
#~ furnished to do so, subject to the following conditions:
2016-03-29 00:25:49 +02:00
#~
2016-03-21 00:48:10 +01:00
#~ The above copyright notice and this permission notice shall be included in all
#~ copies or substantial portions of the Software.
2016-03-29 00:25:49 +02:00
#~
2016-03-21 00:48:10 +01:00
#~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#~ SOFTWARE.
2016-12-07 05:06:56 +01:00
VERSION = "2.1.0a2" #Version string.
INPUT_ARGS = $( echo " $@ " ) #The original input argument string.
2016-12-06 06:56:08 +01:00
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."
2016-05-17 03:32:02 +02:00
fi
2016-10-30 02:57:05 +01:00
2016-12-06 06:56:08 +01:00
#BASIC FUNCTIONS
2016-10-30 02:57:05 +01:00
2016-12-06 06:56:08 +01:00
readlinkF( ) { #readlink -f, but works on all platforms (including mac).
target = $1
if [ [ $OSTYPE = = "linux-gnu" ] ] ; then #Linux-specific constants.
echo $( readlink -f " $target " )
elif [ [ $OSTYPE = = "darwin11" ] ] ; then #Mac-specific constants
2016-10-30 02:57:05 +01:00
cd ` dirname $target `
target = ` basename $target `
2016-12-06 06:56:08 +01:00
# Iterate down a (possible) chain of symlinks
while [ -L " $target " ] ; do
target = ` readlink $target `
cd ` dirname $target `
target = ` basename $target `
done
2016-10-30 02:57:05 +01:00
2016-12-06 06:56:08 +01:00
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
phys = ` pwd -P`
res = $phys /$target
echo $res
fi
2016-10-30 02:57:05 +01:00
}
2016-03-21 00:48:10 +01:00
2016-12-06 06:56:08 +01:00
setPaths( ) { #Repends on SRC_PATH, BIN_PATH, and PYTHON. Run this function if either is changed.
MLV_DUMP = " ${ BIN_PATH } /mlv_dump " #Path to mlv_dump location.
RAW_DUMP = " ${ BIN_PATH } /raw2dng " #Path to raw2dng location.
CR_HDR = " ${ BIN_PATH } /cr2hdr " #Path to cr2hdr location.
MLV_BP = " ${ BIN_PATH } /mlv2badpixels.sh "
PYTHON_BAL = " ${ SRC_PATH } /imgProcessing/balance.py "
PYTHON_SRANGE = " ${ SRC_PATH } /imgProcessing/sRange.py "
2016-05-18 02:19:53 +02:00
BAL = " ${ PYTHON } ${ PYTHON_BAL } "
SRANGE = " ${ PYTHON } ${ PYTHON_SRANGE } "
2016-12-06 06:56:08 +01:00
COLOR_LUTS = ( " ${ SCRIPT_LOCATION } /color-core " " ${ SCRIPT_LOCATION } /color-ext " ) #One can add more with options, but these are the defaults.
Huge color management release. Added lists getting ready for true compatibility, multiple LUTs, dcraw paths, updated convmlv -h.
Bug Fixes: Reuse of DNGs, DPX colorspace bug, PNG compression format, "files left" display for DNG folders, ARG bug, filter application sequence, file-specific reset bugs.
Error Checking: Though not complete, it's been drastically upscaled - there should be far fewer "weird errors"; it'll tell you what's wrong.
Speedups: ffmpeg filtering is faster for EXRs. movie creation is much faster if images were developed.
2016-07-09 02:11:59 +02:00
DCRAW = "dcraw"
2016-05-18 02:19:53 +02:00
}
2016-12-06 06:56:08 +01:00
setDefaults( ) { #Set all the default global variables. Run during "parseAll".
2016-06-25 02:38:00 +02:00
#DEPENDENCIES
2016-11-30 06:40:52 +01:00
DEB_DEPS = "imagemagick dcraw ffmpeg python3 python3-pip libimage-exiftool-perl libc6-i386" #Dependency package names (Debian). List with -K option.
UBU_DEPS = "imagemagick dcraw ffmpeg python3 python3-pip libimage-exiftool-perl libc6-i386" #Dependency package names (Ubuntu). List with -K option.
FED_DEPS = "ImageMagick dcraw ffmpeg python3 python-pip perl-Image-ExifTool glibc-devel.i686" #Dependency package names (Fedora). List with -K option.
Huge color management release. Added lists getting ready for true compatibility, multiple LUTs, dcraw paths, updated convmlv -h.
Bug Fixes: Reuse of DNGs, DPX colorspace bug, PNG compression format, "files left" display for DNG folders, ARG bug, filter application sequence, file-specific reset bugs.
Error Checking: Though not complete, it's been drastically upscaled - there should be far fewer "weird errors"; it'll tell you what's wrong.
Speedups: ffmpeg filtering is faster for EXRs. movie creation is much faster if images were developed.
2016-07-09 02:11:59 +02:00
BREW_DEPS = "imagemagick dcraw ffmpeg python3 exiftool"
PIP_DEPS = "numpy tifffile" #You don't need Pillow. That's just to make balance.py a bit more portable.
MAN_DEPS = "mlv_dump raw2dng cr2hdr mlv2badpixels.sh balance.py sRange.py color-core"
2016-06-25 02:38:00 +02:00
if [ [ $OSTYPE = = "linux-gnu" ] ] ; then
PYTHON = "python3"
2016-10-30 02:57:05 +01:00
elif [ [ $OSTYPE = = "darwin11" ] ] ; then
PYTHON = "python3"
2016-06-25 02:38:00 +02:00
else
PYTHON = "python"
fi
#PATHS
2016-12-06 06:56:08 +01:00
SCRIPT_LOCATION = $( dirname " $( readlinkF " $0 " ) " )
SRC_PATH = " $SCRIPT_LOCATION /src " #Source components will always be looked for here.
BIN_PATH = "./binaries"
2016-06-25 02:38:00 +02:00
GCONFIG = " ${ HOME } /convmlv.conf "
LCONFIG = "" #No local config by default.
2016-12-06 06:56:08 +01:00
setPaths #Set all the paths using the current SRC_PATH and BIN_PATH.
2016-06-25 02:38:00 +02:00
OUTDIR = "./raw_conv"
isOutGen = false
2016-03-29 00:52:59 +02:00
#OUTPUT
2016-06-25 02:38:00 +02:00
MOVIE = false
Huge color management release. Added lists getting ready for true compatibility, multiple LUTs, dcraw paths, updated convmlv -h.
Bug Fixes: Reuse of DNGs, DPX colorspace bug, PNG compression format, "files left" display for DNG folders, ARG bug, filter application sequence, file-specific reset bugs.
Error Checking: Though not complete, it's been drastically upscaled - there should be far fewer "weird errors"; it'll tell you what's wrong.
Speedups: ffmpeg filtering is faster for EXRs. movie creation is much faster if images were developed.
2016-07-09 02:11:59 +02:00
RES_IN = ""
2016-06-25 02:38:00 +02:00
FPS = 24 #Will be read from .MLV or .RAW.
IMAGES = false
IMG_FMT = "exr"
COMPRESS = ""
isCOMPRESS = true
isJPG = false
isH264 = false
KEEP_DNGS = false
2016-03-20 16:17:40 +01:00
2016-04-13 15:47:22 +02:00
#FRAME RANGE
2016-06-25 02:38:00 +02:00
FRAME_RANGE = "" #UPDATED LATER WHEN FRAME # IS AVAILABLE.
FRAME_START = "1"
FRAME_END = ""
RANGE_BASE = ""
isFR = true
2016-04-13 15:47:22 +02:00
2016-03-29 00:52:59 +02:00
#RAW DEVELOPOMENT
2016-06-25 02:38:00 +02:00
HIGHLIGHT_MODE = "0"
PROXY_SCALE = "50%"
DEMO_MODE = "1"
DEPTH = "-W -6"
DEPTH_OUT = "-depth 16"
2016-06-26 18:28:01 +02:00
WAVE_NOISE = "" #Used to be NOISE_REDUC. Wavelet noise reduction.
2016-06-25 02:38:00 +02:00
FOUR_COLOR = ""
CHROMA_SMOOTH = "--no-cs"
Huge color management release. Added lists getting ready for true compatibility, multiple LUTs, dcraw paths, updated convmlv -h.
Bug Fixes: Reuse of DNGs, DPX colorspace bug, PNG compression format, "files left" display for DNG folders, ARG bug, filter application sequence, file-specific reset bugs.
Error Checking: Though not complete, it's been drastically upscaled - there should be far fewer "weird errors"; it'll tell you what's wrong.
Speedups: ffmpeg filtering is faster for EXRs. movie creation is much faster if images were developed.
2016-07-09 02:11:59 +02:00
#COLOR MANAGEMENT
GAMMA = "1 1" #As far as dcraw is concerned, output is linear.
SPACE = "5" #dcraw only outputs Linear XYZ. LUTs convert onwards.
COLOR_GAMMA = "lin" #STANDARD marks it such that it will correspond to the gamut
COLOR_GAMUT = "srgb"
COLOR_VF = "" #Standard (~2.4) sRGB LUT by default: ${CORE_LUT}/lin_xyz--srgb_srgb.cube . This is used in VF_FILTERS
colorDesc = ""
2016-03-29 00:52:59 +02:00
#FEATURES
2016-06-25 02:38:00 +02:00
DUAL_ISO = false
BADPIXELS = ""
BADPIXEL_PATH = ""
isBP = false
DARKFRAME = ""
2016-06-30 23:01:35 +02:00
useDF = false
DARK_PROC = ""
Huge color management release. Added lists getting ready for true compatibility, multiple LUTs, dcraw paths, updated convmlv -h.
Bug Fixes: Reuse of DNGs, DPX colorspace bug, PNG compression format, "files left" display for DNG folders, ARG bug, filter application sequence, file-specific reset bugs.
Error Checking: Though not complete, it's been drastically upscaled - there should be far fewer "weird errors"; it'll tell you what's wrong.
Speedups: ffmpeg filtering is faster for EXRs. movie creation is much faster if images were developed.
2016-07-09 02:11:59 +02:00
RES_DARK = ""
2016-06-25 02:38:00 +02:00
SETTINGS_OUTPUT = false
MK_DARK = false
DARK_OUT = ""
BLACK_LEVEL = ""
2016-03-14 02:33:53 +01:00
#White Balance
2016-06-25 02:38:00 +02:00
WHITE = ""
GEN_WHITE = false
CAMERA_WB = true
WHITE_SPD = 15
isScale = false
SATPOINT = ""
2016-03-14 02:33:53 +01:00
2016-06-26 18:28:01 +02:00
#FFMPEG Filters
FFMPEG_FILTERS = false #Whether or not FFMPEG filters are going to be used.
Huge color management release. Added lists getting ready for true compatibility, multiple LUTs, dcraw paths, updated convmlv -h.
Bug Fixes: Reuse of DNGs, DPX colorspace bug, PNG compression format, "files left" display for DNG folders, ARG bug, filter application sequence, file-specific reset bugs.
Error Checking: Though not complete, it's been drastically upscaled - there should be far fewer "weird errors"; it'll tell you what's wrong.
Speedups: ffmpeg filtering is faster for EXRs. movie creation is much faster if images were developed.
2016-07-09 02:11:59 +02:00
V_FILTERS = ""
V_FILTERS_PROX = ""
2016-06-30 23:01:35 +02:00
FILTER_ARR = ( )
2016-06-26 18:28:01 +02:00
TEMP_NOISE = "" #Temporal noise reduction.
2016-06-27 06:59:14 +02:00
tempDesc = ""
Huge color management release. Added lists getting ready for true compatibility, multiple LUTs, dcraw paths, updated convmlv -h.
Bug Fixes: Reuse of DNGs, DPX colorspace bug, PNG compression format, "files left" display for DNG folders, ARG bug, filter application sequence, file-specific reset bugs.
Error Checking: Though not complete, it's been drastically upscaled - there should be far fewer "weird errors"; it'll tell you what's wrong.
Speedups: ffmpeg filtering is faster for EXRs. movie creation is much faster if images were developed.
2016-07-09 02:11:59 +02:00
LUTS = ( ) #lut3d LUT application. Supports multiple LUTs, in a chain; therefore it is an array.
2016-06-27 06:59:14 +02:00
lutDesc = ""
2016-06-27 07:33:53 +02:00
DESHAKE = "" #deshake video stabilisation.
2016-06-27 06:59:14 +02:00
deshakeDesc = ""
HQ_NOISE = "" #hqdn3d noise reduction.
hqDesc = ""
2016-06-27 07:33:53 +02:00
REM_NOISE = "" #removegrain noise reduction
remDesc = ""
2016-06-30 20:46:03 +02:00
SHARP = ""
sharpDesc = ""
Huge color management release. Added lists getting ready for true compatibility, multiple LUTs, dcraw paths, updated convmlv -h.
Bug Fixes: Reuse of DNGs, DPX colorspace bug, PNG compression format, "files left" display for DNG folders, ARG bug, filter application sequence, file-specific reset bugs.
Error Checking: Though not complete, it's been drastically upscaled - there should be far fewer "weird errors"; it'll tell you what's wrong.
Speedups: ffmpeg filtering is faster for EXRs. movie creation is much faster if images were developed.
2016-07-09 02:11:59 +02:00
baseSet( ) { #All camera attributes are reset here.
CAM_NAME = "Unknown"
FRAMES = "Unknown"
RES_IN = "Unknown"
ISO = "Unknown"
APERTURE = "Unknown"
LEN_FOCAL = "Unknown"
SHUTTER = "Unknown"
REC_DATE = "Unknown"
REC_TIME = "Unknown"
KELVIN = "Unknown"
}
baseSet
2016-06-25 02:38:00 +02:00
}
2016-12-06 06:56:08 +01:00
setDefaults #Run once now, and whenever you wish to reset things.
2016-05-18 02:19:53 +02:00
2016-12-06 06:56:08 +01:00
#DEFAULT PROGRAM - what it is we're actually doing right now.
PROGRAM = "develop"
#Possible values:
#~ help: Display help page!
#~ version: Display version!
#~ darkframe: Create darkframe!
#~ settings: Show MLV settings!
#~ develop: What we do best!
Huge color management release. Added lists getting ready for true compatibility, multiple LUTs, dcraw paths, updated convmlv -h.
Bug Fixes: Reuse of DNGs, DPX colorspace bug, PNG compression format, "files left" display for DNG folders, ARG bug, filter application sequence, file-specific reset bugs.
Error Checking: Though not complete, it's been drastically upscaled - there should be far fewer "weird errors"; it'll tell you what's wrong.
Speedups: ffmpeg filtering is faster for EXRs. movie creation is much faster if images were developed.
2016-07-09 02:11:59 +02:00
2016-03-14 02:33:53 +01:00
2016-12-06 06:56:08 +01:00
#IMPORT MODULES GLOBALLY - into this namespace directly.
source " $SRC_PATH /documentation/help.sh "
source " $SRC_PATH /helpers/platform.sh "
source " $SRC_PATH /programs/shotSettings.sh "
source " $SRC_PATH /helpers/format.sh "
source " $SRC_PATH /programs/califrame.sh "
source " $SRC_PATH /helpers/utility.sh "
source " $SRC_PATH /core/parsing.sh "
source " $SRC_PATH /helpers/error.sh "
source " $SRC_PATH /core/develop.sh "
2016-12-07 05:06:56 +01:00
source " $SRC_PATH /core/proc.sh "
source " $SRC_PATH /imgProcessing/imgMath.sh "
2016-03-13 08:04:18 +01:00
2016-04-15 14:50:13 +02:00
2016-12-06 06:56:08 +01:00
#OPTION PARSING FROM CONFIG AND CLI - same as at bottom of develop().
2016-04-15 14:50:13 +02:00
2016-12-06 06:56:08 +01:00
#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.
2016-04-15 14:50:13 +02:00
2016-12-06 06:56:08 +01:00
parseConf " $GCONFIG " false #Parse global config file.
2016-06-25 17:38:33 +02:00
parseArgs " $@ " #First, parse all cli args. We only need the -C flag, but that forces us to just parse everything.
2016-06-25 02:38:00 +02:00
shift $(( OPTIND-1)) #Shift past all of the options to the file arguments.
2016-12-06 06:56:08 +01:00
parseConf " $LCONFIG " false #Parse local config file.
2016-06-25 17:38:33 +02:00
set -- $INPUT_ARGS #Reset $@ for cli option reparsing.
2016-12-06 06:56:08 +01:00
OPTIND = 1 #To reset argument parsing, we must set OPTIND to 1.
2016-06-25 02:38:00 +02:00
2016-06-25 17:38:33 +02:00
parseArgs " $@ " #Reparse cli to overwrite local config options.
2016-12-06 06:56:08 +01:00
shift $(( OPTIND-1)) #Shift past all of the options to the file arguments.
OPTIND = 1 #Reset argument index.
2016-06-25 02:38:00 +02:00
2016-05-18 23:36:28 +02:00
2016-12-06 06:56:08 +01:00
THREADS = $( getThreads)
2016-03-13 08:04:18 +01:00
ARGNUM = $#
2016-06-25 02:38:00 +02:00
FILE_ARGS = " $@ "
2016-12-06 06:56:08 +01:00
IFS = ' ' read -r -a FILE_ARGS_ARRAY <<< $FILE_ARGS #Need to make arguments an array, for iteration over paths purposes.
#Choose which PROGRAM to run - from the multitude of things convmlv can do!
case " $PROGRAM " in
help )
help
; ;
version)
echo " $VERSION "
; ;
darkframe)
mkDarkframe
; ;
settings)
checkDeps #Check static dependencies.
printFileSettings
; ;
develop)
checkDeps #Check static dependencies.
2016-12-07 05:06:56 +01:00
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
2016-12-06 06:56:08 +01:00
; ;
esac
2016-03-05 21:29:51 +01:00
exit 0