convmlv icon indicating copy to clipboard operation
convmlv copied to clipboard

Input paths with whitespace => broken

Open mikeperalta1 opened this issue 7 years ago • 5 comments

Hey there,

When supplying this script with an input movie file that has a space in its path, the script cuts off anything after the first space and fails.

I've been looking through the source code and it is just ... way too complicated for me to fix myself, sorry.

mikeperalta1 avatar Dec 08 '17 12:12 mikeperalta1

Thanks for the bug report!

Yea, I coincidentally noticed this too a couple days ago (https://git.sofusrose.com/so-rose/convmlv/issues/36)...

The bash language is notoriously bad at dealing with spaces in general. Whenever one uses a variable the naiive way like so $VAR or like so ${VAR} to convey arguments to commands, the variable must not contain any spaces - or else the command will interpret it as two separate arguments.

Luckily, the fix is relatively simple - in theory. Just replace all $VAR with "$VAR". Except, quotes have their own sets of problems - one can't use them just anywhere, for example. Bugs of this nature are irritating to catch.

Unfortunately I wasn't thinking about this when I first started writing this monster of a script. I'll make sure to fix it for the next release (2.1.0 - here's a roadmap: https://git.sofusrose.com/so-rose/convmlv/milestones), which is a major code restructuring of convmlv for my sanity's sake! Since I'm revamping most of the functionality anyway, doing it properly this time is top of my agenda.

so-rose avatar Dec 08 '17 19:12 so-rose

Awesome and can't wait to see the new upgrades.

I've abandoned bash in favor of Python about a month ago for reasons such as this. I actually have a half-working "MLV to {Dng, Png, ProRes}" python script, but unfortunately I need a little more time to digest the colorspace stuff that dcraw does. I might post it up here under gpl if it ever works properly lol.

But great work and glad to see someone making great contributions to the community!

mikeperalta1 avatar Dec 09 '17 07:12 mikeperalta1

Thanks! Actually, way down the roadmap is a Python rewrite, so it's no doubt the best choice :). Still, for smaller scripts, bash is just... Devilishly easy to throw together.

I suggest supplementing any high-performance Python application with C++ functions; I did this with my other project openlut. Pybind11 makes this painless.

DCraw's color management is... Special. I've had to deal with this for awhile; this is what I've learned:

  • It has a long list of camera matrices, representing the camera's color space at some white balance that's unknown, mysteriously derived from Adobe DNGs.
  • Think of the white balance scaling as a kind of corrective chromatic adaptation matrix. It is far from perfect...
  • All output spaces have a D65 white point - including XYZ, which really should be D50 to fit the spec.
  • Accuracy is marginal. The camera matrices are often a bit wrong, and dcraw's icc camera profile option just doesn't seem to work - to use a custom ICC, you'd let dcraw output the "raw" camera space before transforming it yourself. Of course, the built in matrices tend to be quite "good enough", and seems to support every camera under the sun. Applications expecting XYZ input will likely pull of a chromatic adaptation assuming D50, when dcraw actually outputs D65, making the image look very wrong once viewed if you don't do a manual chromatic adaptation.
  • If you're writing a new application I'd suggest looking into LibRaw. It's a more sane, dcraw-inspired library that can be used in C++, and I believe there are Python bindings out there.

so-rose avatar Dec 09 '17 18:12 so-rose

Wow, thank you for all the excellent thoughtful advice. I'll take that all under consideration for sure!

mikeperalta1 avatar Dec 10 '17 01:12 mikeperalta1

Happy to help. I'd feel bad if you had to suffer through all that!!

I'm working on the next release; watch this space!

so-rose avatar Dec 10 '17 01:12 so-rose