Author Topic: (Linux/Mac) convmlv: Featureful MLV Developer  (Read 28704 times)

Danne

  • Hero Member
  • *****
  • Posts: 4256
Re: MLV/RAW to TIFF/Prores with Proxy (Linux/Mac)
« Reply #25 on: March 15, 2016, 09:27:23 AM »
For dual iso movie sequences I use wildcard and 4 parallell conversions. Find command and dual iso processing what was started all that ended up in MLP(command tip from dmilligan).
Code: [Select]
find . '*.dng' -print0 | xargs -0 -P 4 -n 1 cr2hdr
You want to apply same white level(avoid flicker) to all files in post and I use exiftool to grab that info. This should work.
Code: [Select]
wl=$(exiftool my.dng | awk '/White Level/ { print $4; }')
Apply white level
Code: [Select]
find . -maxdepth 1 -mindepth 1 -name '*.dng' -print0 | xargs -0 exiftool "-WhiteLevel=$wl" -overwrite_original

Since you will have to use cr2hdr you might wanna consider developing CR2 files as well. This is also working to grab the correct white balance multiplier from the CR2 file. You could check this source file from MLP
dualiso_to_DNG(CR2 images)
https://drive.google.com/file/d/0B4tCJMlOYfirUTlfWlFFa3BpeE0/view?usp=sharing

Basically it develops the same as for movie sequences
Code: [Select]
find . -maxdepth 1 -mindepth 1 -name '*.CR2' -print0 | xargs -0 -P 4 -n 1 ~/Library/Services/MLP.workflow/Contents/cr2hdr20bit $CR2 $co_01
You could grab the white balance from the CR2 file itself.
I do this by creating a list and calculate for whitebalance asShotNeutral values(courtesy chmee). Check the script. You could probably make this a lot nicer than in my script. There is also the export path solution if you include binaries outside the system paths(cr2hdr,dcraw,exiftool) but seems you,re dependencies might be put in the system itself. Solution from dfort ,dmilligan ,stackoverflow put in MLP
Code: [Select]
export PATH=~/Library/Services/MLP.workflow/Contents:$PATH
By the way. I don,t think 7D can shoot dual iso movie sequences.



dfort

  • Developer
  • Hero Member
  • *****
  • Posts: 3028
Re: MLV/RAW to TIFF/Prores with Proxy (Linux/Mac)
« Reply #26 on: March 15, 2016, 06:45:19 PM »
An open question: How does Dual ISO video processing work? And does anyone have any samples...? (My 7D refuses to cooperate; I think I need to put a new ML build in there)

Here are some sample Dual ISO files. One from a 100D and another from an EOSM.
https://www.dropbox.com/sh/kkrx3k2a2hz8nl2/AADAQS5GoTBNPbfP9bFR4OAZa?dl=0

I believe that the 7D has the same issue with Dual ISO video as the 5D2. There has been some recent breakthroughs with that on the 5D2. If you can compile ML (easy as π on Linux) you might try adapting it for the 7D.
http://magiclantern.fm/forum/index.php?topic=16854
5D3.* 7D.206 700D.115 EOSM.203 EOSM2.103 500D.112

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #27 on: March 21, 2016, 12:09:25 AM »
All right, so I got Dual ISO video to work. However, I'm getting what seems like blinking focus pixels. Here's the proxy video output from the 100D sample:

https://drive.google.com/open?id=0Bx0YaKfeuWSrLU9iY2tUZjJqZFE

I tried running mlv2badpixels.sh on the original MLV file, as well as on a developed (with cr2hdr) DNG, using $raw_buffer --> $video_mode (from @dfort's code) from the MLV to specify the -m option, but they both have the exact same artifacts as above. What the heck is going on?

Besides the blinking pixels  :-\ , the output looks good.

Thanks @Danne for exposing me to the -P option of xargs - I managed to parallelize image sequence and Dual ISO development :) . Things are much faster now.



Finally, the script can now output to TIFF, EXR, DPX, and PNG sequences, all automatically compressed if -c is specified. It's trivial to add more; any requests?  :D
convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #28 on: March 21, 2016, 01:31:26 AM »
One more question: How does footage archival work with mlv_dump? As in, compressing the MLV file (and being able to decompress it for use)?
convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

Danne

  • Hero Member
  • *****
  • Posts: 4256
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #29 on: March 21, 2016, 07:12:53 AM »
Nice stuff. On a train atm so can,t check anything yet.
I,m planning to add darkframe subtraction something like this to MLP. Might be of interest here.
http://magiclantern.fm/forum/index.php?topic=15801.msg164620#msg164620

