Compare commits

...

7 Commits

28 changed files with 3737 additions and 2607 deletions

View File

@ -1,5 +1,10 @@
[code]
[b]v2.0.1[/b]: I'm back! Did some quick fixes. Also, there is now a bundled tarball available - no need to mess around with manual dependencies yourself anymore.
[size=8pt]*Updated PDF with all new features. Nothing is unexplained, now![/size]
[size=8pt]*Added some Mac compatibility.[/size]
[size=8pt]*DNG sequences now use symlinks instead of copying.[/size]
[size=8pt]*Fixed DNG sequence bug.[/size]
[b]v2.0.0[/b]: I think convmlv is the stablest it's ever been! Though I'm sure there's plenty more bugs to discover :).
[size=8pt]*Color Management: Real, 3D LUT-based gamma/gamut choices! See -g/-G. There is now minimal quality loss from sensor to image. Adds a dependency: color-core. [/size]

312
README.md
View File

@ -1,307 +1,45 @@
# convmlv #
RAW ML Formats to Workable Images/Movies Developer
RAW Formats (Magic Lantern) to Images/Movies Developer
=======
I needed a workflow to provide me full control over development for filmmaking with Magic Lantern (beyond mlrawviewer's excellent preview!), while keeping things simple by providing defaults for everything.
So, I wrote this: A converter from ML formats (RAW, MLV, DNG sequences) to many usable formats (EXR, DPX, and yes, Prores) with many, many features in between!
Generically, as a DNG developer, it's very capable as well, even if all the ML formats are ignored.
**So**, I wrote this: A program that converts from RAW formats (MLV, RAW, DNG, CR2) to workable formats (EXR, MOV, DPX, DNxHD, MJPEG, etc.) with many, many features in between (color management, filters, dual iso, demosaic, etc.)
I make shorts with convmlv :D so here's some examples of it (back at v1.7) in action!!
It's extensible, letting you write plugins controlling/filtering any leg of the journey from raw to developed. Config file syntax also makes it a kind of "make for productions"; with configs and one command, you can develop your whole project from unsorted raw footage to editable, proxied, organized stuff!
I use it myself :D so here's some shorts with it (back at v1.7) in action!!
http://youtu.be/yi-G7sXHB1M
http://youtu.be/yi-G7sXHB1M
See [http://www.magiclantern.fm/forum/index.php?topic=16799.0](http://www.magiclantern.fm/forum/index.php?topic=16799.0) for more info.
*See the primary development repo on my GitLab: https://git.sofusrose.com/so-rose/convmlv*
**The pdf found in the source and in the release, under docs->docs.pdf, is up to date. Refer to it for tutorials, tips, documentation, etc.!!**
## Installation
Supported platforms are Linux and Mac. To install, copy/paste the following into a terminal:
Full help page is below:
1. **Extract tarball**. Rename it "convmlv" and put it somewhere useful. `cd` to that directory.
2. **Install Deps**: `sudo apt-get install $(./convmlv.sh -K <number>)`. Replace <number> as indicated below:
* For Debain, use the number "0"
* For Fedora, replace `apt-get` with `yum` and use the number "2".
* For Mac, replace `sudo apt-get` with `brew` and use the number "3". *Requires Homebrew to be installed.
3. **Install Python deps**: `sudo python3 -m pip install $ (./convmlv.sh -Y)`
4. (Optional) **Add to Path**: `sudo ln -s $(pwd)/convmlv.sh /usr/local/bin/convmlv`
```text
Usage:
./convmlv.sh [FLAGS] [OPTIONS] files
INFO:
A program allowing you to develop ML files into workable formats. Many useful options are exposed.
--> Defaults: Compressed 16-bit Linear EXR. 10-bit Prores4444 MOV.
--> Color Defaults: Linear (1.0) Gamma on sRGB Gamut, using Camera White Balance.
--> Acceptable Inputs: MLV, RAW (requires raw2dng), Folder containing DNGs.
--> Option Input: From command line or config file (specify with -C).
--> Forum Post: http://www.magiclantern.fm/forum/index.php?topic=16799.
--> A note: BE CAREFUL WITH OPTIONS. Wrong values will give very strange errors. Read this page well!!
It's as simple or complex as you need it to be: 'convmlv -m <mlvfile>.mlv' is enough for good-looking output!
VERSION: 2.0.1
MANUAL DEPENDENCIES:
Place these in RES_PATH (see OPTIONS, BASIC). Keep in mind you also need dist. and pip packages.
--> See 'Dist Deps' and 'Python Deps'
You're done! For more info, see the Documentation (especially the PDF has a guide to this).
-- mlv_dump: Required binary. http://www.magiclantern.fm/forum/index.php?topic=7122.0
-- color-core: Required folder of LUTs. See convmlv repository.
-- sRange.py: Required script. See convmlv repository.
-- raw2dng: For DNG extraction from RAW. http://www.magiclantern.fm/forum/index.php?topic=5404.0
-- mlv2badpixels.sh: For bad pixel removal. https://bitbucket.org/daniel_fort/ml-focus-pixels/src
-- cr2hdr: For Dual ISO Development. Two links: http://www.magiclantern.fm/forum/index.php?topic=16799.0
-- balance.py: For Auto White Balance. See convmlv repository.
-- color-ext: Extra LUTs, providing more color resources. See convmlv repository.
## Documentation
Especially the PDF is designed as a tutorial; take a look!
OPTIONS, BASIC:
-v, --version version - Print out version string.
-h, --help help - Print out this help page.
-C, --config config - Designates config file to use.
-o, --outdir <path> OUTDIR - The path in which files will be placed.
-P, --res-path <path> RES_PATH - The path in which all manual dependencies are looked for.
--> Default: Current Directory.
--dcraw <path> DCRAW - The path to dcraw.
--mlv-dump <path> MLV_DUMP - The path to mlv_dump.
--raw-dump <path> RAW_DUMP - The path to raw2dng.
--badpixels <path> MLV_BP - The path to mlv2badpixels.sh (by dfort).
--cr-hdr <path> CR_HDR - The path to cr2hdr.
--srange <path> SRANGE - The path to sRange.py.
--balance <path> BAL - The path to balance.py.
--python <path> PYTHON - The path or command used to invoke Python 3. Default is python3 on Linux, python on Mac.
-T, --threads [int] THREADS - Override amount of utilized process threads. Default is MAX - 1.
OPTIONS, OUTPUT:
-i IMAGE - Will output image sequence.
-t [0:3] IMG_FMT - Image output format.
--> 0: EXR (default), 1: TIFF, 2: PNG, 3: Cineon (DPX)."
-m MOVIE - Will output a Prores4444 file.
-p [0:3] PROXY - Create proxies alongside main output.
--> 0: No proxies (Default). 1: H.264 proxy. 2: JPG proxy sequence. 3: Both.
--> JPG proxy will always be in sRGB Gamma/sRGB Gamut. H.264 proxy is color managed.
--> JPG proxy *won't* be developed w/o IMAGE. H.264 proxy *will* be developed no matter what, if specified here.
--> Why? JPG is for potential use in editing. H.264 is for a quick visual preview of convmlv's output.
-s [0%:100%] PROXY_SCALE - the size, in %, of the proxy output.
--> Default: 50%.
-k KEEP_DNGS - Specify if you want to keep the DNG files.
--> Run convmlv on the top level folder of former output to reuse saved DNGs from that run!
-r <start>-<end> FRAME_RANGE - Specify to process an integer frame range.
--> You may use the characters 's' and 'e', such that s = start frame, e = end frame.
--> Indexed from 0 to (# of frames - 1). Develops from 1 to ($ of frames)
--> A single number may be writted to develop that single frame.
--> DO NOT try to reuse DNGs while developing a larger frame range.
--uncompress UNCOMP - Turns off lossless image compression. Otherwise:
--> TIFF: ZIP, EXR: PIZ, PNG: lvl 0, DPX: RLE.
OPTIONS, RAW DEVELOPMENT:
-d [0:3] DEMO_MODE - Demosaicing algorithm. Higher modes are slower + better.
--> 0: Bilinear. 1: VNG (default). 2: PPG. 3: AHD.
-f FOUR_COLOR - Interpolate as RGBG. Fixes weirdness with VNG/AHD, at the cost of sharpness.
-H [0:9] HIGHLIGHT_MODE - Highlight management options.
--> 0: White, clipped highlights. 1: Unclipped but colored highlights. 2: The defail of 1, but adjusted to grey.
--> 3-9: Highlight reconstruction. Can cause flickering. Start at 5, then adjust to color (down) or to white (up).
-c [0:3] CHROMA_SMOOTH - Apply shadow/highlight chroma smoothing to the footage.
--> 0: None (default). 1: 2x2. 2: 3x3. 3: 5x5.
--> MLV input Only.
-n [int] WAVE_NOISE - Apply wavelet denoising.
--> Default: None. Subtle: 25. Medium: 50. Strong: 125.
-N <A>-<B> TEMP_NOISE - Apply temporal denoising.
--> A: 0 to 0.3. B: 0 to 5. A reacts to abrupt noise (splotches), B reacts to noise over time (fast motion causes artifacts).
--> Subtle: 0.03-0.04. High: 0.15-0.04. High, Predictable Motion: 0.15-0.07
-Q [i-i:i-i] HQ_NOISE - Apply 3D denoising filter.
--> In depth explanation: https://mattgadient.com/2013/06/29/in-depth-look-at-de-noising-in-handbrake-with-imagevideo-examples/ .
--> Spacial/Temporal (S/T). S will soften/blur/smooth, T will remove noise without doing that but may create artifacts.
--> Luma/Chroma (L/C). L is the detail, C is the color. Each one's denoising may be manipulated Spacially or Temporally.
--> Option Value: <LS>-<CS>:<LT>-<CT>
--> Weak: 2-1:2-3. Medium: 3-2:2-3. Strong: 7-7:5-5
--> DONT combine with TEMP_NOISE.
-O [i-i-i-i] REM_NOISE - Yet another spatial denoiser, with 4 choices of 24 modes.
--> See https://ffmpeg.org/ffmpeg-filters.html#removegrain for list of modes.
--> Option Value: <mode1>-<mode2>-<mode3>-<mode4>
--> I truly cannot tell you what values will be helpful to you; there are too many... Look at the link!
--shallow SHALLOW - Output smaller, 8-bit files.
--> Read why this is a bad idea: http://www.cambridgeincolour.com/tutorials/bit-depth.htm
OPTIONS, COLOR:
-g [0:4] GAMMA - Output gamma. A curve applied to the output, for easier viewing/grading.
--> 0: Standard (Around 2.2). 1: Linear (Default).
--> Requires color-ext: 2: Cineon. 3: C-Log2 4: S-Log3
--> "Standard" grades to the gamut specification, and to 2.2 if that's not given.
-G [0:6] GAMUT - Output gamut. The range of colors that can exist in the output.
--> 0: sRGB (Default). 1: Adobe RGB. 2: Rec.709. 3: XYZ (Always Linear Gamma).
--> Requires color-ext: 4: Rec2020 5: DCI-P3 6: Sony S-Gamut3.cine
**The Forum Thread** at [http://www.magiclantern.fm/forum/index.php?topic=16799.0](http://www.magiclantern.fm/forum/index.php?topic=16799.0) is always up to date.
-w [0:2] WHITE - This is a modal white balance setting.
--> 0: Auto WB (requires balance.py). 1: Camera WB (default). 2: No Change.
--> AWB uses the Grey's World algorithm.
-A [i:i:i:i] SHARP - Lets you sharpen, or blur, your footage.
--> BE CAREFUL. Wrong values will give you strange errors.
--> Size/Strength (S/T). S is the size of the sharpen/blur effect, T is the strength of the sharpen/blur effect.
--> Luma/Chroma (L/C). L is the detail, C is the color. Luma sharpening more effective.
--> Option Value: <LS>:<LT>:<CS>:<CT>
--> LS and CS must be ODD, between 3 and 63. Negative LT/CT values blur, while positive ones sharpen.
--> Strong Sharp: 7:3:7:3 Strong Blur: 7,-3:7,-3. Medium Sharp: 5:1:3:0
-l <path> LUT - Specify a LUT to apply after Color Management.
--> Supports cube, 3dl, dat, m3d.
--> Specify -l multiple times, to apply multiple LUTs in sequence.
-S [int] SATPOINT - Specify the 14-bit uint saturation point of your camera. You don't usually need to.
--> Worth setting globally, as it's a per-camera setting. Must be correct for highlight reconstruction/unclipped highlights.
--> Lower from 15000 if -H1 yields purple highlights, until they turn white.
--> You can determine the optimal value using the max pixel value of 'dcraw -D -j -4 -T'.
--white-speed [int] WHITE_SPD - Manually specify samples used to calculate AWB.
--allow-white-clip WHITE_CLIP - Let the White Balance multipliers clip.
OPTIONS, FEATURES:
-D DESHAKE - Auto-stabilize the video using ffmpeg's "deshake" module.
--> You may wish to crop/scale the output later, to avoid edge artifacts.
-u DUAL_ISO - Process as dual ISO.
--> Requires cr2hdr.
-b BADPIXELS - Fix focus pixels issue using dfort's script.
--> Requires mlv2badpixels.sh.
-a <path> BADPIXEL_PATH - Use your own .badpixels file. Does NOT require mlv2badpixels.sh
--> How to: http://www.dl-c.com/board/viewtopic.php?f=4&t=686
-F <path> DARKFRAME - This is the path to a "dark frame MLV"; effective for noise reduction.
--> How to: Record 5 sec w/lens cap on & same settings as footage. Pass MLV in here.
--> If the file extension is '.darkframe', the file will be used as a preaveraged dark frame.
-R <path> darkframe_output - Specify to create a .darkframe file from passed in MLV.
--> Usage: 'convmlv -R <path> <input>.MLV'
--> Averages <input>.MLV to create <path>.darkframe.
--> THE .darkframe EXTENSION IS ADDED FOR YOU.
OPTIONS, INFO:
-q settings - Output MLV settings.
-K [0:3] Dist Deps - Output package dependecies, for use with common package managers.
--> 0: Debian, 1: Ubuntu, 2: Fedora, 3: Homebrew (Mac)
--> Deps Install (Debian): sudo apt-get install $(./convmlv.sh -K 0)
--> Deps Install (Ubuntu): sudo apt-get install $(./convmlv.sh -K 1)
--> Deps Install (Fedora): sudo yum install $(./convmlv.sh -K 2)
--> Deps Install (Homebrew Mac): brew install $(./convmlv.sh -K 3)
-Y Python Deps - Lists Python dependencies. Works directly with pip.
-->Install (Cross-Platform): sudo python3 -m pip install $ (./convmlv -Y)
-M Manual Deps - Lists manual dependencies, which must be downloaded by hand.
--> Manually place all in RES_PATH. See http://www.magiclantern.fm/forum/index.php?topic=16799.0 .
COLOR MANAGEMENT:
INTRO Images aren't simple. They are often stored, processed, and viewed as a result of complex transformations usually called,
in applications, color management. Understanding it is required as a colourist, and encouraged as a DPs and Cinematographers.
--> Intro: http://www.cambridgeincolour.com/tutorials/color-management1.htm
--> Understanding Gamma: http://www.cambridgeincolour.com/tutorials/gamma-correction.htm
--> Color Spaces: http://www.cambridgeincolour.com/tutorials/color-spaces.htm
--> Conversions: http://www.cambridgeincolour.com/tutorials/color-space-conversion.htm
--> Monitor Calibration: http://www.cambridgeincolour.com/tutorials/monitor-calibration.htm
PIPELINE convmlv is a color managed application, designed to retain quality from RAW footage:
-- mlv_dump writes camera-specific color transformation matrices as metadata in developed DNGs.
--> This defines the camera's gamut.
-- dcraw applies these matrices, then transforms the newly developed image to the super-wide XYZ colorspace.
--> All color detail is preserved, and if now in a well-defined colorspace.
--> No gamma has been applied - the image is now Linear XYZ.
-- ffmpeg applies the specified (up to) x64 resolution 3D LUTs, in .cube format.
--> Use -g and -G to specify Gamma/Gamut combinations.
--> The output employs DATA, not LEGAL, values. The resulting image is flatter, but retains all shadow/highlight detail.
--> -l specified LUTs are applied afterwards.
3D LUTS The included LUTs, found in the convmlv repository, are key to convmlv's color management solution:
-- color-core: The required LUTs, including sRGB (default), Adobe RGB, and Rec709 in Standard and Linear gamma.
-- color-ext: Optional LUTs, including Rec2020, DCI-P3, etc. in Standard/Linear gammas, but also in Log formats.
Create Your Own LUTs using LUTCalc, for any grading format output: https://cameramanben.github.io/LUTCalc/ (watch his tutorials).
--> Note that convmlv only accepts up to 64x64x64 LUTs. You can resize LUTs using pylut (https://pypi.python.org/pypi/pylut).
--> The pylut command to resize is 'pylut <yourx65lut>.cube --resize 64'. Alternatively, you can use pylut from Python (2X only).
--> I reccommend Legal --> Data LUTs, as this conserves shadow/highlight detail for grading. Legal --> Legal looks better, but with detail loss.
CONFIG FILE:
Config files, another way to specify options, can save you time & lend you convenience in production situations.
GLOBAL: /home/sofus/convmlv.conf
LOCAL: Specify -C/--config.
SYNTAX:
Most options listed above have an uppercased VARNAME, ex. OUTDIR. You can specify such options in config files, as such:
<VARNAME> <VALUE>
One option per line only. Indentation by tabs or spaces is allowed, but not enforced.
Comments Lines starting with # are comments.
You may name a config using:
CONFIG_NAME <name>
Flags If the value is a true/false flag (ex. IMAGE), simply specifying VARNAME is enough. There is no VALUE.
OPTION ORDER OF PRECEDENCE Options override each other as such:
-LOCAL options overwrite GLOBAL options.
-COMMAND LINE options overwrite LOCAL & GLOBAL options.
-FILE SPECIFIC options overwrite ALL ABOVE options.
File-Specific Block: A LOCAL config file lets you specify options for specific input names:
/ <TRUNCATED INPUTNAME>
...options here will only be
*
You must use the truncated (no .mlv or .raw) input name after the /. Nested blocks will fail.
With a single config file, you can control the development options of multiple inputs as specifically and/or generically
as you want. Batch developing everything can then be done with a single, powerful commmand.
**The PDF** found *in the release* is up to date, including tutorials, tips, explanations, plugin API, and more.
**The Help Page** is the most up to date; just run `convmlv -h` or look at docs-->MANPAGE in the release tarball.
Contact me with any feedback or questions at convmlv@sofusrose.com, PM me (so-rose) on the ML forums, or post on the thread!
## Development
To build the PDF and MANPAGE using LATEX, run `docs/buildDocs.sh`. You can clean it up using `docs/cleanDocs.sh`.
To make a release tarball, simply place all the manual binary deps into the `binaries` dir and run `./mkrelease.sh`. Optionally, you can call `./mkrelease bare` to make a release without included examples.
```
Run 'sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" docs/MANPAGE' to strip colors from MANPAGE after generating through less. This is done automatically in 'docs/buildDocs.sh.
The source code is located in `src`, where you'll find bash and Python code, as well as the builtin plugins. convmlv.sh itself imports all the src's, and acts as a kind of program selector; develop is but one option.

View File

@ -1,5 +1,6 @@
Besides the tarball, you need a few external deps.
For your distribution:
First, install libc6:i386 for 64-bit systems.
@ -9,14 +10,7 @@ Ubuntu: sudo apt-get install $(./convmlv.sh -K 1)
Fedora: sudo yum install $(./convmlv.sh -K 2)
Mac (Homebrew): brew install $(./convmlv.sh -K 3)
For Python (make sure you're using python3):
For Python (make sure you're using Python 3.X):
sudo python3 -m pip install $(./convmlv -Y)
Binary Source Code:
mlv2badpixels.sh: http://www.magiclantern.fm/forum/index.php?topic=16054
raw2dng: http://www.magiclantern.fm/forum/index.php?topic=5404.0
mlv_dump: http://www.magiclantern.fm/forum/index.php?topic=7122.0
cr2hdr: http://www.magiclantern.fm/forum/index.php?topic=7139.0

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1,27 @@
Binary Source Code, distributed under GPLv2:
# Copyright (C) 2016 Magic Lantern Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#/
Source code found at links below:
mlv2badpixels.sh: http://www.magiclantern.fm/forum/index.php?topic=16054
raw2dng: http://www.magiclantern.fm/forum/index.php?topic=5404.0
mlv_dump: http://www.magiclantern.fm/forum/index.php?topic=7122.0
cr2hdr: http://www.magiclantern.fm/forum/index.php?topic=7139.0

56
convmlv.geany 100644
View File

@ -0,0 +1,56 @@
[editor]
line_wrapping=false
line_break_column=72
auto_continue_multiline=true
[file_prefs]
final_new_line=true
ensure_convert_new_lines=false
strip_trailing_spaces=false
replace_tabs=false
[indentation]
indent_width=4
indent_type=1
indent_hard_tab_width=8
detect_indent=false
detect_indent_width=false
indent_mode=2
[project]
name=convmlv
base_path=/home/sofus/subhome/src/convmlv
description=
[long line marker]
long_line_behaviour=1
long_line_column=72
[files]
current_page=4
FILE_NAME_0=15352;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fcore%2Fdevelop.sh;0;4
FILE_NAME_1=3473;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fcore%2Fparsing.sh;0;4
FILE_NAME_2=1070;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fcore%2FargFuncs.sh;0;4
FILE_NAME_3=3159;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fconvmlv.sh;0;4
FILE_NAME_4=1199;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fcore%2Fproc.sh;0;4
FILE_NAME_5=2653;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fdocumentation%2Fhelp.sh;0;4
FILE_NAME_6=0;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fdocumentation%2FTODO.sh;0;4
FILE_NAME_7=0;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fhelpers%2Ferror.sh;0;4
FILE_NAME_8=0;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fhelpers%2Fformat.sh;0;4
FILE_NAME_9=0;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fhelpers%2Fplatform.sh;0;4
FILE_NAME_10=2653;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fhelpers%2Futility.sh;0;4
FILE_NAME_11=0;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2FimgProcessing%2FimgMath.sh;0;4
FILE_NAME_12=0;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fprograms%2Fcaliframe.sh;0;4
FILE_NAME_13=1;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2Fprograms%2FshotSettings.sh;0;4
FILE_NAME_14=0;Python;0;EUTF-8;1;1;0;%2Fhome%2Fsofus%2Fsubhome%2Fsrc%2Fconvmlv%2Fsrc%2FimgProcessing%2Fbalance.py;0;4
[VTE]
last_dir=/home/sofus
[prjorg]
source_patterns=*.c;*.C;*.cpp;*.cxx;*.c++;*.cc;*.m;
header_patterns=*.h;*.H;*.hpp;*.hxx;*.h++;*.hh;
ignored_dirs_patterns=.*;CVS;
ignored_file_patterns=*.o;*.obj;*.a;*.lib;*.so;*.dll;*.lo;*.la;*.class;*.jar;*.pyc;*.mo;*.gmo;
generate_tag_prefs=0
external_dirs=

2532
convmlv.sh

File diff suppressed because it is too large Load Diff

24
deploy.sh 100755
View File

@ -0,0 +1,24 @@
#!/bin/bash
VERSION=$(echo "$(./convmlv.sh -v)" | sed -e 's/\./\_/g')
REMOTE=sofus@yeti
if [[ $OSTYPE == "linux-gnu" ]]; then
PLATFORM="linux"
elif [[ $OSTYPE == "darwin11" ]]; then
PLATFORM="mac"
else
echo "Platform not yet supported! Contact me at contact@sofusrose.com."
fi
rsync -avzP release/convmlv-${VERSION}-${PLATFORM}.tar.gz $REMOTE:/data/main/convmlv/
ssh $REMOTE VERSION=$VERSION PLATFORM=$PLATFORM 'bash -s' << 'ENDSSH'
cd /data/main/convmlv
tar -xvzf /data/main/convmlv/convmlv-$VERSION-$PLATFORM.tar.gz
rm /data/main/convmlv/convmlv-$VERSION-$PLATFORM.tar.gz
ENDSSH
echo -e "\nRemember to update apt dependencies on $REMOTE"!

View File

@ -7,4 +7,6 @@ DDIR="$ROOT_DIR/docs"
$ROOT_DIR/convmlv.sh -h | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" > $DDIR/MANPAGE
pdflatex $DDIR/docs.tex #> /dev/null
pdflatex $DDIR/docs.tex #> /dev/null #Compile twice to get TOC to show.
rm -f $DDIR/docs.aux $DDIR/docs.log $DDIR/docs.out $DDIR/docs.toc $DDIR/texput.log > /dev/null
mv ./docs.pdf $DDIR
rm -f ./docs.aux ./docs.log ./docs.out ./docs.toc ./texput.log > /dev/null

12
docs/cleanDocs.sh 100755
View File

@ -0,0 +1,12 @@
#!/bin/bash
#Run from within docs/.
ROOT_DIR="/home/sofus/subhome/src/convmlv"
DDIR="$ROOT_DIR/docs"
#~ rm -f ./docs.aux ./docs.log ./docs.out ./docs.toc ./texput.log > /dev/null #Remove any local bullshit.
cd $DDIR
rm -f $DDIR/docs.aux $DDIR/docs.log $DDIR/docs.out $DDIR/docs.toc $DDIR/texput.log $DDIR/MANPAGE $DDIR/docs.pdf > /dev/null

Binary file not shown.

20
mkBinaries.sh 100755
View File

@ -0,0 +1,20 @@
#!/bin/bash
#Run from convmlv root. Builds all ML-specific binaries.
cd binaries
#Remove old binaries.
rm cr2hdr mlv_dump raw2dng
#Build Binaries
git clone https://git.sofusrose.com/so-rose/magic-tools.git
#cd magic-tools
magic-tools/prepAll.sh
magic-tools/tools/mkToolStack.sh
cp magic-tools/tools/latest/* .
#No place to build mlv2badpixels.sh from, unfortunately.
rm -rf magic-tools

View File

@ -1,28 +1,57 @@
#!/bin/bash
VERSION=$(echo "$(./convmlv.sh -v)" | sed -e 's/\./\_/g')
TYPE=$1
if [[ -z "${TYPE// }" ]]; then TYPE="examples"; fi
#HOW TO USE (Linux and Mac):
# 1. Update version above.
# 2. Put mlv2badpixels.sh, mlv_dump, raw2dng, and cr2hdr into a "binaries" folder in the repository.
# 3. Run this script, with one argument representing the path to the binaries.
# 4. A release tarball will automatically be created in "release" in the repository.
# 1. Make sure everything is up to date.
# 2. Put mlv2badpixels.sh, mlv_dump, raw2dng, and cr2hdr into the "binaries" folder in the repository.
# 4. Run the script with "bare" or "examples" as argument. "examples" is default.
# 3. A release tarball will automatically be created in "release" in the repository.
## It's reccommended that BINPATH is a folder in REP_PATH.
REP_PATH="$(pwd)"
BINPATH="${REP_PATH}/binaries"
SRCPATH="${REP_PATH}/src"
DOCPATH="${REP_PATH}/docs"
RELEASE="${REP_PATH}/release"
mkdir -p "$RELEASE"
#Determine Platform
if [[ $OSTYPE == "linux-gnu" ]]; then
PLATFORM="linux"
elif [[ $OSTYPE == "darwin11" ]]; then
elif [[ $OSTYPE == "darwin11" || $OSTYPE == "darwin15" ]]; then
PLATFORM="mac"
else
echo "Platform not yet supported! Contact me at contact@sofusrose.com."
fi
cd "$BINPATH"
tar -czvf $RELEASE/convmlv-${VERSION}-${PLATFORM}.tar.gz ../balance.py mlv2badpixels.sh mlv_dump raw2dng cr2hdr ../sRange.py ../CHANGELOG ../licence ../convmlv.sh ../color-core/ ../color-ext ../DEPENDENCIES ../docs/MANPAGE ../docs/docs.pdf ../docs/workflow.txt ../configs/*
TARBALL="$RELEASE/convmlv-${VERSION}-${PLATFORM}.tar.gz"
#Build Docs
$DOCPATH/cleanDocs.sh > /dev/null
$DOCPATH/buildDocs.sh > /dev/null
#Make tarball
cd $REP_PATH
case $TYPE in
examples)
tar -czvf "$TARBALL" binaries/ src/ CHANGELOG 7D_badpixels.txt licence convmlv.sh \
color-core/ color-ext docs/MANPAGE docs/docs.pdf docs/workflow.txt configs/*
;;
bare)
tar -czvf "$TARBALL" binaries/ src/ CHANGELOG licence convmlv.sh \
color-core/ color-ext docs/MANPAGE docs/docs.pdf
;;
esac
#Sign & Verify
gpg -b "$TARBALL"
$DOCPATH/cleanDocs.sh > /dev/null
gpg --verify "${TARBALL}.sig" "$TARBALL"

View File

@ -0,0 +1,365 @@
argOUTDIR() {
val="$1"
OUTDIR="$val"
SETTINGS[path_output]="$val"
}
argBIN_PATH() {
val="$1"
BIN_PATH=="$val"
SETTINGS[path_bin]=="$val"
}
argDCRAW() {
val="$1"
DCRAW="$val"
SETTINGS[bin_dcraw]="$val"
}
argMLV_DUMP() {
val="$1"
MLV_DUMP="$val"
SETTINGS[bin_mlvdump]="$val"
}
argRAW_DUMP() {
val="$1"
RAW_DUMP="$val"
SETTINGS[bin_rawdump]="$val"
}
argMLV_BP() {
val="$1"
MLV_BP="$val"
}
argCR_HDR() {
val="$1"
CR_HDR="$val"
}
argPYTHON() {
val="$1"
PYTHON="$val"
}
argTHREADS() {
val="$1"
THREADS="$val"
}
argIMAGE() {
IMAGES=true
}
argIMG_FMT() {
val="$1"
case ${val} in
"0") IMG_FMT="exr"
;;
"1") IMG_FMT="tiff"
;;
"2") IMG_FMT="png"
;;
"3") IMG_FMT="dpx"
;;
*) invOption "Invalid Image Format Choice: ${mode}"
;;
esac
}
argMOVIE() {
MOVIE=true
}
argPROXY() {
val="$1"
case ${val} in
"0") isJPG=false; isH264=false
;;
"1") isJPG=false; isH264=true
;;
"2") isJPG=true; isH264=false
;;
"3") isJPG=true; isH264=true
;;
*) invOption "Invalid Proxy Choice: ${PROXY}"
;;
esac
}
argPROXY_SCALE() {
val="$1"
PROXY_SCALE=val
proxy_num=`echo "$PROXY_SCALE" | cut -d'%' -f 1`
if [[ ! ( ($proxy_num -le 100 && $proxy_num -ge 5) && $proxy_num =~ ^-?[0-9]+$ ) ]];then
invOption "Invalid Proxy Scale: ${PROXY_SCALE}"
fi
}
argKEEP_RAWS() {
val="$1"
KEEP_DNGS=true
}
argFRAME_RANGE() {
val="$1"
RANGE_BASE="$val"
isFR=false
}
argUNCOMP() {
isCOMPRESS=false
}
argDEMO_MODE() {
val="$1"
DEMO_MODE="$val"
}
argHIGHLIGHT_MODE() {
val="$1"
HIGHLIGHT_MODE="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}
argOUTDIR() {
val="$1"
OUTDIR="$val"
}

560
src/core/develop.sh 100644
View File

@ -0,0 +1,560 @@
setRange() {
#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.
FRAME_RANGE="1-${FRAMES}"
FRAME_START="1"
FRAME_END=$FRAMES
else
base=$(echo $RANGE_BASE | sed -e 's:s:0:g' | sed -e "s:e:$(echo "$FRAMES - 1" | bc):g") #FRAMES is incremented in a moment.
#~ FRAME_RANGE_ZERO="$(echo $base | cut -d"-" -f1)-$(echo $base | cut -d"-" -f2)" #Number from 0. Useless as of now.
FRAME_RANGE="$(echo "$(echo $base | cut -d"-" -f1) + 1" | bc)-$(echo "$(echo $base | cut -d"-" -f2) + 1" | bc)" #Number from 1.
FRAME_START=$(echo ${FRAME_RANGE} | cut -d"-" -f1)
FRAME_END=$(echo ${FRAME_RANGE} | cut -d"-" -f2)
#Some error checking - out of range values default to start and end.
if [[ $FRAME_END -gt $FRAMES || $FRAME_END -lt $FRAME_START || $FRAME_END -lt 1 ]]; then FRAME_END=$FRAMES; fi
if [[ $FRAME_START -lt 1 || $FRAME_START -gt $FRAME_END ]]; then FRAME_START=1; fi
FRAME_RANGE="${FRAME_START}-${FRAME_END}"
fi
}
develop() {
#Usage: develop arg -- globals are treated as a large, passed in data structure.
#Desc: Develops footage according to the current configuration of global variables.
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
local BASE="$(basename "$ARG")" #BASE is the name of the file.
local TRUNC_ARG="${BASE%.*}" #TRUNC_ARG is the name of the file, sans extension.
local EXT="${BASE##*.}" #EXT is the file's extension.
if [[ "${EXT}" == ".${BASE}" ]]; then EXT=""; fi #If the input is a folder, it will have no extension.
local SCALE=`echo "($(echo "${PROXY_SCALE}" | sed 's/%//') / 100) * 2" | bc -l` #Get scale as factor for halved video, *2 for 50%
setBL=true
#Color Management - The Color LUT is chosen + applied.
#We define what "STANDARD" means. Gamma 2.2 if it's not specifically defined.
if [[ $COLOR_GAMUT != "xyz" ]]; then
#This block defines what a "STANDARD" gamma means for each gamut.
if [[ $COLOR_GAMMA == "STANDARD" ]]; then
if [[ $COLOR_GAMUT == "argb" || $COLOR_GAMUT == "ssg3c" ]]; then #List of gamuts with Gamma 2.2 .
COLOR_GAMMA="y2*2"
elif [[ $COLOR_GAMUT == "aces" ]]; then #ACES is linear.
COLOR_GAMMA="lin"
else
COLOR_GAMMA=$COLOR_GAMUT #Otherwise, "standard" is the name of the gamut.
fi
fi
for lutSource in "${COLOR_LUTS[@]}"; do
colorName="${lutSource}/lin_xyz--${COLOR_GAMMA}_${COLOR_GAMUT}.cube"
#~ colorName="${lutSource}/lin_srgb--${COLOR_GAMMA}_${COLOR_GAMUT}.cube"
if [[ -f $colorName ]]; then
COLOR_VF="lut3d=$colorName"
colorDesc="Color Management LUT"
FFMPEG_FILTERS=true
fi
done
if [[ $COLOR_VF == "" ]]; then
error "Specified LUT not found! Is color-ext loaded?\n"
fi
fi #COLOR_VF is nothing if the gamut is xyz - it'll pass directly out of dcraw/IM, without LUT application.
#Construct the FFMPEG filters.
FINAL_SCALE="scale=trunc(iw/2)*${SCALE}:trunc(ih/2)*${SCALE}"
if [[ $FFMPEG_FILTERS == true ]]; then
V_FILTERS="-vf $(joinArgs , ${COLOR_VF} ${LUTS[@]} ${HQ_NOISE} ${TEMP_NOISE} ${REM_NOISE} ${SHARP} ${DESHAKE})"
V_FILTERS_PROX="-vf $(joinArgs , ${COLOR_VF} ${LUTS[@]} ${HQ_NOISE} ${TEMP_NOISE} ${REM_NOISE} ${SHARP} ${DESHAKE} ${FINAL_SCALE})" #Proxy filter set adds the FINAL_SCALE component.
#Created formatted array of filters, FILTER_ARR.
compFilters=()
declare -a compFilters=("${colorDesc}" "${sharpDesc}" "${hqDesc}" "${tempDesc}" "${remDesc}" "${deshakeDesc}" "${lutDesc}")
for v in "${compFilters[@]}"; do if test "$v"; then FILTER_ARR+=("$v"); fi; done
else
V_FILTERS_PROX="-vf ${FINAL_SCALE}"
fi
#List remaining files to process.
local remFiles=("${FILE_ARGS_ARRAY[@]:$ARG_INC:$ARGNUM}") #Make a new array from slice.
#Assemble list of files left to process.
list=""
for item in "${remFiles[@]}"; do
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 [ -z "${list}" ]; then
list=$(formArg "$ARG" "selected")
#~ if [[ $itemBase == $(basename $ARG) ]]; then
#~ list="${itemDir}/$(selected "${itemBase%.*}")${itemExt}"
#~ else
#~ list="${itemDir}/$(bold ${itemBase%.*})${itemExt}"
#~ fi
else
list="${list}, $(formArg "$ARG" "deselected")"
fi
done
if [[ ${#remFiles[@]} == 1 ]]; then
echo -e "\n$(bold "${#remFiles[@]} File Left to Process:") ${list}\n"
else
echo -e "\n$(bold "${#remFiles[@]} Files Left to Process:") ${list}\n"
fi
#PREPARATION
#Establish Basic Directory Structure.
OUTDIR=$(readlinkF "$OUTDIR")
if [ $OUTDIR != $PWD ]; then
mkdir -p $OUTDIR
#NO RISKS. WE REMEMBER THE LUT.py. RIP ad-hoc HALD LUT implementation :'( .
fi
local FILE="${OUTDIR}/${TRUNC_ARG}"
local TMP="${FILE}/tmp_${TRUNC_ARG}"
#DNG argument, reused or not. Also, create FILE and TMP.
DEVELOP=true
if [[ ( -d $ARG ) && ( ( `basename ${ARG} | cut -c1-3` == "dng" && -f "${ARG}/../settings.txt" ) || ( `basename ${ARG}` == $TRUNC_ARG && -f "${ARG}/settings.txt" ) ) ]]; then #If we're reusing a dng sequence, copy over before we delete the original.
echo -e "\033[1m${TRUNC_ARG}:\033[0m Moving DNGs from previous run...\n" #Use prespecified DNG sequence.
#User may specify either the dng_ or the trunc_arg folder; must account for both.
if [[ `folderName ${ARG}` == $TRUNC_ARG && -d "${ARG}/dng_${TRUNC_ARG}" ]]; then #Accounts for the trunc_arg folder.
ARG="${ARG}/dng_${TRUNC_ARG}" #Set arg to the dng argument.
elif [[ `folderName ${ARG}` == $TRUNC_ARG && `echo "$(basename ${ARG})" | cut -c 1-3` == "dng" ]]; then #Accounts for the dng_ folder.
TRUNC_ARG=`echo $TRUNC_ARG | cut -c5-${#TRUNC_ARG}`
else
echo -e "\033[0;31m\033[1mCannot reuse - DNG folder does not exist! Skipping argument.\033[0m"
return 1
fi
DNG_LOC=${OUTDIR}/tmp_reused
mkdir -p ${OUTDIR}/tmp_reused
find $ARG -iname "*.dng" | xargs -I {} mv {} $DNG_LOC #Moving DNGs to temporary location.
reuseSet "$ARG"
#~ dngSet "$DNG_LOC"
#~ 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.
#~ KELVIN=`cat ${ARG}/../settings.txt | grep "WBKelvin" | cut -d $" " -f2`
cp "${ARG}/../settings.txt" $DNG_LOC
oldARG="${ARG}"
DIRNAME=$(dirname "$oldARG")
BASE="$(basename "$oldARG")"
EXT=""
FILE="${OUTDIR}/${TRUNC_ARG}"
TMP="${FILE}/tmp_${TRUNC_ARG}" #Remove dng_ from ARG by redefining basic constants. Ready to go!
ARG="${FILE}/dng_${TRUNC_ARG}" #Careful. This won't exist till later.
dngLocClean() {
find $DNG_LOC -iname "*.dng" | xargs -I {} mv {} $oldARG
rm -rf $DNG_LOC
}
mkdirS $FILE dngLocClean; if [ $? -eq 1 ]; then return 1; fi
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.
cp "${DNG_LOC}/settings.txt" $FILE
setBL=false
DEVELOP=false
rm -r $DNG_LOC
elif [ -d $ARG ]; then #If it's a DNG sequence, but not a reused one.
mkdirS $FILE; if [ $? -eq 1 ]; then return 1; fi
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.
FPS=24 #Set it to a safe default.
FRAMES=$(find ${ARG} -name "*.dng" | wc -l)
setRange
i=1
for dng in $ARG/*.dng; do
ln -s $dng $(printf "${TMP}/${TRUNC_ARG}_%06d.dng" $i) #Since we're not touching the DNGs, we can link them from wherever to TMP!!! :) Super duper fast.
let i++
if [[ i -gt $FRAME_END ]]; then break; fi
done
dngSet
DEVELOP=false #We're not developing DNG's; we already have them!
else
mkdirS $FILE; if [ $? -eq 1 ]; then return 1; fi
mkdirS $TMP; if [ $? -eq 1 ]; then return 1; fi
fi
#Darkframe Averaging
if [[ $useDF == true ]]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Creating darkframe for subtraction...\n"
avgFrame="${TMP}/avg.darkframe" #The path to the averaged darkframe file.
#~ There was a bug - retest this.
darkBase="$(basename "$DARKFRAME")"
darkExt="${darkBase##*.}"
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
RES_DARK=`echo "$(${MLV_DUMP} -v -m ${avgFrame})" | grep "Res" | sed 's/[[:alpha:] ]*: //'`
DARK_PROC="-s ${avgFrame}"
fi
#Develop sequence if needed.
if [ $DEVELOP == true ]; then
echo -e "\033[1m${TRUNC_ARG}:\033[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 extension is RAW, we want to convert to MLV. All the interesting features are MLV-only, because of mlv_dump's amazingness.
if [ $EXT == "MLV" ] || [ $EXT == "mlv" ]; then
# Read the header.
mlvSet
setRange
# Error checking: Darkframe resolution must match resolution.
if [[ (! -z $RES_DARK) && $RES_DARK != $RES_IN ]]; then
invOption "Darkframe Resolution doesn't match MLV Resolution! Use another darkframe!"
fi
#Dual ISO might want to do the chroma smoothing. In which case, don't do it now!
if [ $DUAL_ISO == true ]; then
smooth="--no-cs"
else
smooth=$CHROMA_SMOOTH
fi
#Create new MLV with adequate number of frames, if needed.
REAL_MLV=$ARG
REAL_FRAMES=$FRAMES
if [ $isFR == false ]; then
REAL_MLV="${TMP}/newer.mlv"
$MLV_DUMP $ARG -o ${REAL_MLV} -f ${FRAME_RANGE} >/dev/null 2>/dev/null
REAL_FRAMES=`${MLV_DUMP} ${REAL_MLV} | awk '/Processed/ { print $2; }'`
fi
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.
for range in "${fileRanges[@]}"; do echo $range; done | #For each frame range, assign a thread.
xargs -I {} -P $THREADS -n 1 \
bash -c "dng_par '{}' '$MLV_DUMP' '$REAL_MLV' '$DARK_PROC' 'no_data' '$smooth' '$TMP' '$FRAME_END' '$TRUNC_ARG' '$FRAME_START'"
#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 "\n"
count=$FRAME_START
for range in "${fileRanges[@]}"; do #Go through the subfolders sequentially
tmpOut=${TMP}/${range} #Use temporary folder. It will be named the same as the frame range.
for dng in ${tmpOut}/*.dng; do
if [ $count -gt $FRAME_END ]; then echo "ERROR! Count greater than end!"; fi
mv $dng $(printf "${TMP}/${TRUNC_ARG}_%06d.dng" $count) #Move dngs out sequentially, numbering them properly.
let count++
done
rm -r $tmpOut #Remove the now empty subfolder
done
elif [ $EXT == "RAW" ] || [ $EXT == "raw" ]; then
rawSet
setRange
echo -e $rawStat
FPS=`$RAW_DUMP $ARG "${TMP}/${TRUNC_ARG}_" | awk '/FPS/ { print $3; }'` #Run the dump while awking for the FPS.
fi
#~ BLACK_LEVEL=$(exiftool -BlackLevel -s -s -s ${TMP}/${TRUNC_ARG}_$(printf "%06d" $(echo "$FRAME_START" | bc)).dng)
fi
setRange #Just to be sure the frame range was set, in case the input isn't MLV.
BLACK_LEVEL=$(exiftool -BlackLevel -s -s -s ${TMP}/${TRUNC_ARG}_$(printf "%06d" $(echo "$FRAME_START" | bc)).dng) #Use the first DNG to get the correct black level.
prntSet > $FILE/settings.txt
sed -i -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" $FILE/settings.txt #Strip escape sequences.
#Create badpixels file.
if [ $isBP == true ] && [ $DEVELOP == true ]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Generating badpixels file...\n"
bad_name="badpixels_${TRUNC_ARG}.txt"
gen_bad="${TMP}/${bad_name}"
touch $gen_bad
if [ $EXT == "MLV" ] || [ $EXT == "mlv" ]; then
$MLV_BP -o $gen_bad $ARG
elif [ $EXT == "RAW" ] || [ $EXT == "raw" ]; then
$MLV_BP -o $gen_bad $ARG
fi
if [[ ! -z $BADPIXEL_PATH ]]; then
if [ -f "${gen_bad}" ]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Concatenating with specified badpixels file...\n"
mv "${gen_bad}" "${TMP}/bp_gen"
cp $BADPIXEL_PATH "${TMP}/bp_imp"
{ cat "${TMP}/bp_gen" && cat "${TMP}/bp_imp"; } > "${gen_bad}" #Combine specified file with the generated file.
else
cp $BADPIXEL_PATH "${gen_bad}"
fi
fi
BADPIXELS="-P ${gen_bad}"
elif [[ ! -z $BADPIXEL_PATH ]]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Using specified badpixels file...\n"
bad_name="badpixels_${TRUNC_ARG}.txt"
gen_bad="${TMP}/${bad_name}"
cp $BADPIXEL_PATH "${gen_bad}"
BADPIXELS="-P ${gen_bad}"
fi
#Dual ISO Conversion
if [ $DUAL_ISO == true ]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Combining Dual ISO...\n"
#Original DNGs will be moved here.
oldFiles="${TMP}/orig_dng"
mkdirS $oldFiles; if [ $? -eq 1 ]; then return 1; fi
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!"
fi
find $TMP -maxdepth 1 -name "*.dng" -print0 | sort -z | xargs -0 -I {} -P $THREADS -n 1 \
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.
echo -e "\n"
fi
if [ $setBL == true ]; then
echo -e "BlackLevel: ${BLACK_LEVEL}" >> $FILE/settings.txt #Black level must now be set.
fi
#Get White Balance correction factor.
if [ $GEN_WHITE == true ]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Generating WB...\n"
#Calculate n, the distance between samples.
frameLen=$(echo "$FRAME_END - $FRAME_START + 1" | bc) #Offset by one to avoid division by 0 errors later. min value must be 1.
#A point of improvement, this.
if [[ $WHITE_SPD -gt $frameLen ]]; then
WHITE_SPD=$frameLen
fi
n=`echo "${frameLen} / ${WHITE_SPD}" | bc`
toBal="${TMP}/toBal"
mkdirS $toBal; if [ $? -eq 1 ]; then return 1; fi
#Develop every nth file for averaging.
local i=0
local t=0
for file in $TMP/*.dng; do
if [ `echo "(${i}+1) % ${n}" | bc` -eq 0 ]; then
$DCRAW -q 0 $BADPIXELS -r 1 1 1 1 -g $GAMMA -k $BLACK_LEVEL $SATPOINT -o 0 -T "${file}"
name=$(basename "$file")
mv "$TMP/${name%.*}.tiff" $toBal #TIFF MOVEMENT. We use TIFFs here because it's easy for dcraw and Python.
let t++
fi
echo -e "\033[2K\rWB Development: Sample ${t}/$(echo "${frameLen} / $n" | bc) (Frame: $(echo "${i} + 1" | bc)/${FRAME_END})\c"
let i++
done
echo ""
#Calculate + store result into a form dcraw likes.
echo -e "Calculating Auto White Balance..."
BALANCE=`$BAL $toBal`
elif [ $CAMERA_WB == true ]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Retrieving Camera White Balance..."
for file in $TMP/*.dng; do
#dcraw a single file verbosely, to get the camera multiplier with awk.
BALANCE=`$DCRAW -T -w -v -c ${file} 2>&1 | awk '/multipliers/ { print $2, $3, $4 }'`
break
done
else #Something must always be set.
echo -e "\033[1m${TRUNC_ARG}:\033[0m Ignoring White Balance..."
BALANCE="1.000000 1.000000 1.000000"
fi
#Finally, set the white balance after determining it.
if [ $isScale = false ]; then
BALANCE=$(normToOne "$BALANCE")
fi
green=$(getGreen "$BALANCE")
WHITE="-r ${BALANCE} ${green}"
echo -e "Correction Factor (RGBG): ${BALANCE} ${green}\n"
#Move .wav.
SOUND_PATH="${TMP}/${TRUNC_ARG}_.wav"
if [ ! -f $SOUND_PATH ]; then
echo -e "*Not moving .wav, because it doesn't exist.\n"
else
echo -e "*Moving .wav.\n"
cp $SOUND_PATH $FILE
fi
#PROCESSING
#IMAGE PROCESSING
if [ $IMAGES == true ] ; then
echo -e "$(bold ${TRUNC_ARG}:) Processing Image Sequence from Frame ${FRAME_START} to ${FRAME_END}...\n"
#Define Image Directories, Create SEQ directory
local SEQ="${FILE}/${IMG_FMT}_${TRUNC_ARG}"
local PROXY="${FILE}/proxy_${TRUNC_ARG}"
mkdirS $SEQ; if [ $? -eq 1 ]; then return 1; fi
if [ $isJPG == true ]; then
mkdirS $PROXY; if [ $? -eq 1 ]; then return 1; fi
fi
#Run the parallel image processing
iProc
#FFMPEG Filter Application: Temporal Denoising, 3D LUTs, Deshake, hqdn Denoising, removegrain denoising, unsharp so far.
#See construction of $V_FILTERS in PREPARATION.
if [[ $FFMPEG_FILTERS == true ]]; then
tmpFiltered="${TMP}/filtered"
tmpUnfiltered="${TMP}/unfiltered"
mkdir $tmpFiltered
mkdir $tmpUnfiltered
#Give correct output.
echo -e "\033[1mApplying Filters:\033[0m $(joinArgs ", " "${FILTER_ARR[@]}")...\n"
if [[ $IMG_FMT == "exr" ]]; then
echo -e "Note: EXR filtering lags due to middle-step conversion (ffmpeg has no EXR encoder).\n"
img_res=$(identify ${SEQ}/${TRUNC_ARG}_$(printf "%06d" $(echo "$FRAME_START" | bc)).${IMG_FMT} | cut -d$' ' -f3)
tConvert "$SEQ" "$tmpUnfiltered" "$IMG_FMT" "dpx"
ffmpeg -start_number $FRAME_START -f image2 -vcodec dpx -s "${img_res}" -r $FPS -loglevel panic -stats -i "${tmpUnfiltered}/${TRUNC_ARG}_%06d.dpx" \
$V_FILTERS -pix_fmt rgb48be -vcodec dpx -n -r $FPS -start_number $FRAME_START ${tmpFiltered}/${TRUNC_ARG}_%06d.dpx
tConvert "$tmpFiltered" "$SEQ" "dpx" "$IMG_FMT"
else
applyFilters "$SEQ"
fi
echo ""
fi
fi
#MOVIE PROCESSING
VID="${FILE}/${TRUNC_ARG}"
SOUND="-i ${TMP}/${TRUNC_ARG}_.wav"
SOUND_ACTION="-c:a mp3 -b:a 320k"
if [ ! -f $SOUND_PATH ]; then
SOUND=""
SOUND_ACTION=""
fi
if [[ $MOVIE == true && $IMAGES == false && $isH264 == true ]]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Encoding to ProRes/H.264..."
runSim dcrawOpt mov_main mov_prox
echo ""
elif [[ $MOVIE == true && $IMAGES == false && $isH264 == false ]]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Encoding to ProRes..."
dcrawOpt | mov_main
echo ""
elif [[ $MOVIE == false && $IMAGES == false && $isH264 == true ]]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Encoding to H.264..."
dcrawOpt | mov_prox
echo ""
elif [[ $IMAGES == true ]]; then
V_FILTERS="" #Only needed if reading from images.
V_FILTERS_PROX="-vf $FINAL_SCALE"
if [[ $IMG_FMT == "dpx" ]]; then
V_FILTERS="-vf lut3d=${COLOR_LUTS[0]}/srgb--lin.cube"
V_FILTERS_PROX="-vf lut3d=${COLOR_LUTS[0]}/srgb--lin.cube,$FINAL_SCALE" #We apply a sRGB to Linear 1D LUT if reading DPX. Because it's fucking broken.
fi
#Use images if available, as opposed to developing the files again.
if [[ $MOVIE == true && $isH264 == true ]]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Encoding to ProRes/H.264..."
mov_main_img &
mov_prox_img &
wait
echo ""
elif [[ $MOVIE == true && $isH264 == false ]]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Encoding to ProRes..."
mov_main_img
echo ""
elif [[ $MOVIE == false && $isH264 == true ]]; then
echo -e "\033[1m${TRUNC_ARG}:\033[0m Encoding to H.264..."
mov_prox_img
echo ""
fi
fi
#Potentially move DNGs.
if [ $KEEP_DNGS == true ]; then
echo -e "\033[1mMoving DNGs...\033[0m"
DNG="${FILE}/dng_${TRUNC_ARG}"
mkdirS $DNG; if [ $? -eq 1 ]; then return 1; fi
if [ $DUAL_ISO == true ]; then
oldFiles="${TMP}/orig_dng"
find $oldFiles -name "*.dng" | xargs -I '{}' mv {} $DNG #Preserve the original, unprocessed DNGs.
else
find $TMP -name "*.dng" | xargs -I '{}' mv {} $DNG
fi
fi
echo -e "\n\033[1mCleaning Up.\033[0m\n\n"
#Delete tmp
rm -rf $TMP
}

760
src/core/parsing.sh 100644
View File

@ -0,0 +1,760 @@
#!/bin/bash
#desc: All config and command line parsing happens here.
#MAIN FUNCTIONS
parseConf() {
local file=$1 #The File to Parse
local argOnly=$2 #If true, will only use file-specific blocks. If false, will ignore file-specific blocks.
local CONFIG_NAME="None"
if [[ -z $file ]]; then return; fi
if [[ ! -f $file ]]; then return; fi
local fBlock=false #Whether or not we are in a file-specific block.
local fID="" #The name of the file-specific block we're in.
while IFS="" read -r line || [[ -n "$line" ]]; do
line=$(echo "$line" | sed -e 's/^[ \t]*//') #Strip leading tabs/whitespaces.
if [[ `echo "${line}" | cut -c1-1` == "#" ]]; then continue; fi #Ignore comments
if [[ `echo "${line}" | cut -c1-1` == "/" ]]; then
if [[ $fBlock == true ]]; then invOption "ERROR: Nested file-specific blocks in config file $CONFIG_NAME!"; fi
fBlock=true
fID=`echo "${line}" | cut -d$' ' -f2`
continue
fi #Enter a file-specific block with /, provided the argument name is correct.
if [[ `echo "${line}" | cut -c1-1` == "*" ]]; then fBlock=false; fID=""; fi #Leave a file-specific block.
#~ echo $argOnly $fBlock $fID ${TRUNC_ARG%.*} `echo "${line}" | cut -d$' ' -f1`
if [[ ($argOnly == false && $fBlock == false) || ( ($argOnly == true && $fBlock == true) && $fID == ${TRUNC_ARG%.*} ) ]]; then #Conditions under which to write values.
case `echo "${line}" | cut -d$' ' -f1` in
"CONFIG_NAME") CONFIG_NAME=`echo "${line}" | cut -d$' ' -f2` #Not doing anything with this right now.
;;
"OUTDIR") OUTDIR=`echo "${line}" | cut -d$' ' -f2`
;;
"BIN_PATH") BIN_PATH=`echo "${line}" | cut -d$' ' -f2`; setPaths
;;
"DCRAW") DCRAW=`echo "${line}" | cut -d$' ' -f2`
;;
"MLV_DUMP") MLV_DUMP=`echo "${line}" | cut -d$' ' -f2`
;;
"RAW_DUMP") RAW_DUMP=`echo "${line}" | cut -d$' ' -f2`
;;
"MLV_BP") MLV_BP=`echo "${line}" | cut -d$' ' -f2`
;;
"CR_HDR") CR_HDR=`echo "${line}" | cut -d$' ' -f2`
;;
"PYTHON") PYTHON=`echo "${line}" | cut -d$' ' -f2`; setPaths
;;
"THREADS") THREADS=`echo "${line}" | cut -d$' ' -f2`
;;
"IMAGE") IMAGES=true
;;
"IMG_FMT")
mode=`echo "${line}" | cut -d$' ' -f2`
case ${mode} in
"0") IMG_FMT="exr"
;;
"1") IMG_FMT="tiff"
;;
"2") IMG_FMT="png"
;;
"3") IMG_FMT="dpx"
;;
*) invOption "Invalid Image Format Choice: ${mode}"
;;
esac
;;
"MOVIE") MOVIE=true
;;
"PROXY")
PROXY=`echo "${line}" | cut -d$' ' -f2`
case ${PROXY} in
"0") isJPG=false; isH264=false
;;
"1") isJPG=false; isH264=true
;;
"2") isJPG=true; isH264=false
;;
"3") isJPG=true; isH264=true
;;
*) invOption "Invalid Proxy Choice: ${PROXY}"
;;
esac
;;
"PROXY_SCALE")
PROXY_SCALE=`echo "${line}" | cut -d$' ' -f2`
proxy_num=`echo "$PROXY_SCALE" | cut -d'%' -f 1`
if [[ ! ( ($proxy_num -le 100 && $proxy_num -ge 5) && $proxy_num =~ ^-?[0-9]+$ ) ]]; then invOption "Invalid Proxy Scale: ${PROXY_SCALE}"; fi
;;
"KEEP_RAWS") KEEP_DNGS=true
;;
"FRAME_RANGE") RANGE_BASE=`echo "${line}" | cut -d$' ' -f2`; isFR=false
;;
"UNCOMP") isCOMPRESS=false
;;
"DEMO_MODE") DEMO_MODE=`echo "${line}" | cut -d$' ' -f2`
;;
"HIGHLIGHT_MODE") HIGHLIGHT_MODE=`echo "${line}" | cut -d$' ' -f2`
;;
"CHROMA_SMOOTH")
mode=`echo "${line}" | cut -d$' ' -f2`
case ${mode} in
"0") CHROMA_SMOOTH="--no-cs"
;;
"1") CHROMA_SMOOTH="--cs2x2"
;;
"2") CHROMA_SMOOTH="--cs3x3"
;;
"3") CHROMA_SMOOTH="--cs5x5"
;;
*) invOption "Invalid Chroma Smoothing Choice: ${mode}"
;;
esac
;;
"WAVE_NOISE") WAVE_NOISE="-n $(echo "${line}" | cut -d$' ' -f2)"
;;
"TEMP_NOISE")
vals="$(echo "${line}" | cut -d$' ' -f2)"
aVal=$(echo "${vals}" | cut -d"-" -f1)
bVal=$(echo "${vals}" | cut -d"-" -f2)
TEMP_NOISE="atadenoise=0a=${aVal}:0b=${bVal}:1a=${aVal}:1b=${bVal}:2a=${aVal}:2b=${bVal}"
tempDesc="Temporal Denoiser"
FFMPEG_FILTERS=true
;;
"HQ_NOISE")
vals="$(echo "${line}" | cut -d$' ' -f2)"
S=`echo "${vals}" | cut -d$':' -f1`
T=`echo "${vals}" | cut -d$':' -f2`
LS=`echo "${S}" | cut -d$'-' -f1`
CS=`echo "${S}" | cut -d$'-' -f2`
LT=`echo "${T}" | cut -d$'-' -f1`
CT=`echo "${T}" | cut -d$'-' -f2`
HQ_NOISE="hqdn3d=luma_spatial=${LS}:chroma_spatial=${CS}:luma_tmp=${LT}:chroma_tmp=${CT}"
hqDesc="3D Denoiser"
FFMPEG_FILTERS=true
;;
"REM_NOISE")
vals="$(echo "${line}" | cut -d$' ' -f2)"
m1=`echo "${vals}" | cut -d$'-' -f1`
m2=`echo "${vals}" | cut -d$'-' -f2`
m3=`echo "${vals}" | cut -d$'-' -f3`
m4=`echo "${vals}" | cut -d$'-' -f4`
REM_NOISE="removegrain=m0=${m1}:m1=${m2}:m2=${m3}:m3=${m4}"
remDesc="RemoveGrain Modal Denoiser"
FFMPEG_FILTERS=true
;;
"GAMMA") #Value checking done in color management.
mode=`echo "${line}" | cut -d$' ' -f2`
case ${mode} in
"0")
COLOR_GAMMA="STANDARD" #Lets CM know that it should correspond to the gamut, or be 2.2.
;;
"1")
COLOR_GAMMA="lin" #Linear
;;
"2")
COLOR_GAMMA="cineon" #Cineon
;;
"3")
COLOR_GAMMA="clog2" #C-Log2. Req: color-ext.
;;
"4")
COLOR_GAMMA="slog3" #S-Log3. Req: color-ext.
;;
#~ "5")
#~ COLOR_GAMMA="logc" #LogC 4.X . Req: color-ext.
#~ ;;
#~ "6")
#~ COLOR_GAMMA="acescc" #ACEScc Log Gamma. Req: color-aces.
#~ ;;
*)
invOption "g: Invalid Gamma Choice: ${mode}"
;;
esac
;;
"GAMUT") #Value checking done in color management.
mode=`echo "${line}" | cut -d$' ' -f2`
case ${mode} in
"0")
COLOR_GAMUT="srgb" #sRGB
;;
"1")
COLOR_GAMUT="argb" #Adobe RGB
;;
"2")
COLOR_GAMUT="rec709" #Rec.709
;;
"3")
COLOR_GAMUT="xyz" #XYZ. Linear Only.
;;
#~ "3")
#~ COLOR_GAMUT="aces" #ACES. Standard is Linear. Req: color-aces (all gammas will work, even without color-ext)/
#~ ;;
#~ "4")
#~ COLOR_GAMUT="xyz" #ACES. Standard is Linear. Req: color-aces (all gammas will work, even without color-ext)/
#~ ;;
"4")
COLOR_GAMUT="rec2020" #Rec.2020. Req: color-ext.
;;
"5")
COLOR_GAMUT="dcip3" #DCI-P3. Req: color-ext.
;;
"6")
COLOR_GAMUT="ssg3c" #Sony S-Gamut3.cine. Req: color-ext.
;;
*)
invOption "G: Invalid Gamut Choice: ${mode}"
;;
esac
;;
"SHALLOW") DEPTH=""; DEPTH_OUT="-depth 8"
;;
"WHITE")
mode=`echo "${line}" | cut -d$' ' -f2`
case ${mode} in
"0") CAMERA_WB=false; GEN_WHITE=true #Will generate white balance.
;;
"1") CAMERA_WB=true; GEN_WHITE=false; #Will use camera white balance.
;;
"2") WHITE="-r 1 1 1 1"; CAMERA_WB=false; GEN_WHITE=false #Will not apply any white balance.
;;
*)
invOption "Invalid White Balance Choice: ${mode}"
;;
esac
;;
"SHARP")
val=`echo "${line}" | cut -d$' ' -f2`
lSize=`echo "${val}" | cut -d$':' -f1`
lStr=`echo "${val}" | cut -d$':' -f2`
cSize=`echo "${val}" | cut -d$':' -f3`
cStr=`echo "${val}" | cut -d$':' -f4`
SHARP="unsharp=${lSize}:${lSize}:${lStr}:${cSize}:${cSize}:${cStr}"
sharpDesc="Sharpen/Blur"
FFMPEG_FILTERS=true
;;
"LUT")
LUT_PATH=`echo "${line}" | cut -d$' ' -f2`
if [ ! -f $LUT_PATH ]; then invOption "Invalid LUT Path: ${LUT_PATH}"; fi
#Check LUT_SIZE
i=0
while read line; do
sLine=$(echo $line | sed -e 's/^[ \t]*//')
if [[ $(echo $sLine | cut -c1-11) == "LUT_3D_SIZE" ]]; then
if [[ $(echo $sLine | cut -c13-) -le 64 && $(echo $sLine | cut -c13-) -ge 2 ]]; then
break
else
size=$(echo $sLine | cut -c13-)
invOption "$(basename $LUT_PATH): Invalid LUT Size of $size x $size x $size - Must be between x2 and x64 (you can resize using pylut - see 'convmlv -h') ! "
fi
elif [[ $i -gt 20 ]]; then
invOption "$(basename $LUT_PATH): Invalid LUT - LUT_3D_SIZE not found in first 20 non-commented lines."
fi
if [[ ! $(echo $sLine | cut -c1-1) == "#" ]]; then ((i++)); fi
done < $LUT_PATH
LUTS+=( "lut3d=${LUT_PATH}" )
lutDesc="3D LUTs"
FFMPEG_FILTERS=true
;;
"SATPOINT") SATPOINT="-S $(echo "${line}" | cut -d$' ' -f2)"
;;
"WHITE_SPD") WHITE_SPD=`echo "${line}" | cut -d$' ' -f2`
;;
"WHITE_CLIP") isScale=true
;;
"DESHAKE")
DESHAKE="deshake"
deshakeDesc="Deshake Filter"
FFMPEG_FILTERS=true
;;
"DUAL_ISO") DUAL_ISO=true
;;
"BADPIXELS") isBP=true
;;
"BADPIXEL_PATH") BADPIXEL_PATH=`echo "${line}" | cut -d$' ' -f2`
;;
"DARKFRAME")
DARKFRAME=`echo "${line}" | cut -d$' ' -f2`;
if [ ! -f $DARKFRAME ]; then invOption "Invalid Darkframe: ${DARKFRAME}"; fi
useDF=true
;;
esac
fi
done < "$1"
}
parseArgs() { #Amazing new argument parsing!!!
longArg() { #Creates VAL
ret="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
}
while getopts "vh C: o: P: T: i t: m p: s: k r: d: f H: c: n: N: Q: O: g: G: w: A: l: S: D u b a: F: R: q K: Y M -:" opt; do
#~ echo $opt ${OPTARG}
case "$opt" in
-) #Long Arguments
case ${OPTARG} in
outdir)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
OUTDIR=$val
;;
version)
PROGRAM="version"
;;
help)
PROGRAM="help"
;;
config)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
LCONFIG=$val
;;
bin-path)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
BIN_PATH=$val
setPaths #Set all the paths with the new BIN_PATH.
;;
dcraw)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
DCRAW="${val}"
;;
mlv-dump)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
MLV_DUMP=$val
;;
raw-dump)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
RAW_DUMP=$val
;;
badpixels)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
MLV_BP=$val
;;
cr-hdr)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
CR_HDR=$val
;;
srange)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
PYTHON_BAL=$val
setPaths #Must regen BAL
;;
balance)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
PYTHON_SRANGE=$val
setPaths #Must regen SRANGE
;;
python)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
PYTHON=$val
setPaths #Set all the paths with the new PYTHON.
;;
threads)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
THREADS=$val
;;
uncompress)
isCOMPRESS=false
;;
shallow)
DEPTH=""
DEPTH_OUT="-depth 8"
;;
white-speed)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
WHITE_SPD=$val
;;
allow-white-clip)
isScale=true
;;
*)
echo "Invalid option: --$OPTARG" >&2
;;
esac
;;
v)
PROGRAM="version"
;;
h)
PROGRAM="help"
;;
C)
LCONFIG=${OPTARG}
;;
o)
OUTDIR=${OPTARG}
;;
P)
BIN_PATH=${OPTARG}
setPaths #Set all the binary paths with the new BIN_PATH.
;;
T)
THREADS=${OPTARG}
;;
i)
IMAGES=true
;;
t)
mode=${OPTARG}
case ${mode} in
"0") IMG_FMT="exr"
;;
"1") IMG_FMT="tiff"
;;
"2") IMG_FMT="png"
;;
"3") IMG_FMT="dpx"
;;
*) invOption "t: Invalid Image Format Choice: ${mode}"
;;
esac
;;
m)
MOVIE=true
;;
p)
PROXY=${OPTARG}
case ${PROXY} in
"0") isJPG=false; isH264=false
;;
"1") isJPG=false; isH264=true
;;
"2") isJPG=true; isH264=false
;;
"3") isJPG=true; isH264=true
;;
*) invOption "p: Invalid Proxy Choice: ${PROXY}"
;;
esac
;;
s)
PROXY_SCALE=${OPTARG}
proxy_num=`echo "$PROXY_SCALE" | cut -d'%' -f 1`
if [[ ! ( ($proxy_num -le 100 && $proxy_num -ge 5) && $proxy_num =~ ^-?[0-9]+$ ) ]]; then invOption "s: Invalid Proxy Scale: ${PROXY_SCALE}"; fi
;;
k)
KEEP_DNGS=true
;;
r)
RANGE_BASE=${OPTARG}
isFR=false
;;
d)
DEMO_MODE=${OPTARG}
;;
f)
FOUR_COLOR="-f"
;;
H)
HIGHLIGHT_MODE=${OPTARG}
;;
c)
mode=${OPTARG}
case ${mode} in
"0") CHROMA_SMOOTH="--no-cs"
;;
"1") CHROMA_SMOOTH="--cs2x2"
;;
"2") CHROMA_SMOOTH="--cs3x3"
;;
"3") CHROMA_SMOOTH="--cs5x5"
;;
*) invOption "c: Invalid Chroma Smoothing Choice: ${mode}"
;;
esac
;;
n)
WAVE_NOISE="-n ${OPTARG}"
;;
N)
vals=${OPTARG}
aVal=$(echo "${vals}" | cut -d"-" -f1)
bVal=$(echo "${vals}" | cut -d"-" -f2)
TEMP_NOISE="atadenoise=0a=${aVal}:0b=${bVal}:1a=${aVal}:1b=${bVal}:2a=${aVal}:2b=${bVal}"
tempDesc="Temporal Denoiser"
FFMPEG_FILTERS=true
;;
Q)
vals=${OPTARG}
S=`echo "${vals}" | cut -d$':' -f1`
T=`echo "${vals}" | cut -d$':' -f2`
LS=`echo "${S}" | cut -d$'-' -f1`
CS=`echo "${S}" | cut -d$'-' -f2`
LT=`echo "${T}" | cut -d$'-' -f1`
CT=`echo "${T}" | cut -d$'-' -f2`
HQ_NOISE="hqdn3d=luma_spatial=${LS}:chroma_spatial=${CS}:luma_tmp=${LT}:chroma_tmp=${CT}"
hqDesc="3D Denoiser"
FFMPEG_FILTERS=true
;;
O)
vals=${OPTARG}
m1=`echo "${vals}" | cut -d$'-' -f1`
m2=`echo "${vals}" | cut -d$'-' -f2`
m3=`echo "${vals}" | cut -d$'-' -f3`
m4=`echo "${vals}" | cut -d$'-' -f4`
REM_NOISE="removegrain=m0=${m1}:m1=${m2}:m2=${m3}:m3=${m4}"
remDesc="RemoveGrain Modal Denoiser"
FFMPEG_FILTERS=true
;;
g)
mode=${OPTARG}
case ${mode} in
"0")
COLOR_GAMMA="STANDARD" #Lets CM know that it should correspond to the gamut, or be 2.2.
;;
"1")
COLOR_GAMMA="lin" #Linear
;;
"2")
COLOR_GAMMA="cineon" #Cineon
;;
"3")
COLOR_GAMMA="clog2" #C-Log2. Req: color-ext.
;;
"4")
COLOR_GAMMA="slog3" #S-Log3. Req: color-ext.
;;
#~ "5")
#~ COLOR_GAMMA="logc" #LogC 4.X . Req: color-ext.
#~ ;;
#~ "6")
#~ COLOR_GAMMA="acescc" #ACEScc Log Gamma. Req: color-aces.
#~ ;;
*)
invOption "g: Invalid Gamma Choice: ${mode}"
;;
esac
;;
G)
mode=${OPTARG}
case ${mode} in
"0")
COLOR_GAMUT="srgb" #sRGB
;;
"1")
COLOR_GAMUT="argb" #Adobe RGB
;;
"2")
COLOR_GAMUT="rec709" #Rec.709
;;
"3")
COLOR_GAMUT="xyz" #XYZ. Linear Only.
;;
#~ "4")
#~ COLOR_GAMUT="aces" #ACES. Standard is Linear. Req: color-aces (all gammas will work, even without color-ext)/
#~ ;;
"4")
COLOR_GAMUT="rec2020" #Rec.2020. Req: color-ext.
;;
"5")
COLOR_GAMUT="dcip3" #DCI-P3. Req: color-ext.
;;
"6")
COLOR_GAMUT="ssg3c" #Sony S-Gamut3.cine. Req: color-ext.
;;
*)
invOption "G: Invalid Gamut Choice: ${mode}"
;;
esac
;;
w)
mode=${OPTARG}
case ${mode} in
"0") CAMERA_WB=false; GEN_WHITE=true #Will generate white balance.
;;
"1") CAMERA_WB=true; GEN_WHITE=false; #Will use camera white balance.
;;
"2") WHITE="-r 1 1 1 1"; CAMERA_WB=false; GEN_WHITE=false #Will not apply any white balance.
;;
*)
invOption "w: Invalid White Balance Choice: ${mode}"
;;
esac
;;
A)
val=${OPTARG}
lSize=`echo "${val}" | cut -d$':' -f1`
lStr=`echo "${val}" | cut -d$':' -f2`
cSize=`echo "${val}" | cut -d$':' -f3`
cStr=`echo "${val}" | cut -d$':' -f4`
SHARP="unsharp=${lSize}:${lSize}:${lStr}:${cSize}:${cSize}:${cStr}"
sharpDesc="Sharpen/Blur"
FFMPEG_FILTERS=true
;;
l)
LUT_PATH=${OPTARG}
if [ ! -f $LUT_PATH ]; then invOption "Invalid LUT Path: ${LUT_PATH}"; fi
#Check LUT_SIZE
i=0
while read line; do
sLine=$(echo $line | sed -e 's/^[ \t]*//')
if [[ $(echo $sLine | cut -c1-11) == "LUT_3D_SIZE" ]]; then
if [[ $(echo $sLine | cut -c13-) -le 64 && $(echo $sLine | cut -c13-) -ge 2 ]]; then
break
else
size=$(echo $sLine | cut -c13-)
invOption "$(basename $LUT_PATH): Invalid LUT Size of $size x $size x $size - Must be between x2 and x64 (you can resize using pylut - see 'convmlv -h') ! "
fi
elif [[ $i -gt 20 ]]; then
invOption "$(basename $LUT_PATH): Invalid LUT - LUT_3D_SIZE not found in first 20 non-commented lines."
fi
if [[ ! $(echo $sLine | cut -c1-1) == "#" ]]; then ((i++)); fi
done < $LUT_PATH
LUTS+=( "lut3d=${LUT_PATH}" )
lutDesc="3D LUTs"
FFMPEG_FILTERS=true
;;
S)
SATPOINT="-S ${OPTARG}"
;;
D)
DESHAKE="deshake"
deshakeDesc="Deshake Filter"
FFMPEG_FILTERS=true
;;
u)
DUAL_ISO=true
;;
b)
isBP=true
;;
a)
BADPIXEL_PATH=${OPTARG}
BADPIXEL_PATH=${OPTARG}
;;
F)
DARKFRAME=`echo "${line}" | cut -d$' ' -f2`;
if [ ! -f $DARKFRAME ]; then invOption "F: Invalid Darkframe: ${DARKFRAME}"; fi
useDF=true
;;
R)
PROGRAM="darkframe"
#~ MK_DARK=true
DARK_OUT=${OPTARG}
;;
q)
PROGRAM="settings"
#~ SETTINGS_OUTPUT=true
;;
K)
mode=${OPTARG}
case ${mode} in
"0") echo $DEB_DEPS
;;
"1") echo $UBU_DEPS
;;
"2") echo $FED_DEPS
;;
"3") echo $BREW_DEPS
;;
*)
invOption "K: Invalid Dist Choice: ${mode}"
;;
esac
exit 0
;;
Y)
echo $PIP_DEPS
exit 0
;;
M)
echo $MAN_DEPS
exit 0
;;
*)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
}
parseAll() {
#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.
}

