Headline news

Want to help with Magic Lantern development, without having to code?

You can find our live webchat here: [email protected]

Author Topic: uncompressed 14-bit RAW video recording  (Read 265242 times)

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2309
uncompressed 14-bit RAW video recording
« on: April 27, 2013, 12:07:12 AM »
UPDATE:
Initially this thread was about my lv_rec module that allowed recording YUV422 and RAW video on an experimental basis.
In this module I found out a lot about the EDMAC (DMA controller) and wrote it down in our wiki. (http://magiclantern.wikia.com/wiki/Register_Map)
Since then we were able to use this high speed engine to copy portions of the image into our own buffers.

Meanwhile alex refactored all the code and optimized buffering, so that we are able to record 14 bit raw bayer data.
the result is a module named 'raw_rec' which he highly optimized to get the maximum out of our beloved canon cameras.

Since then we are constantly trying to improve the usability.
Our focused target is the 5D Mark III, but the devs are porting it to other models as you can see (thanks 1%, coutts, nanomad)

Yet this code is EXPERIMENTAL. It will cause any random failures that lead from data loss to crashing cameras.
As you know, ML is very stable, but sometimes code at this early stage causes unforseen problems.
Prepare yourself for that before you go shooting. (a backup CF card, ML-free SD card)

Key ingredients:
 - canon has an internal buffer that contains the RAW data
 - we understand the high speed DMA controller "EDMAC" a lot better now and know how to crop areas out of an image
 - we know how to get the maximum rate out of the CF card and so achieve to get up to 90MiB/s
 - we provided a reference tool that converts the Magic Lantern .RAW movie into single .DNG frames plus a MJPEG script

All together sums up to the most advanced 14-bit RAW recording system people can get for less than 3 kEUR.
We will prepare a full article as soon we see this code being stable enough for public testing.


Again. This is EXPERIMENTAL, so:
 - bloody beginners and non-geeks should not touch the whole thing. wait until it is "beginner-proof". we will tell you on the website.
 - you know that you are a bloody beginner, when you read the whole thread and you still cannot get it to work.
 - DON'T be disappointed if it doesn't work or we figure out the whole thing is unstable and/or unusable
 - NO, there is no manual yet
 - NO, there is no all-in-one tool that fits every use case
 - NO, we don't have tutorials how to use it
 - NO, not all models are supported yet ;)
 - we are just at the moment testing how good it works and what we have missed and what to improve
 - you are welcome to post comparisons, experiences (both good and bad), or even deep analysis or just cool videos
 - if you are a programmer and you see potential for improvements, grab the source and support :)

As always we want to remind you of these things:
 - Magic Lantern Team will not be responsible or liable for any kind of direct or indirect damage to your camera. (nothing new anyway)
 - The software provided for download is not related to Canon in any way
 - Do not contact Canon about issues related with this software
 - Do not blame Canon for not-implementing this feature! Why? This is no feature that is stable enough so that a company like Canon would ever release.
 - Prepare for footage loss due to frame drops, tinted frames, corrupted frames etc.
 - THIS IS EXPERIMENTAL. Deal with it. Don't blame anyone.

About sensor heating rumors:
The only thing that could get warmer is DIGiC and the CF circuitry, but i am sure that the power dissipation that reaches the sensor
through all that plastic housing will not have any noticeable temperature raise.

detailed: when doing that much DMA transfers and CF writing, we may cause a bit more current drain (which causes squared power dissipation)
but we do not encode any H.264 while recording, so we use less power there.
its *possible* that the CF writing will consume less energy than the encoding with H.264, which will result in *less* power consumption.
raw is being produced by the DIGiC for every single frame anyway. we "just" save it away.

still this is a *theory*, but i expect the consumption and the temperatures not to raise at all.


<hr>
old post:
Currently i am working on a module that records YUV422 data to card.
This code will only work when compiled from repository (there is no release yet)

5D3: can record 1904x1274 @ 12.5 fps