Gotta check how you export to exr and dpx later. How is it done :)?

Exr are created with imagemagick with convert command right?

dfort

  • Developer
  • Hero Member
  • *****
  • Posts: 3028
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #30 on: March 21, 2016, 01:09:21 PM »
I tried running mlv2badpixels.sh on the original MLV file, as well as on a developed (with cr2hdr) DNG, using $raw_buffer --> $video_mode (from @dfort's code) from the MLV to specify the -m option, but they both have the exact same artifacts as above. What the heck is going on?

What is going on is that the way dcraw is filling in the "badpixels" isn't working very well with that particular Dual ISO example. I just checked it out and it is also happening on the Mac using MLP with the mlv_dump -> cr2hdr method. This isn't the case when using MLP in combination with MLVFS. dmilligan worked out a pixel blending system specifically for Dual ISO. It should be possible to do something similar with dcraw but that involves some C coding and creating a custom dcraw build. Better yet, it is also be possible to add the focus pixel fixing code into mlv_dump. That would be a better solution because it would fix the focus pixels on the DNG files like MLVFS does.

By the way I shot that Dual ISO shot on the 100D when testing MLVFS. That was before I created the mlv2badpixels.sh script which is used in MLP. Guess I never ran that shot through mlv_dump -> cr2hdr -> dcraw -P -> ffmpeg.
5D3.* 7D.206 700D.115 EOSM.203 EOSM2.103 500D.112

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #31 on: March 26, 2016, 11:53:09 PM »
@Danne I figured out darkframe subtraction! It's in 1.7.1; thanks for the pointer!

Quote
dmilligan worked out a pixel blending system specifically for Dual ISO. It should be possible to do something similar with dcraw but that involves some C coding and creating a custom dcraw build. Better yet, it is also be possible to add the focus pixel fixing code into mlv_dump. That would be a better solution because it would fix the focus pixels on the DNG files like MLVFS does.

A custom dcraw build specifically for Dual ISO is starting to sound a little scary, though it makes a lot of sense if focus pixel removal could be integrated into mlv_dump - or perhaps cr2hdr?


A question for @dmilligan: Looking through the MLVFS source code, I notice a function in 'cs.c' named 'fix_focus_pixels' and another named 'fix_bad_pixels'; I wonder how possible/painful it would be to isolate these little stumps of magic, using the resulting binary to simply take in a bad DNG (from the output of cr2hdr) and output a fixed one?



Also, open question, is there any difference between cr2hdr and cr2hdr20bit? If so where can I find/compile cr2hdr20bit?
convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

dfort

  • Developer
  • Hero Member
  • *****
  • Posts: 3028
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #32 on: March 27, 2016, 12:27:26 AM »
Also, open question, is there any difference between cr2hdr and cr2hdr20bit? If so where can I find/compile cr2hdr20bit?

No difference. cr2hdr20bit was merged into the main branch several months ago. People should stop using the old name to avoid confusion.
5D3.* 7D.206 700D.115 EOSM.203 EOSM2.103 500D.112

DeafEyeJedi

  • Hero Member
  • *****
  • Posts: 3081
  • 5D3 / M1 / 7D / 70D / SL1
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #33 on: March 27, 2016, 12:40:54 AM »
Nice work guys. Been following this thread and as it seems to get best results with Dual-ISO and Focus Pixel to work together is to combine MLP and MLVFS atm, correct?
5D3.113 • 5D3.123 • EOSM.203 • 7D.203 • 70D.112 • 100D.101

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #34 on: March 27, 2016, 01:14:18 AM »
Nice work guys. Been following this thread and as it seems to get best results with Dual-ISO and Focus Pixel to work together is to combine MLP and MLVFS atm, correct?
Thanks :).

It would seem that MLVFS has the golden ticket to badpixel removal in Dual ISO footage, so in a sense yes. However, I'm not quite sure what you mean by combining the two programs - if you're suggesting working on integrating the pixel blending code, then I agree fully! convmlv would benefit from such work as well.
convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

DeafEyeJedi

  • Hero Member
  • *****
  • Posts: 3081
  • 5D3 / M1 / 7D / 70D / SL1
convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #35 on: March 27, 2016, 01:27:21 AM »
Sorry I forgot to also mention these in conjunction with DarkFraming Avg Process (Dual-ISO, Focus Pixel Fix and DF) all together ... My fault for the typo so-rose!
5D3.113 • 5D3.123 • EOSM.203 • 7D.203 • 70D.112 • 100D.101

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3217
  • 60Da / 1100D / EOSM
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #36 on: March 27, 2016, 04:54:50 AM »
A question for @dmilligan: Looking through the MLVFS source code, I notice a function in 'cs.c' named 'fix_focus_pixels' and another named 'fix_bad_pixels'; I wonder how possible/painful it would be to isolate these little stumps of magic, using the resulting binary to simply take in a bad DNG (from the output of cr2hdr) and output a fixed one?
the bad pixel fix was pulled straight from cr2hdr, the focus pixel fixing probably needs to be added directly into cr2hdr

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #37 on: March 28, 2016, 09:26:06 PM »
Quote
the focus pixel fixing probably needs to be added directly into cr2hdr

I'd be happy to give this a go at some point in time, but as I've never coded in C (only simple code in C++, and never image processing outside of Python), I'm not sure I'd have much success - would anyone be up for trying this?

Quote
in conjunction with DarkFraming Avg Process (Dual-ISO, Focus Pixel Fix and DF) all together ... My fault for the typo so-rose!

No problems  :) . Combining MLP and MLVFS does, at the moment, give the best results as far as I can tell; it seems like a bit of a roundabout way to do it, however. Implementing the focus pixel fix in cr2hdr would allow MLP (and convmlv for that matter) to process those three features - Dual-ISO, Focus Pixel Fix and DF - all by itself!
convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #38 on: March 28, 2016, 11:46:32 PM »
If anyone's interested, I wrote some documentation for convmlv! It's a PDF found in docs->docs.pdf in the source code (https://bitbucket.org/so-rose/convmlv/src).
convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

DeafEyeJedi

  • Hero Member
  • *****
  • Posts: 3081
  • 5D3 / M1 / 7D / 70D / SL1
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #39 on: March 29, 2016, 12:32:32 AM »
No problems  :) . Combining MLP and MLVFS does, at the moment, give the best results as far as I can tell; it seems like a bit of a roundabout way to do it, however. Implementing the focus pixel fix in cr2hdr would allow MLP (and convmlv for that matter) to process those three features - Dual-ISO, Focus Pixel Fix and DF - all by itself!

Exactly. Glad you followed me and I feel better that I'm not alone in this either. Looking forward to this implementation in the near future.

May the force be with you, @so-rose!
5D3.113 • 5D3.123 • EOSM.203 • 7D.203 • 70D.112 • 100D.101

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #40 on: March 29, 2016, 01:29:59 AM »
Quote
May the force be with you, @so-rose!

Many thanks!

Quote
the focus pixel fixing probably needs to be added directly into cr2hdr

Seems like a challenge. I shall dive. No promises...



...I opened up cr2hdr.c, and cs.c from mlvfs, and I now fear for my life :o ! Though I'm incredibly unsure how to do it, I have an idea of what I need to do (and quite certain I can do it due to the magic of GPL):

From cs.c, I need to take the function fix_focus_pixels(struct frame_headers * frame_headers, uint16_t * image_data, int dual_iso) and all that it needs to function.

This I need to plop into cr2hdr.c next to (or in?) find_and_fix_bad_pixels(int dark_noise, int bright_noise, int* raw2ev, int* ev2raw), in such a way that fix_focus_pixels executed as a step.