247
src/core/proc.sh 100644
View File

@ -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...
}

View File

@ -0,0 +1,46 @@
#!/bin/bash
#desc: Kinda standalone TODO list.
less -R << EOF
TODO:
PLANNING:
Except for openlut integration, CM fixes, and the last throes of Mac compatibility, I consider convmlv feature-complete. As in, only bug fixes and error checking.
New developments, like special ffmpeg filters, or new techniques from the ML world, may change that. But that\'s nothing compared to the 2400 lines this pushes at the moment!
Any further effort is better focused on compatibility, bug fixes, error checking, more bug fixes, and finally a GUI app described in FUTURE.
TOP PRIORITY
--> Fix Color Management; -o 5 is broken. Use -o 0 or -o 1, supplemented by current paradigm of Rec709 -> Whatever LUTs, instead of XYZ -> Whatever LUTs.
--> MLVFS backend - run the mlvfs command, passing whatever options it supports, then rewrite ARG. Give an option to choose mlv_dump or mlvfs, and an option for a custom path to mlvfs.
*Consider using dcraw for darkframing, through the -K option. Requires a develop from MLV, then a convert to raw PGM, first.
--> Calibration frame program & library - place in $HOME/.local/convmlv, perhaps.
--> New program: Install dependencies.
HIGH PRIORITY
--> Integrate openlut for 1D LUTs. 3D LUTs would only be used for gamut transforms, not gamut/gamma.
--> More error checking.
--> Test Mac compatibility with a *working* (with 10.7) mlv_dump...
--> Documentation: Videos.
MEDIUM PRIORITY
--> Integrate openlut for gamut ops. Matrices would replace standard 3D LUTs altogether, and openlut would handle 3D LUTs.
LOW
--> Stats for .RAW files.
FUTURE
--> A GUI app, running libraw variants, which has a CLI backend, but can also output a convmlv config file.
--> convmlv will always have more features - bash makes certain nasty things like ffmpeg filters available, as opposed to the \"code it yourself\" of true image array processing...
--> But, a GUI is usable by the average non-nerd!! You know, the users of ML.
BUG: Relative OUTDIR makes baxpixel generation fail if ./mlv2badpixels.sh doesn\'t exist. Should be fixed on all platforms.
BIG BUG: Color Management is oversaturated, destructively so.
--> See Nasty Hacks Part 1 - 3. FML :O.
EOF