here some example video:
https://docs.google.com/file/d/0BwQ2MOkAZTFHdU1tR1pITXFVVXM/edit?usp=sharing
(not sure how to make it look better and not take 600MiB)

here some sample images:
https://docs.google.com/file/d/0BwQ2MOkAZTFHdFFsV1BGU0Nmd2s/edit?usp=sharing

there are three major options
 - Frame skipping: record every n-th frame. choose 2 on 5D3 in 25 fps mode to record with 12.5 fps *continuously*
 - Single file: save some processing time by writing a single file. you have to split it later on your computer. (maybe the 422 converters will somewhen support this?)
 - RAW mode: not working yet, just saving gibberish ;)

right now the module is not user-friendly. press start and it will record 2000 frames.
it will abort if the buffers are exhausted.
you can also abort by removing battery ;)

All questions regarding RAW VIDEO POST PROCESSING on any OS
HERE: http://www.magiclantern.fm/forum/index.php?topic=5404.0

All questions regarding RAW_REC MODULE COMPILATION/INSTALLATION/USAGE
HERE: http://www.magiclantern.fm/forum/index.php?topic=5405.0

And this thread here should from now on just be used for video results, and open discussion.
NOT for any installation or processing help.
« Last Edit: May 19, 2013, 03:02:24 AM by g3gg0 »

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5889
  • 600D/6D/50D/EOSM/7D
uncompressed YUV422 video recording
« Reply #1 on: April 27, 2013, 12:14:24 AM »
Working here... stops after the buffer fills. I dunno how FPS is yet or how to split up the 422 files. Got 39 frames as single, 33 as multiple.

Yoshiyuki Blade

  • Contributor
  • Member
  • *****
  • Posts: 103
  • 5D2
uncompressed YUV422 video recording
« Reply #2 on: April 27, 2013, 01:23:26 AM »
here some example video:
https://docs.google.com/file/d/0BwQ2MOkAZTFHdU1tR1pITXFVVXM/edit?usp=sharing
(not sure how to make it look better and not take 600MiB)

You can try compressing with x264. I compressed the 45 frames in the other zip file and it came out to about 25MB lossless.

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2309
uncompressed YUV422 video recording
« Reply #3 on: April 27, 2013, 01:31:40 AM »
for the posted video i used these settings (x264 in virtualdub):
--profile high444 --qp 0 --preset placebo --tune stillimage --demuxer raw --input-csp i420 --input-res %(width)x%(height) --fps %(fpsnum)/%(fpsden) -o "%(tempvideofile)" -

edit: damn, i used i420 instead of i422. retrying
edit2: causes image distortion :
« Last Edit: April 27, 2013, 01:36:30 AM by g3gg0 »

Yoshiyuki Blade

  • Contributor
  • Member
  • *****
  • Posts: 103
  • 5D2
uncompressed YUV422 video recording
« Reply #4 on: April 27, 2013, 01:51:40 AM »
Here's an output I made at 4:2:2, PC levels (0-255)
....

The image will probably look darker than it should because the levels aren't rescaled to TV (16-235), similar to how a clip from a Canon camera would look unprocessed.

Used these settings from MeGUI: --preset veryslow --crf 0 --colorprim bt709 --transfer bt709 --colormatrix bt709 --output-csp i422

Here's a "standard" 4:2:0 at TV levels. it should look as intended:
....

Edit: (Links removed due to excessive dropbox traffic causing suspension. :o)

« Last Edit: May 01, 2013, 10:11:45 AM by Yoshiyuki Blade »

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5889
  • 600D/6D/50D/EOSM/7D
uncompressed YUV422 video recording
« Reply #5 on: April 27, 2013, 05:25:07 PM »
for the old school 422 single frames I just threw them into after effects as an image sequence and exported to whatever... cineform, h264, dnxhd, animated gif, lol.

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2309
uncompressed YUV422 video recording
« Reply #6 on: April 27, 2013, 11:27:40 PM »
added crop modes to record 1904x720 @ 25 fps.

