Blackmagic Raw files

Questions and answers on how to get the most out of FFAStrans
emcodem
Posts: 1752
Joined: Wed Sep 19, 2018 8:11 am

Re: Blackmagic Raw files

Post by emcodem »

Hi @Ben,

thanks, finally some feedback on the work i did above :D
So regarding @ThomasM solution, you'll not get any help from me on misusing Davinci,Premiere and Co. in ways they are not designed (e.g. tools that are made for manual usage, not for automated use), so i'll try to keep focussed on my own solution from above:

It would be really good to have someone actually really using the solution i sent above in order to find out if it is the right way. If it turns out to work, it could potentially be added to the A/V decoder.
I did not have any braw files with audio as samples, maybe you can share some.

You can either do the two-step processing as you proposed or just add the audio in a single step like this:

Code: Select all

"C:\Libraries\ProcessClipCPU.exe" "C:\temp\sample.braw" | ffmpeg -f rawvideo -pixel_format rgba -s 4608x2592 -i - -i  "C:\temp\sample.braw" -map 0:v -map 1:a c:\temp\transcode.mov
Note that our ffmpeg has two inputs now, the first -i reads the decoded braw video frames from STDIN (-) and the second reads the original braw file. We make sure that video is being taken from the first -i and audio from the second using the -map options.
emcodem, wrapping since 2009 you got the rhyme?
Ben
Posts: 31
Joined: Wed Aug 19, 2020 4:50 am

Re: Blackmagic Raw files

Post by Ben »

Hey @emcodem thanks for the enhanced ffmpeg string to get audio working. It works nicely.
It always outputs a really good video file based on tests from my own footage. Oddly though I downloaded some sample footage online and it output a video file with the video all mixed up. Here's a link to a folder to see what I mean. https://www.dropbox.com/scl/fo/rjuz32xf ... 149qc&dl=0
Inside you'll see Mission.braw. This is a file I filmed on a Blackmagic Studio Camera 4k Pro with audio. You can see the transcoded .mov file looks normal.
The sample footage is called Filmplusgear-skiers-Samnaun-2019-dci-Q5.braw and is from Filmplusgear https://filmplusgear.com/blackmagic-raw ... r-download
I trimmed it down to speed up download and encoding time. The transcoded .mov looks super weird. I'm not sure why it's doing that.
Attachments
BRAW to 422 proxy FF.json
(4.34 KiB) Downloaded 358 times
emcodem
Posts: 1752
Joined: Wed Sep 19, 2018 8:11 am

Re: Blackmagic Raw files

Post by emcodem »

@Ben thanks for the feedback, unfortunately the solution for "Filmplusgear-skiers-Samnaun-2019-dci-Q5.braw" is pretty simple:
you did "hardcode" the resolution in your ffmpeg command. Even if you analyzed the braw resolution using my tool, you did not use the analyzed result but instead you told ffmpeg to assume the input is always 3820xsomething.. Also, you tried to store the analyzed resolution in a variable of type "integer" which cannot work because it is a string, not a number e.g. 4090x2060

I corrected this in your workflow, also i added a ? after -map 1:a, this way it should support files with or without audio.
emcodem_BRAW to 422 proxy FF.json
(4.32 KiB) Downloaded 361 times
By the way, the analyze step is needed because mediainfo spits out completely bogus values for the resolution.

Question could be, how could we possibly support mapping the colors to normal 709 for proxy, do we know anything about the possible color spaces/transfer characteristic there could occur in braw files?
The BMD LUT's seem to be widely spread in the web because davinci is freeware (e.g. https://github.com/imnz730/LUTs/tree/ma ... c%20Design) but i have no clue what to expect in braw files and how we could analyze what settings the braw have and how to map it to a corresponding bmd lut ^^

What does all the stuff we find in the mediainfo for the braw want to tell us?

Code: Select all

tone_curve_contrast                      : 1.000
tone_curve_saturation                    : 1.000
tone_curve_midpoint                      : 0.409
tone_curve_highlights                    : 1.000
tone_curve_shadows                       : 1.000
tone_curve_video_black_level             : 0
viewing_gamma                            : Blackmagic Design Film
viewing_gamut                            : Blackmagic Design
viewing_bmdgen                           : 4
emcodem, wrapping since 2009 you got the rhyme?
Ben
Posts: 31
Joined: Wed Aug 19, 2020 4:50 am

Re: Blackmagic Raw files

Post by Ben »

Thanks @emcodem, the human error solver :) The video transcoded correctly now.
I haven't checked but I've seen reports online that on Mac's you can right-click and Get info on a .braw file and it gives you some decent amount of info. If I open up the file in DaVinci Resolve then it gives me way more information about the metadata. Maybe the SDK has to be used to garnish even more info about colours? Or perhaps Mediainfo needs better support for .braw first.
emcodem
Posts: 1752
Joined: Wed Sep 19, 2018 8:11 am

Re: Blackmagic Raw files

Post by emcodem »

@Ben

Hm well using the BMD API, there is not MUCH more than mediainfo has to say, well ok there COULD be a LUT embedded but what exactly they mean with "Blackmagic Gen 5 Film to Extended Video.cube"...
i mean what exactly is "Extended Video"?

Code: Select all