The issues I have even at this point are numerous:
  • What is the uint16 array image_data, and how might I set the output's pixel data in cr2hdr.c?
  • Are the raw2ev and ev2raw integer arrays the same in cs.c as in the argument of find_and_fix_bad_pixels()? Oh and what is it  :) ?
  • Several attributes of the pointer frame_headers are referenced, including what seems to be crop values (frame_headers->vidf_hdr.panPos<X or Y>). raw_info in cr2hdr seems to be the corresponding struct, but I can't find any "pan" values. Something that looks promising is found on Line 774 in cr2hdr.c, where the script sets an attribute called raw_info.active_area.<x/y 1/2>.

    I assume focus pixel handling is different based on whether the footage is taken with a cropped frame or not (that's how it works in mlv2badpixels.sh). If so, where can I find or get/how can I use what I have in raw_info to get these "panPos" values that I don't have, but seemingly need, to power the focus pixels script?
  • What is the parameter dual_iso?

@dmilligan and @anyone Any ideas?
convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

dfort

  • Developer
  • Hero Member
  • *****
  • Posts: 3028
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #41 on: March 29, 2016, 02:07:48 AM »
The pan and crop metadata isn't saved in the DNG files. Since cr2hdr starts with either the CR2 or DNG files it doesn't have access to this information. In order to find crop and pan you'll have to go back to the original MLV file. Actually you only need to find the pan because the crop can be derived from the pan--but not vice versa.

dmilligan provided some instructions on how you can read headers and footers from MLV and RAW files.
http://magiclantern.fm/forum/index.php?topic=16054.msg163145#msg163145

Since you are crossing the line from shell script to C programming I'd suggest abandoning my mlv2badpixels.sh as a reference and looking at the source code for MLVFS.

https://bitbucket.org/dmilligan/mlvfs

If you have any further questions, you already know who to ask!
5D3.* 7D.206 700D.115 EOSM.203 EOSM2.103 500D.112

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3217
  • 60Da / 1100D / EOSM
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #42 on: March 29, 2016, 02:50:25 PM »
I assume focus pixel handling is different based on whether the footage is taken with a cropped frame or not (that's how it works in mlv2badpixels.sh). If so, where can I find or get/how can I use what I have in raw_info to get these "panPos" values that I don't have, but seemingly need, to power the focus pixels script?[/li][/list]
Sorry, it's not possible to add the focus pixel stuff to cr2hdr (cr2hdr does not have the required metadata), it needs to be added to mlv_dump instead, where you still have crop information.

What is the uint16 array image_data, and how might I set the output's pixel data in cr2hdr.c?
read pixel at (x,y): p = image_data[x + y * w];
set pixel at (x,y): image_date[x + y * w] = p;

Are the raw2ev and ev2raw integer arrays the same in cs.c as in the argument of find_and_fix_bad_pixels()? Oh and what is it  :) ?
LUTs that convert linear raw pixel values to a log scale (EVs in fixed point) and back.

What is the parameter dual_iso?
Whether or not the footage is dual ISO. If it is dual ISO we have to interpolate pixels differently, we can't use the pixels above or below for interpolation because they will be at a different ISO.

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #43 on: April 13, 2016, 12:26:58 AM »
Status update: I'm trying to modify mlv_dump! No idea when it's going to work, but work it shall!

In any case, I finally made my script aware of Black Levels. It may interest people to know that dcraw apparently doesn't read Black Level info from the DNG file it's processing, leaving a magenta/green color cast. It's all fixed now, though; I compared the output to Darktable and MLRawViewer to be certain.


Thanks for all the support everyone!  :)
convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

Danne

  • Hero Member
  • *****
  • Posts: 4256
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #44 on: April 13, 2016, 12:45:37 AM »
Good luck on modifying mlv_dump!

I havn,t had any problems with dcraw black levels. I recall though, some greenish output files on some early messing around of another script I was working on but I changed dcraw build and suddenly the problem was gone. Did you try the setting +M?

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 11475
  • 5D Mark Free
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #45 on: April 13, 2016, 12:46:37 AM »
I've noticed the dcraw bug with the prepackaged version that came with Ubuntu Wily; recompiled from latest source and the bug was gone.

The bug was also present in ufraw.

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #46 on: April 13, 2016, 03:53:07 PM »
@Danne I did, with no luck... I ended up exiftool'ing the Black Level from the developed DNG (works on Dual ISO footage as well), so that the user doesn't need to deal with it - this seems to be a universally usable solution.

It's interesting that the bug should be present in ufraw too. The dcraw on Debian at least has the bug.
convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

Danne

  • Hero Member
  • *****
  • Posts: 4256
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #47 on: April 13, 2016, 03:56:05 PM »
The non universal solution(but faster) would be adding black level through hex. Dfort already cracked those numbers for white level.
Did you compile dcraw yourself?

*that was fo mlv files not dng files. My bad.

so-rose

  • New to the forum
  • *
  • Posts: 36
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #48 on: April 13, 2016, 06:49:55 PM »
The non universal solution(but faster) would be adding black level through hex. Dfort already cracked those numbers for white level.
Did you compile dcraw yourself?

*that was fo mlv files not dng files. My bad.
I'm just using the latest dcraw available in the Debian repository (testing), inserting the extracted BlackLevel tag after the -k option.

I only extract that value from one DNG, however - does it change? You mention that adding the black level through hex would be faster, but wouldn't I still have to specify -k, thus slowing it all down regardless?

Sent from my Nexus 6 using Tapatalk

convmlv - feed it your footage, it's safe I swear  -   http://www.magiclantern.fm/forum/index.php?topic=16799.0

openlut - recoloring your day, lut by lut  -  http://www.magiclantern.fm/forum/index.php?topic=17820.0

Danne

  • Hero Member
  • *****
  • Posts: 4256
Re: convmlv: MLV/RAW to Sequence/Prores with Proxy (Linux/Mac)
« Reply #49 on: April 13, 2016, 07:05:33 PM »
Are you adding black level from dcraw or exiftool. Wasn,t aware you could change black level with dcraw. Wouldn,t that be faster than exiftool?