the module is recording into a single file where all frames are concatenated.
use a splitting tool to split to single files. the frame size is displayed in menu.

maybe a popular .422 converter will add a feature to split the files automatically?

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5889
  • 600D/6D/50D/EOSM/7D
uncompressed YUV422 video recording
« Reply #7 on: April 27, 2013, 11:42:39 PM »
With crop and some frame skip it keeps going with only 1 frame buffered.

There needs to be a way to stop this thing tho because when it keeps going I have to turn the camera off.

I can split on linux with HJsplit but need to know the frame size.
« Last Edit: April 27, 2013, 11:48:44 PM by 1% »

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2309
uncompressed YUV422 video recording
« Reply #8 on: April 27, 2013, 11:53:41 PM »
> There needs to be a way to stop this thing tho because when it keeps going I have to turn the camera off.
>> stop recording when leaving LV and movie mode
>> https://bitbucket.org/hudson/magic-lantern/commits/a0b2ac64c625356f618757f1d48d938406f5e770

> I can split on linux with HJsplit but need to know the frame size.
>> the frame size is displayed in menu.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5889
  • 600D/6D/50D/EOSM/7D
uncompressed YUV422 video recording
« Reply #9 on: April 27, 2013, 11:56:32 PM »
So just shut down LV?


Ha, looks like anamorphic. Splitting first one..

Heh, frame size is only in WxH... i went into a hex editor and found start then start again and took 1 frame out to get size.
« Last Edit: April 28, 2013, 12:00:37 AM by 1% »

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2309
uncompressed YUV422 video recording
« Reply #10 on: April 28, 2013, 12:02:47 AM »
Heh, frame size is only in WxH... i went into a hex editor and found start then start again and took 1 frame out to get size.

no just see the help when you are over the resolution.
it tells you the frame size.

So just shut down LV?
yep, just leave LV or video mode.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5889
  • 600D/6D/50D/EOSM/7D
uncompressed YUV422 video recording
« Reply #11 on: April 28, 2013, 12:09:28 AM »
Ah... I see it. Totally usable... wonder if it will roll with audio. Maybe would be in sync if lv_rec threw it the semaphore when writing the first frame. Also then you'd have FPS, get X frames over the lenght of the audio.

Heh, need more frame skip when audio is recording... maybe for 5d3 wav can go to SD and video to CF... but 6D is fucked. At least the audio didn't skip.
« Last Edit: April 28, 2013, 12:14:27 AM by 1% »

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2309
uncompressed YUV422 video recording
« Reply #12 on: April 28, 2013, 12:21:00 AM »
hmm then we would have to lower the resolution a bit more.
with 720 lines its at the limit already.

yeah, writing to SD is a good idea.
thought about doing that for higher fps or resolution, but didnt think about audio :)

squig

  • Moderators
  • Senior
  • *****
  • Posts: 416
  • Crash test dummy MK3
uncompressed YUV422 video recording
« Reply #13 on: April 28, 2013, 12:33:51 AM »
Is the YUV422 displaying the same level of detail as the RAW video?

If so and if you're able to lower the vertical resolution a little it's not going to be a drama to upscale the image a little in post. Cropping it horizontally to 500 pixels for a 1.5x anamorphic mode is gonna produce better resolution.
Reporter to Mahatma Gandhi: "Mr. Gandhi, what do you think of Western Civilisation?"   Gandhi: "I think it would be a good idea." https://vimeo.com/rollingshutter

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2309
uncompressed YUV422 video recording
« Reply #14 on: April 28, 2013, 12:44:08 AM »
cropping horizontally isnt feasible as it will reduce write speed a lot.

well, it will be possible if EDMAC is understood better.
but for now its not doable.

squig

  • Moderators
  • Senior
  • *****
  • Posts: 416
  • Crash test dummy MK3