Clip Metadata
manufacturer: Blackmagic Design
camera_id: 0fc70744-2307-433b-a866-0762c27862ed
camera_type: Blackmagic Studio Camera 4K Pro
firmware_version: 8.1.1
encoder_device_manufacturer: Blackmagic Design
braw_compression_ratio: Q5
braw_codec_bitrate: 213964800
sensor_area_captured: 3840,2160,
time_lapse_interval:
crop_origin: 16,8,
crop_size: 3840,2160,
analog_gain: 1
analog_gain_is_constant: 1
sensor_line_time: 7.50751
ois_enable: 1
offspeed: 0
clip_number: A002_07021403_C015
reel_name: 2
scene: 1
take: 18
shot_type: None
take_type: None
good_take: false
environment: interior
day_night: day
shutter_type: Angle
lens_type: LUMIX G VARIO 35-100/F2.8II
filters:
production_name: 2024-04-12
director:
camera_number: A
camera_operator:
frameguide_aspect_ratio:
safe_area: 0,0,
anamorphic:
anamorphic_enable: 0
post_3dlut_mode: Disabled
post_3dlut_embedded_name: Blackmagic Gen 5 Film to Extended Video.cube
post_3dlut_embedded_title: Gen 5 Film to Extended Video
post_3dlut_embedded_size: 33
post_3dlut_embedded_data: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0,0,0,0,0,0,0,0
viewing_gamma: Blackmagic Design Film
viewing_gamut: Blackmagic Design
viewing_bmdgen: 5
date_recorded: 2024:07:02
location:

Frame 0 Metadata
sensor_rate: 25,1,
shutter_value: 180░
internal_nd: 0
analog_gain: 1
as_shot_kelvin: 0
as_shot_tint: 0
aperture: f2.9
exposure: 0
focal_length: 36mm
distance: 1115mm
iso: 100
white_balance_kelvin: 4200
white_balance_tint: 0
emcodem, wrapping since 2009 you got the rhyme?
Ben
Posts: 31
Joined: Wed Aug 19, 2020 4:50 am

Re: Blackmagic Raw files

Post by Ben »

I filmed with no LUT but had the Film to Extended Video LUT enabled to display on the LCD screen. It's nice that it embeds what LUT I was using for monitoring in the metadata. I don't know a lot about that particular LUT, but it just typically looks the most balanced and nice. Extended video should offer a wider dynamic range compared to video but not quite as much as film. I have no idea how'd you map the values to a LUT, a bit beyond me unfortunately. BRAW is supposed to be an open standard so hopefully all the info is out there somewhere.
emcodem
Posts: 1752
Joined: Wed Sep 19, 2018 8:11 am

Re: Blackmagic Raw files

Post by emcodem »

@Ben
No worries about extracting the lut, it's just numbers. But just to be clear, i have not seen any signs about BRAW being anyhow open, they just give the SDK away without charge but limited in what they allow you to do with it. If it was truly open, i suspect ffmpeg would have a native decoder already ;-) The only thing thats open is the container they use, i think (mov)

I tend to attempt writing another tool for extracting the embedded lut because it appears to be the best solution for fully automated workflow (instead of "guessing" which lut to apply), what would make my life easier if you can share the file "Blackmagic Gen 5 Film to Extended Video.cube"
emcodem, wrapping since 2009 you got the rhyme?
Ben
Posts: 31
Joined: Wed Aug 19, 2020 4:50 am

Re: Blackmagic Raw files

Post by Ben »

This discussion has some download links for the Gen 5 LUTS. https://forum.blackmagicdesign.com/view ... 2&t=155930
If that's not quite what you're after I do have the camera with me and could probably download the LUT off of it if you needed.

I have often wondered why support for BRAW is quite limited across different software. Not even VLC can play it. Perhaps it's as you say, not as open as it should be. Or maybe there's just not heaps of demand for it or perhaps it's a fairly new codec still and hasn't gained much momentum yet. Either way it seems like we're on the cutting edge now which is cool. If FFAStrans added native support for it it'd be a huge leap forward.
emcodem
Posts: 1752
Joined: Wed Sep 19, 2018 8:11 am

Re: Blackmagic Raw files

Post by emcodem »

thanks a buch @Ben !

Yeah well we can only support it "natively" if avisynth or ffmpeg adds a decoder (this just takes far too much time to do it myself)... The best we might do if this all turns out to work is to add support in the A/V decoder for it, where it will create some intermediate file on disk first and from there we can do what we like. (sidenote: there was already some attempt to add a reverse engineered decoder in ffmpeg for it, i dont know the exact reason why it was not accepted)

However, even if A/V decoder can decode it, we will still need something separate to check and extract a possibly embedded LUT i guess.
The stuff you sent helped me to successfully extract the embedded LUT, it just takes some time for me to finish that program and then i'll share it as next step here.

It would be good if you and all other interested parties continue using the stuff from here so we continue learning about all of the braw stuff which maybe enables us to add support in the A/V decoder for it later on.
emcodem, wrapping since 2009 you got the rhyme?
emcodem
Posts: 1752
Joined: Wed Sep 19, 2018 8:11 am

Re: Blackmagic Raw files

Post by emcodem »

@Ben @andrezagato

with the interest and help of @Ben, i decided to go for an avisynth plugin.

Example workflow:
emcodem_avisynth_braw_source.json
(3.03 KiB) Downloaded 345 times
Avisynth Source plugin dll:
https://forum.doom9.org/showthread.php?t=185608

Basically you create the folder and extract the downloaded files to "%s_ffastrans_dir%\processors\avs_plugins\BRawsource\".
In your workflow, you can use a custom avisynth filter with this code:

Code: Select all

loadplugin("%s_ffastrans_dir%\processors\avs_plugins\BRawsource\BRawSource.dll")
BrawSource("%s_source%")
m_clip = last
return m_clip
After this, it should work to connect any existing filter or encoder from stock ffastrans.

BUT it is important that you UNCHECK "clear media properties" in the custom avisynth filter processor

Please instead of saying thanks, just make sure you test the stuff inside out, use it and let me know any shortcoming.
emcodem, wrapping since 2009 you got the rhyme?
Post Reply