View File

@ -1,7 +1,13 @@
#!/bin/bash
#desc: The help function lives here, as well as helper functions thereof.
help() {
less -R << EOF
Usage:
./convmlv.sh [FLAGS] [OPTIONS] files
$(echo -e "\033[1m./convmlv.sh\033[0m [FLAGS] [OPTIONS] \033[2mfiles\033[0m")
INFO:
$(head "INFO:")
A program allowing you to develop ML files into workable formats. Many useful options are exposed.
--> Defaults: Compressed 16-bit Linear EXR. 10-bit Prores4444 MOV.
--> Color Defaults: Linear (1.0) Gamma on sRGB Gamut, using Camera White Balance.
@ -14,9 +20,9 @@ INFO:
It's as simple or complex as you need it to be: 'convmlv -m <mlvfile>.mlv' is enough for good-looking output!
VERSION: 2.0.1
$(echo -e "$(head VERSION): ${VERSION}")
MANUAL DEPENDENCIES:
$(head "MANUAL DEPENDENCIES:")
Place these in RES_PATH (see OPTIONS, BASIC). Keep in mind you also need dist. and pip packages.
--> See 'Dist Deps' and 'Python Deps'
@ -30,82 +36,81 @@ MANUAL DEPENDENCIES:
-- balance.py: For Auto White Balance. See convmlv repository.
-- color-ext: Extra LUTs, providing more color resources. See convmlv repository.
OPTIONS, BASIC:
-v, --version version - Print out version string.
-h, --help help - Print out this help page.
$(head "OPTIONS, BASIC:")
-v, --version $(bVal version) - Print out version string.
-h, --help $(bVal help) - Print out this help page.
-C, --config config - Designates config file to use.
-C, --config $(bVal config) - Designates config file to use.
-o, --outdir <path> OUTDIR - The path in which files will be placed.
-P, --res-path <path> RES_PATH - The path in which all manual dependencies are looked for.
--> Default: Current Directory.
-o, --outdir <path> $(cVal OUTDIR) - The path in which files will be placed.
-P, --bin-path <path> $(iVal BIN_PATH) - The path in which all binary dependencies are looked for.
--> Default: ./binaries (the folder binaries in current folder).
--> Source Code: These components will be looked for at <location of convmlv.sh>/src.
--dcraw <path> DCRAW - The path to dcraw.
--mlv-dump <path> MLV_DUMP - The path to mlv_dump.
--raw-dump <path> RAW_DUMP - The path to raw2dng.
--badpixels <path> MLV_BP - The path to mlv2badpixels.sh (by dfort).
--cr-hdr <path> CR_HDR - The path to cr2hdr.
--srange <path> SRANGE - The path to sRange.py.
--balance <path> BAL - The path to balance.py.
--python <path> PYTHON - The path or command used to invoke Python 3. Default is python3 on Linux, python on Mac.
--dcraw <path> $(cVal DCRAW) - The path to dcraw.
--mlv-dump <path> $(cVal MLV_DUMP) - The path to mlv_dump.
--raw-dump <path> $(cVal RAW_DUMP) - The path to raw2dng.
--badpixels <path> $(cVal MLV_BP) - The path to mlv2badpixels.sh (by dfort).
--cr-hdr <path> $(cVal CR_HDR) - The path to cr2hdr.
--python <path> $(cVal PYTHON) - The path or command used to invoke Python 3. Default is python3 on Linux, python on Mac.
-T, --threads [int] THREADS - Override amount of utilized process threads. Default is MAX - 1.
-T, --threads [int] $(cVal THREADS) - Override amount of utilized process threads. Default is MAX - 1.
OPTIONS, OUTPUT:
-i IMAGE - Will output image sequence.
$(head "OPTIONS, OUTPUT:")
-i $(cVal IMAGE) - Will output image sequence.
-t [0:3] IMG_FMT - Image output format.
-t [0:3] $(cVal IMG_FMT) - Image output format.
--> 0: EXR (default), 1: TIFF, 2: PNG, 3: Cineon (DPX)."
-m MOVIE - Will output a Prores4444 file.
-m $(cVal MOVIE) - Will output a Prores4444 file.
-p [0:3] PROXY - Create proxies alongside main output.
-p [0:3] $(cVal PROXY) - Create proxies alongside main output.
--> 0: No proxies (Default). 1: H.264 proxy. 2: JPG proxy sequence. 3: Both.
--> JPG proxy will always be in sRGB Gamma/sRGB Gamut. H.264 proxy is color managed.
--> JPG proxy *won't* be developed w/o IMAGE. H.264 proxy *will* be developed no matter what, if specified here.
--> Why? JPG is for potential use in editing. H.264 is for a quick visual preview of convmlv's output.
-s [0%:100%] PROXY_SCALE - the size, in %, of the proxy output.
-s [0%:100%] $(cVal PROXY_SCALE) - the size, in %, of the proxy output.
--> Default: 50%.
-k KEEP_DNGS - Specify if you want to keep the DNG files.
-k $(cVal KEEP_DNGS) - Specify if you want to keep the DNG files.
--> Run convmlv on the top level folder of former output to reuse saved DNGs from that run!
-r <start>-<end> FRAME_RANGE - Specify to process an integer frame range.
-r <start>-<end> $(cVal FRAME_RANGE) - Specify to process an integer frame range.
--> You may use the characters 's' and 'e', such that s = start frame, e = end frame.
--> Indexed from 0 to (# of frames - 1). Develops from 1 to ($ of frames)
--> A single number may be writted to develop that single frame.
--> DO NOT try to reuse DNGs while developing a larger frame range.
--uncompress UNCOMP - Turns off lossless image compression. Otherwise:
--uncompress $(cVal UNCOMP) - Turns off lossless image compression. Otherwise:
--> TIFF: ZIP, EXR: PIZ, PNG: lvl 0, DPX: RLE.
OPTIONS, RAW DEVELOPMENT:
-d [0:3] DEMO_MODE - Demosaicing algorithm. Higher modes are slower + better.
$(head "OPTIONS, RAW DEVELOPMENT:")
-d [0:3] $(cVal DEMO_MODE) - Demosaicing algorithm. Higher modes are slower + better.
--> 0: Bilinear. 1: VNG (default). 2: PPG. 3: AHD.
-f FOUR_COLOR - Interpolate as RGBG. Fixes weirdness with VNG/AHD, at the cost of sharpness.
-f $(cVal FOUR_COLOR) - Interpolate as RGBG. Fixes weirdness with VNG/AHD, at the cost of sharpness.
-H [0:9] HIGHLIGHT_MODE - Highlight management options.
-H [0:9] $(cVal HIGHLIGHT_MODE) - Highlight management options.
--> 0: White, clipped highlights. 1: Unclipped but colored highlights. 2: The defail of 1, but adjusted to grey.
--> 3-9: Highlight reconstruction. Can cause flickering. Start at 5, then adjust to color (down) or to white (up).
-c [0:3] CHROMA_SMOOTH - Apply shadow/highlight chroma smoothing to the footage.
-c [0:3] $(cVal CHROMA_SMOOTH) - Apply shadow/highlight chroma smoothing to the footage.
--> 0: None (default). 1: 2x2. 2: 3x3. 3: 5x5.
--> MLV input Only.
-n [int] WAVE_NOISE - Apply wavelet denoising.
-n [int] $(cVal WAVE_NOISE) - Apply wavelet denoising.
--> Default: None. Subtle: 25. Medium: 50. Strong: 125.
-N <A>-<B> TEMP_NOISE - Apply temporal denoising.
-N <A>-<B> $(cVal TEMP_NOISE) - Apply temporal denoising.
--> A: 0 to 0.3. B: 0 to 5. A reacts to abrupt noise (splotches), B reacts to noise over time (fast motion causes artifacts).
--> Subtle: 0.03-0.04. High: 0.15-0.04. High, Predictable Motion: 0.15-0.07
-Q [i-i:i-i] HQ_NOISE - Apply 3D denoising filter.
-Q [i-i:i-i] $(cVal HQ_NOISE) - Apply 3D denoising filter.
--> In depth explanation: https://mattgadient.com/2013/06/29/in-depth-look-at-de-noising-in-handbrake-with-imagevideo-examples/ .
--> Spacial/Temporal (S/T). S will soften/blur/smooth, T will remove noise without doing that but may create artifacts.
--> Luma/Chroma (L/C). L is the detail, C is the color. Each one's denoising may be manipulated Spacially or Temporally.
@ -115,32 +120,32 @@ OPTIONS, RAW DEVELOPMENT:
--> DONT combine with TEMP_NOISE.
-O [i-i-i-i] REM_NOISE - Yet another spatial denoiser, with 4 choices of 24 modes.
-O [i-i-i-i] $(cVal REM_NOISE) - Yet another spatial denoiser, with 4 choices of 24 modes.
--> See https://ffmpeg.org/ffmpeg-filters.html#removegrain for list of modes.
--> Option Value: <mode1>-<mode2>-<mode3>-<mode4>
--> I truly cannot tell you what values will be helpful to you; there are too many... Look at the link!
--shallow SHALLOW - Output smaller, 8-bit files.
--shallow $(cVal SHALLOW) - Output smaller, 8-bit files.
--> Read why this is a bad idea: http://www.cambridgeincolour.com/tutorials/bit-depth.htm
OPTIONS, COLOR:
-g [0:4] GAMMA - Output gamma. A curve applied to the output, for easier viewing/grading.
$(head "OPTIONS, COLOR:")
-g [0:4] $(cVal GAMMA) - Output gamma. A curve applied to the output, for easier viewing/grading.
--> 0: Standard (Around 2.2). 1: Linear (Default).
--> Requires color-ext: 2: Cineon. 3: C-Log2 4: S-Log3
--> "Standard" grades to the gamut specification, and to 2.2 if that's not given.
-G [0:6] GAMUT - Output gamut. The range of colors that can exist in the output.
-G [0:6] $(cVal GAMUT) - Output gamut. The range of colors that can exist in the output.
--> 0: sRGB (Default). 1: Adobe RGB. 2: Rec.709. 3: XYZ (Always Linear Gamma).
--> Requires color-ext: 4: Rec2020 5: DCI-P3 6: Sony S-Gamut3.cine
-w [0:2] WHITE - This is a modal white balance setting.
-w [0:2] $(cVal WHITE) - This is a modal white balance setting.
--> 0: Auto WB (requires balance.py). 1: Camera WB (default). 2: No Change.
--> AWB uses the Grey's World algorithm.
-A [i:i:i:i] SHARP - Lets you sharpen, or blur, your footage.
-A [i:i:i:i] $(cVal SHARP) - Lets you sharpen, or blur, your footage.
--> BE CAREFUL. Wrong values will give you strange errors.
--> Size/Strength (S/T). S is the size of the sharpen/blur effect, T is the strength of the sharpen/blur effect.
--> Luma/Chroma (L/C). L is the detail, C is the color. Luma sharpening more effective.
@ -149,63 +154,63 @@ OPTIONS, COLOR:
--> LS and CS must be ODD, between 3 and 63. Negative LT/CT values blur, while positive ones sharpen.
--> Strong Sharp: 7:3:7:3 Strong Blur: 7,-3:7,-3. Medium Sharp: 5:1:3:0
-l <path> LUT - Specify a LUT to apply after Color Management.
-l <path> $(cVal LUT) - Specify a LUT to apply after Color Management.
--> Supports cube, 3dl, dat, m3d.
--> Specify -l multiple times, to apply multiple LUTs in sequence.
-S [int] SATPOINT - Specify the 14-bit uint saturation point of your camera. You don't usually need to.
-S [int] $(cVal SATPOINT) - Specify the 14-bit uint saturation point of your camera. You don't usually need to.
--> Worth setting globally, as it's a per-camera setting. Must be correct for highlight reconstruction/unclipped highlights.
--> Lower from 15000 if -H1 yields purple highlights, until they turn white.
--> You can determine the optimal value using the max pixel value of 'dcraw -D -j -4 -T'.
--white-speed [int] WHITE_SPD - Manually specify samples used to calculate AWB.
--white-speed [int] $(cVal WHITE_SPD) - Manually specify samples used to calculate AWB.
--allow-white-clip WHITE_CLIP - Let the White Balance multipliers clip.
--allow-white-clip $(cVal WHITE_CLIP) - Let the White Balance multipliers clip.
OPTIONS, FEATURES:
-D DESHAKE - Auto-stabilize the video using ffmpeg's "deshake" module.
$(head "OPTIONS, FEATURES:")
-D $(cVal DESHAKE) - Auto-stabilize the video using ffmpeg's "deshake" module.
--> You may wish to crop/scale the output later, to avoid edge artifacts.
-u DUAL_ISO - Process as dual ISO.
-u $(cVal DUAL_ISO) - Process as dual ISO.
--> Requires cr2hdr.
-b BADPIXELS - Fix focus pixels issue using dfort's script.
-b $(cVal BADPIXELS) - Fix focus pixels issue using dfort's script.
--> Requires mlv2badpixels.sh.
-a <path> BADPIXEL_PATH - Use your own .badpixels file. Does NOT require mlv2badpixels.sh
-a <path> $(cVal BADPIXEL_PATH) - Use your own .badpixels file. Does NOT require mlv2badpixels.sh
--> How to: http://www.dl-c.com/board/viewtopic.php?f=4&t=686
-F <path> DARKFRAME - This is the path to a "dark frame MLV"; effective for noise reduction.
-F <path> $(cVal DARKFRAME) - This is the path to a "dark frame MLV"; effective for noise reduction.
--> How to: Record 5 sec w/lens cap on & same settings as footage. Pass MLV in here.
--> If the file extension is '.darkframe', the file will be used as a preaveraged dark frame.
-R <path> darkframe_output - Specify to create a .darkframe file from passed in MLV.
-R <path> $(bVal darkframe_output) - Specify to create a .darkframe file from passed in MLV.
--> Usage: 'convmlv -R <path> <input>.MLV'
--> Averages <input>.MLV to create <path>.darkframe.
--> THE .darkframe EXTENSION IS ADDED FOR YOU.
OPTIONS, INFO:
-q settings - Output MLV settings.
$(head "OPTIONS, INFO:")
-q $(bVal settings) - Output MLV settings.
-K [0:3] Dist Deps - Output package dependecies, for use with common package managers.
-K [0:3] $(bVal "Dist Deps") - Output package dependecies, for use with common package managers.
--> 0: Debian, 1: Ubuntu, 2: Fedora, 3: Homebrew (Mac)
--> Deps Install (Debian): sudo apt-get install $(./convmlv.sh -K 0)
--> Deps Install (Ubuntu): sudo apt-get install $(./convmlv.sh -K 1)
--> Deps Install (Fedora): sudo yum install $(./convmlv.sh -K 2)
--> Deps Install (Homebrew Mac): brew install $(./convmlv.sh -K 3)
--> Deps Install (Debian): sudo apt-get install \$(./convmlv.sh -K 0)
--> Deps Install (Ubuntu): sudo apt-get install \$(./convmlv.sh -K 1)
--> Deps Install (Fedora): sudo yum install \$(./convmlv.sh -K 2)
--> Deps Install (Homebrew Mac): brew install \$(./convmlv.sh -K 3)
-Y Python Deps - Lists Python dependencies. Works directly with pip.
-Y $(bVal "Python Deps") - Lists Python dependencies. Works directly with pip.
-->Install (Cross-Platform): sudo python3 -m pip install $ (./convmlv -Y)
-M Manual Deps - Lists manual dependencies, which must be downloaded by hand.
-M $(bVal "Manual Deps") - Lists manual dependencies, which must be downloaded by hand.
--> Manually place all in RES_PATH. See http://www.magiclantern.fm/forum/index.php?topic=16799.0 .
COLOR MANAGEMENT:
INTRO Images aren't simple. They are often stored, processed, and viewed as a result of complex transformations usually called,
$(head "COLOR MANAGEMENT:")
$(bold INTRO) Images aren't simple. They are often stored, processed, and viewed as a result of complex transformations usually called,
in applications, color management. Understanding it is required as a colourist, and encouraged as a DPs and Cinematographers.
--> Intro: http://www.cambridgeincolour.com/tutorials/color-management1.htm
@ -214,7 +219,7 @@ COLOR MANAGEMENT:
--> Conversions: http://www.cambridgeincolour.com/tutorials/color-space-conversion.htm
--> Monitor Calibration: http://www.cambridgeincolour.com/tutorials/monitor-calibration.htm
PIPELINE convmlv is a color managed application, designed to retain quality from RAW footage:
$(bold "PIPELINE") convmlv is a color managed application, designed to retain quality from RAW footage:
-- mlv_dump writes camera-specific color transformation matrices as metadata in developed DNGs.
--> This defines the camera's gamut.
@ -226,46 +231,46 @@ COLOR MANAGEMENT:
--> The output employs DATA, not LEGAL, values. The resulting image is flatter, but retains all shadow/highlight detail.
--> -l specified LUTs are applied afterwards.
3D LUTS The included LUTs, found in the convmlv repository, are key to convmlv's color management solution:
$(bold "3D LUTS") The included LUTs, found in the convmlv repository, are key to convmlv's color management solution:
-- color-core: The required LUTs, including sRGB (default), Adobe RGB, and Rec709 in Standard and Linear gamma.
-- color-ext: Optional LUTs, including Rec2020, DCI-P3, etc. in Standard/Linear gammas, but also in Log formats.
Create Your Own LUTs using LUTCalc, for any grading format output: https://cameramanben.github.io/LUTCalc/ (watch his tutorials).
$(bold "Create Your Own LUTs") using LUTCalc, for any grading format output: https://cameramanben.github.io/LUTCalc/ (watch his tutorials).
--> Note that convmlv only accepts up to 64x64x64 LUTs. You can resize LUTs using pylut (https://pypi.python.org/pypi/pylut).
--> The pylut command to resize is 'pylut <yourx65lut>.cube --resize 64'. Alternatively, you can use pylut from Python (2X only).
--> I reccommend Legal --> Data LUTs, as this conserves shadow/highlight detail for grading. Legal --> Legal looks better, but with detail loss.
CONFIG FILE:
$(head "CONFIG FILE:")
Config files, another way to specify options, can save you time & lend you convenience in production situations.
GLOBAL: /home/sofus/convmlv.conf
LOCAL: Specify -C/--config.
$(echo -e "\033[1mGLOBAL\033[0m"): $HOME/convmlv.conf
$(echo -e "\033[1mLOCAL\033[0m"): Specify -C/--config.
SYNTAX:
$(echo -e "\033[1mSYNTAX:\033[0m")
Most options listed above have an uppercased VARNAME, ex. OUTDIR. You can specify such options in config files, as such:
<VARNAME> <VALUE>
One option per line only. Indentation by tabs or spaces is allowed, but not enforced.
Comments Lines starting with # are comments.
$(echo -e "\033[1mComments\033[0m") Lines starting with # are comments.
You may name a config using:
CONFIG_NAME <name>
Flags If the value is a true/false flag (ex. IMAGE), simply specifying VARNAME is enough. There is no VALUE.
$(echo -e "\033[1mFlags\033[0m") If the value is a true/false flag (ex. IMAGE), simply specifying VARNAME is enough. There is no VALUE.
OPTION ORDER OF PRECEDENCE Options override each other as such:
$(echo -e "\033[1mOPTION ORDER OF PRECEDENCE\033[0m") Options override each other as such:
-LOCAL options overwrite GLOBAL options.
-COMMAND LINE options overwrite LOCAL & GLOBAL options.
-FILE SPECIFIC options overwrite ALL ABOVE options.
File-Specific Block: A LOCAL config file lets you specify options for specific input names:
$(echo -e "\033[1mFile-Specific Block\033[0m"): A LOCAL config file lets you specify options for specific input names:
/ <TRUNCATED INPUTNAME>
...options here will only be
@ -279,3 +284,5 @@ CONFIG FILE:
Contact me with any feedback or questions at convmlv@sofusrose.com, PM me (so-rose) on the ML forums, or post on the thread!
EOF
}

View File

@ -0,0 +1,148 @@
#!/bin/bash
#desc: Error checking and consequence functions.
invOption() {
str=$1
echo -e "\033[0;31m\033[1m${str}\033[0m"
echo -e "\n\033[1mCleaning Up.\033[0m\n\n"
#Delete tmp
rm -rf $TMP
exit 1
}
checkArg() {
#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.
local arg="$1"
local argBase="$(basename "$arg")"
local argExt="${argBase##*.}"
local argTrunc="${argBase%.*}"
local cont
#Argument Checks
if [ ! -f $arg ] && [ ! -d $arg ]; then
nFound "File" "${arg}" "Skipping File"
echo "false" >&1; return
fi
if [[ ! -d $arg && ! ( $argExt == "MLV" || $argExt == "mlv" || $argExt == "RAW" || $argExt == "raw" ) ]]; then
error "File ${arg} has invalid extension!\n" >&2
echo "false" >&1; return
fi
if [[ ( ( ! -f $arg ) && $(ls -1 ${arg%/}/*.[Dd][Nn][Gg] 2>/dev/null | wc -l) == 0 ) && ( `folderName ${arg}` != $argTrunc ) ]]; then
error "Folder ${arg} contains no DNG files!" >&2
echo "false" >&1; return
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.
cont=false
while true; do
#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
case $csr in
[Cc]* ) error "\nContinuing.\n"; break
;;
[Ss]* ) error "\nSkipping.\n"; cont=true; break
;;
[Rr]* ) error "\nRemoving ${arg}.\n"; cont=true; rm $arg; break
;;
[Qq]* ) error "\nQuitting.\n"; isExit=true; break
;;
* ) error "Please answer continue, skip, or remove.\n"
;;
esac
done
if [ $cont == true ]; then
echo "false" >&1; return
fi
fi
}
checkDeps() {
#Essentials
if [ ! -f $MLV_DUMP ]; then
nFound "Binary" "${MLV_DUMP}" "Execution will halt" "Get it here: http://www.magiclantern.fm/forum/index.php?topic=7122.0."
isExit=true
fi
if [ ! -d ${COLOR_LUTS[0]} ]; then
nFound "Folder" "color-core" "Execution will halt" "Download from convmlv repository."
isExit=true
fi
if [ ! -f $PYTHON_SRANGE ]; then
nFound "Python Script" "${PYTHON_SRANGE}" "Execution will halt" "Download from convmlv repository."
isExit=true
fi
cmdExists() { if type -P "$1" &> /dev/null || [ -x "$1" ]; then echo true; else echo false; fi }
#Basic Options - Dist Deps
if [[ $(cmdExists "$DCRAW") != true ]]; then
nFound "Command" "$DCRAW" "Execution will halt" "dcraw not installed correctly - See Dist Deps in the OPTIONS, INFO section of 'convmlv -h'."
isExit=true
fi
if [[ $(cmdExists "$PYTHON") != true ]]; then
nFound "Command" "$PYTHON" "Execution will halt" "Python was not installed correctly. Install version 3.X, or see PYTHON in the OPTIONS, BASIC section of 'convmlv -h' for custom path."
isExit=true
fi
if [[ $(cmdExists "$PYTHON") == true && $($PYTHON -c 'import sys; print(sys.version_info[0])') != 3 ]]; then
nFound "Python Version" "3.X" "Execution will halt" "Your python version is $($PYTHON -c "import sys; print('.'.join(str(x) for x in sys.version_info[0:3]))") - convmlv requires 3.X. Typically, you must install the 'python3' package; else you can set set PYTHON in the OPTIONS, BASIC section of 'convmlv -h'."
fi
if [[ $(cmdExists "convert") != true ]]; then
nFound "Command" "convert" "Execution will halt" "ImageMagick not installed correctly - See Dist Deps in the OPTIONS, INFO section of 'convmlv -h'."
isExit=true
fi
if [[ $(cmdExists "ffmpeg") != true ]]; then
nFound "Command" "ffmpeg" "Execution will halt" "ffmpeg not installed correctly - See Dist Deps in the OPTIONS, INFO section of 'convmlv -h'."
isExit=true
fi
if [[ $(cmdExists "exiftool") != true ]]; then
nFound "Command" "exiftool" "Execution will halt" "exiftool not installed correctly - See Dist Deps in the OPTIONS, INFO section of 'convmlv -h'."
isExit=true
fi
#Optionals
if [ ! -f $RAW_DUMP ]; then
nFound "Binary" "${RAW_DUMP}" "Execution will continue without .RAW processing capability" "Get it here: http://www.magiclantern.fm/forum/index.php?topic=5404.0."
fi
if [ ! -f $MLV_BP ]; then
nFound "SH Script" "${MLV_BP}" "Execution will continue without badpixel removal capability" "Get it here: https://bitbucket.org/daniel_fort/ml-focus-pixels/src"
fi
if [ ! -f $CR_HDR ]; then
nFound "Binary" "${CR_HDR}" "Execution will continue without Dual ISO processing capability" "Get it here: http://www.magiclantern.fm/forum/index.php?topic=7139.0"
fi
if [ ! -f $PYTHON_BAL ]; then
nFound "Python Script" "${PYTHON_BAL}" "Execution will continue without AWB" "Download from convmlv repository."
fi
if [ ! -d ${COLOR_LUTS[1]} ]; then
nFound "Folder" "color-ext" "Execution will continue without extra gamma/gamut options." "Download from convmlv repository."
fi
if [[ $isExit == true ]]; then
echo -e "\033[0;33m\033[1mPlace all binaries in BIN_PATH - ${BIN_PATH} - or give specific paths with the relevant arguments/config options (see 'convmlv -h'). Also, make sure they're executable (run 'chmod +x file').\033[0m\n"
exit 1
fi
#Option Checking - ideally, we do all of these. For now, I'm bored of it...
#Check wavelet NR - WAVE_NOISE
#Check TEMP_NOISE
#Check HQ_NOISE
#Check REM_NOISE
#Check SHARP
#Check SATPOINT
#Check WHITE_SPD
#Check BADPIXEL_PATH
#Check LUT size.
#badpixel info.
}

View File

@ -0,0 +1,67 @@
#!/bin/bash
#desc: Text formatting functions.
bold() {
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() {
#usage: cVal value
#desc: Formats config file values, as bolded grey.
#return: Formatted value.
echo -e "\033[1m\033[37m${1}\033[0m"
}
bVal() {
#usage: bVal value
#desc: Formats running (not related to development) options, as bolded green.
#return: Formatted value.
echo -e "\033[1m\033[32m${1}\033[0m"
}
head() {
#usage: cVal value
#desc: Formats help page header values, as bold.
#return: Formatted value.
echo -e "\033[1m${1}\033[0m"
}
iVal() {
#usage: iVal value
#desc: Formats important config values, as bolded yellow.
#return: Formatted value.
echo -e "\033[1m\033[33m${1}\033[0m"
}

View File

@ -0,0 +1,15 @@
#!/bin/bash
#desc: Platform-specific functions.
getThreads() {
local threads=4 #4 threads by default
if [[ $OSTYPE == "linux-gnu" ]]; then #Linux-specific constants.
threads=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | tail -1)
elif [[ $OSTYPE == "darwin11" ]]; then #Mac-specific constants
threads=$(sysctl -n hw.ncpu)
fi
echo "$threads"
}

View File

@ -0,0 +1,91 @@
#!/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.
type=$1
name="$2"
exec_instr=$3
down_instr=$4
if [[ -z $down_instr ]]; then
echo -e "\033[1;31m${type} \033[0;1m${name}\033[1;31m not found! ${exec_instr}.\033[0m\n" >&2
else
echo -e "\033[1;31m${type} \033[0;1m${name}\033[1;31m not found! ${exec_instr}.\033[0m\n------> ${down_instr}\n" >&2
fi
}
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
cleanup=$2
cont=false
if [ -d $path ]; then
while true; do
read -p "Overwrite ${path}? [y/n/q] " ynq
case $ynq in
[Yy]* ) echo -e ""; rm -rf $path; mkdir -p $path >/dev/null 2>/dev/null; break
;;
[Nn]* ) error "\nDirectory ${path} won't be created.\n"; cont=true; `$cleanup`; break
;;
[Qq]* ) error "\nHalting execution. Directory ${path} won't be created.\n"; `$cleanup`; exit 1;
;;
* ) error "Please answer yes or no, or quit.\n"
;;
esac
done
else
mkdir -p $path >/dev/null 2>/dev/null
fi
if [ $cont == true ]; then
return 1
fi
}
folderName() {
#Like basename, but for folders.
echo "$1" | rev | cut -d$'/' -f1 | rev
}
joinArgs() {
#Joins the arguments of the input array using commas.
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 ^_^
}
strArr() {
#usage: strArr arg1 arg2 ...
#desc: Formats the args into a string ready to insert into an associative array.
#return: A string ready to insert into an associative array.
echo "TO BE WRITTEN"
}

View File

@ -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
}

View File

View File

@ -0,0 +1,9 @@
#!/bin/bash
#desc: Calibration frame code.
mkDarkframe() {
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
echo -e "\n\033[1m\033[1mWrote Darkframe File\033[0m: ${DARK_OUT}\n"
}

View File

@ -0,0 +1,124 @@
#!/bin/bash
#desc: Functions dealing with getting and printing footage (ARG) settings.
prntSet() {
cat << EOF
$(bold CameraName): ${CAM_NAME}
$(bold RecordingDate): ${REC_DATE}
$(bold RecordingTime): ${REC_TIME}
$(bold FPS): ${FPS}
$(bold Resolution): ${RES_IN}
$(bold TotalFrames): ${FRAMES}
$(bold Aperture): ${APERTURE}
$(bold ISO): ${ISO}
$(bold ShutterSpeed): ${SHUTTER}
$(bold WBKelvin): ${KELVIN}
$(bold FocalLength): ${LEN_FOCAL}
EOF
}
mlvSet() {
camDump=$(${MLV_DUMP} -v -m ${ARG}) #Read it in *once*; otherwise it's unbearably slow on external media.
FPS=`echo "$camDump" | grep FPS | awk 'FNR == 1 {print $3}'`
CAM_NAME=`echo "$camDump" | grep 'Camera Name' | cut -d "'" -f 2`
FRAMES=`echo "$camDump" | awk '/Processed/ { print $2; }'` #Use actual processed frames as opposed to what the sometimes incorrect metadata thinks.
RES_IN=`echo "$camDump" | grep "Res" | sed 's/[[:alpha:] ]*: //'`
ISO=`echo "$camDump" | grep 'ISO' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f2`
APERTURE=`echo "$camDump" | grep 'Aperture' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
LEN_FOCAL=`echo "$camDump" | grep 'Focal Len' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
SHUTTER=`echo "$camDump" | grep 'Shutter' | sed 's/[[:alpha:] ]*: //' | grep -oP '\(\K[^)]+' | cut -d$'\n' -f1`
REC_DATE=`echo "$camDump" | grep 'Date' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
REC_TIME=`echo "$camDump" | grep 'Time: [0-2][0-9]\:*' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
KELVIN=`echo "$camDump" | grep 'Kelvin' | sed 's/[[:alpha:] ]*: //' | cut -d$'\n' -f1`
}
rawSet() { #To be implemented maybe - exiftool? Or raw_dump? ...
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"
}
dngSet() { #Set as many options as the RAW spec will allow. Grey out the rest.
dngLoc=$1
if [[ -z $dngLoc ]]; then dngLoc="${ARG}"; fi
for dng in $dngLoc/*.dng; do
dataDNG="$(pwd)/.datadng.dng"
cp $dng $dataDNG
break
done
FPS=24 #Standard FPS.
#Frames is taken care of.
CAM_NAME=$(exiftool -UniqueCameraModel -s -s -s $dataDNG)
RES_IN=$(exiftool -ImageSize -s -s -s $dataDNG)
ISO=$(exiftool -UniqueCameraModel -s -s -s $dataDNG)
APERTURE=$(exiftool -ApertureValue -s -s -s $dataDNG)
LEN_FOCAL=$(exiftool -FocalLength -s -s -s $dataDNG)
SHUTTER=$(exiftool -ShutterSpeed -s -s -s $dataDNG)
REC_DATE=$(echo "$(exiftool -DateTimeOriginal -s -s -s $dataDNG)" | cut -d$' ' -f1)
REC_TIME=$(echo "$(exiftool -DateTimeOriginal -s -s -s $dataDNG)" | cut -d$' ' -f2)
KELVIN="Unknown"
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() {
ARG="${FILE_ARGS_ARRAY[0]}"
checkArg
BASE="$(basename "$ARG")"
EXT="${BASE##*.}"
if [ $EXT == "MLV" ] || [ $EXT == "mlv" ]; then
# Read the header for interesting settings :) .
mlvSet
echo -e "\n\033[1m\033[0;32m\033[1mFile\033[0m: ${ARG}\n"
prntSet
elif [ $EXT == "RAW" ] || [ $EXT == "raw" ]; then
rawSet
echo -e "\n\033[1m\033[0;32m\033[1mFile\033[0m\033[0m: ${ARG}\n"
prntSet
elif [ -d $ARG ]; then
dngSet
echo -e "\n\033[1m\033[0;32m\033[1mFile\033[0m\033[0m: ${ARG}\n"
prntSet
else
echo -e "Cannot print settings from ${ARG}; it's not a valid file!"
fi
}