uncompressed YUV422 video recording
« Reply #15 on: April 28, 2013, 12:52:37 AM »
Can you get the audio recording 8bit?
Reporter to Mahatma Gandhi: "Mr. Gandhi, what do you think of Western Civilisation?"   Gandhi: "I think it would be a good idea." https://vimeo.com/rollingshutter

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5889
  • 600D/6D/50D/EOSM/7D
uncompressed YUV422 video recording
« Reply #16 on: April 28, 2013, 01:15:18 AM »
Sure, you don't save that much though and it sounds like shit.

squig

  • Moderators
  • Senior
  • *****
  • Posts: 416
  • Crash test dummy MK3
uncompressed YUV422 video recording
« Reply #17 on: April 28, 2013, 01:24:47 AM »
8bit doesn't actually sound that bad, we used 8bit samplers back in the day. 22khz sounds like shit. I'm just thinking in terms of a sync track not audio you'd actually use. Is there a way you could just record the first 10 seconds of audio for sync?
Reporter to Mahatma Gandhi: "Mr. Gandhi, what do you think of Western Civilisation?"   Gandhi: "I think it would be a good idea." https://vimeo.com/rollingshutter

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5889
  • 600D/6D/50D/EOSM/7D
uncompressed YUV422 video recording
« Reply #18 on: April 28, 2013, 03:19:21 AM »
Probably, you can start/stop it at will.

I bet tho 8 bit vs 16 bit won't matter. The write rate just doesn't seem to be there. I only have ~150MB of buffer... maybe 5d3 has more.

squig

  • Moderators
  • Senior
  • *****
  • Posts: 416
  • Crash test dummy MK3
uncompressed YUV422 video recording
« Reply #19 on: April 28, 2013, 07:33:01 AM »
If you guys need help testing builds on the MK3 I'm up for it. I don't know jack about code but I'm a fully qualified crash test dummy. I've got a 1000x Lexar card.
Reporter to Mahatma Gandhi: "Mr. Gandhi, what do you think of Western Civilisation?"   Gandhi: "I think it would be a good idea." https://vimeo.com/rollingshutter

Kabuto1138

  • Freshman
  • **
  • Posts: 84
uncompressed YUV422 video recording
« Reply #20 on: April 28, 2013, 08:44:47 AM »
I'm with squig, I have a 5d2(don't know if this patch is working for the 5d2) and I also have a 1000x Lexar card

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5889
  • 600D/6D/50D/EOSM/7D
uncompressed YUV422 video recording
« Reply #21 on: April 28, 2013, 08:57:01 AM »
Should it write start time and end time to the file name?

Michael Zöller

  • Administrator
  • Senior
  • *****
  • Posts: 303
  • 5D Mark II
uncompressed YUV422 video recording
« Reply #22 on: April 28, 2013, 01:46:21 PM »
Should it write start time and end time to the file name?
Its nice to have. Audio wise many use an external recorder and sync with Pluraleyes. Just buffer-recording the first (and last?) two seconds might be enough for it to sync. But we wouldn't store audio into the resulting video file anyway, would we?
neoluxx.de
EOS 5D Mark II | EOS 600D | EF 24-70mm f/2.8 | Tascam DR-40

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5889
  • 600D/6D/50D/EOSM/7D
uncompressed YUV422 video recording
« Reply #23 on: April 28, 2013, 06:02:17 PM »
When I record wav with it, run time is reduced. 

N/A

  • Senior
  • ****
  • Posts: 409
  • Dreaming in 14 bit
uncompressed YUV422 video recording
« Reply #24 on: April 28, 2013, 06:32:27 PM »
Uncompressed video with audio would be ok BUT I'd sacrifice audio to have better video. And besides, you can still do the clapboard trick if absolutely necessary.

Edit: First page!  ;D
« Last Edit: May 17, 2013, 04:23:38 PM by N/A »
7D. 600D. Rokinon 35 cine. Sigma 30 1.4
Audio and video recording/production, Random Photography
Want to help with the latest development but don't know how to compile?