Author Topic: How to replace file footer, aka fix the Error: This ain't a lv_rec RAW file  (Read 39322 times)

Shield

  • Senior
  • ****
  • Posts: 254
If you are recording and run out of space on the card, when you try to extract the dng files you'll get the following error:

Error: This ain't a lv_rec RAW file

You need to replace the file footer information to get this back.

Here's what I did, and I'm sure there are easier ways, but this is free.

Step 1:
Download the freeware Hex editor from here:
http://mh-nexus.de/en/downloads.php?product=HxD

Step 2: Open the .raw file in the hex editor.  Scroll all the way to the bottom.

You have 2 choices at this point:

Option 1 - Record another file with the same settings on the card, and retrieve the footer information in the hex editor.  It should be the last 12 lines of the file.  The downside to doing it this way is it'll only extract the same number of DNG files that the secondary file has listed; i.e. if your 2nd file is 200 megs or so, if you copy that file's footer information to the (assuming) larger troubled file, you'll only be able to pull out the first 50 or so dng files.

So I suggest you do #2:

Option 2 - Copy and paste this into your file footer:

52 41 57 4D 80 07 38 04 00 5F 37 00 F4 21 00 00 01 00 00 00 A8 5D 00 00 18 02 98 19 18 02 98 19 01 00 00 00 00 20 15 0B 26 05 00 00 20 08 00 00 38 0E 00 00 50 34 49 00 0E 00 00 00 0C 08 00 00 98 3A 00 00 00 00 00 00 00 00 00 00 88 07 00 00 08 05 00 00 1E 00 00 00 92 00 00 00 26 05 00 00 1A 08 00 00 00 00 00 00 00 00 00 00 00 01 01 02 01 00 00 00 42 1A 00 00 10 27 00 00 85 FD FF FF 10 27 00 00 3D FC FF FF 10 27 00 00 41 EF FF FF 10 27 00 00 AC 30 00 00 10 27 00 00 EC 07 00 00 10 27 00 00 74 FC FF FF 10 27 00 00 72 08 00 00 10 27 00 00 24 16 00 00 10 27 00 00 82 03 00 00

Save the file, and start unpacking your dng's!

This will work for file sizes up to 32gb.
**Of note - say your "bad" file was smaller than 32GB - let's say it was 11GB - by using this footer it will try to unpack 8692 DNG files.  Since I'm not smart enough to read hex, I just estimate where the good dng files should be and delete everything after it.

Here's a screen shot of the pasted in footer:


Shield

  • Senior
  • ****
  • Posts: 254
Since I'm not a programmer or really that smart, I've been doing "trial and error" work on how many frames it will extract.

The key numbers are these:

52 41 57 4D 80 07 38 04 00 5F 37 00 F4 21 00 00 01 00 00 00 A8 5D 00 00 18 02 98 19 18 02 98 19 01 00 00 00 00 20 15 0B 26 05 00 00 20 08 00 00 38 0E 00 00 50 34 49 00 0E 00 00 00 0C 08 00 00 98 3A 00 00 00 00 00 00 00 00 00 00 88 07 00 00 08 05 00 00 1E 00 00 00 92 00 00 00 26 05 00 00 1A 08 00 00 00 00 00 00 00 00 00 00 00 01 01 02 01 00 00 00 42 1A 00 00 10 27 00 00 85 FD FF FF 10 27 00 00 3D FC FF FF 10 27 00 00 41 EF FF FF 10 27 00 00 AC 30 00 00 10 27 00 00 EC 07 00 00 10 27 00 00 74 FC FF FF 10 27 00 00 72 08 00 00 10 27 00 00 24 16 00 00 10 27 00 00 82 03 00 00


So for example if I change "F4 21" to 66 22" it will try to extract 8806 frames, or "6A 29" is over 10,000 frames (10,602 to be exact). 

Here's some sample footers for you:

8806 frames (for corrupt 32GB raw file):  - This is exactly the number of "good" dng files I got from an empty 32GB Lexar recording a full 32GB file @ 1920x1080 with FPS override set to 24FPS.  So the F4 21 has been changed to 66 22.  Not bolded so can copy and paste:

52 41 57 4D 80 07 38 04 00 5F 37 00 66 22 00 00 01 00 00 00 A8 5D 00 00 18 02 98 19 18 02 98 19 01 00 00 00 00 20 15 0B 26 05 00 00 20 08 00 00 38 0E 00 00 50 34 49 00 0E 00 00 00 07 08 00 00 BB 35 00 00 00 00 00 00 00 00 00 00 88 07 00 00 08 05 00 00 1E 00 00 00 92 00 00 00 26 05 00 00 1A 08 00 00 00 00 00 00 00 00 00 00 00 01 01 02 01 00 00 00 42 1A 00 00 10 27 00 00 85 FD FF FF 10 27 00 00 3D FC FF FF 10 27 00 00 41 EF FF FF 10 27 00 00 AC 30 00 00 10 27 00 00 EC 07 00 00 10 27 00 00 74 FC FF FF 10 27 00 00 72 08 00 00 10 27 00 00 24 16 00 00 10 27 00 00 B2 03 00 00

More to follow...




Shield

  • Senior
  • ****
  • Posts: 254
66 11 = 4454  (Roughly the fix for a corrupt 16GB file)

Footer:
52 41 57 4D 80 07 38 04 00 5F 37 00 66 11 00 00 01 00 00 00 A8 5D 00 00 18 02 98 19 18 02 98 19 01 00 00 00 00 20 15 0B 26 05 00 00 20 08 00 00 38 0E 00 00 50 34 49 00 0E 00 00 00 07 08 00 00 BB 35 00 00 00 00 00 00 00 00 00 00 88 07 00 00 08 05 00 00 1E 00 00 00 92 00 00 00 26 05 00 00 1A 08 00 00 00 00 00 00 00 00 00 00 00 01 01 02 01 00 00 00 42 1A 00 00 10 27 00 00 85 FD FF FF 10 27 00 00 3D FC FF FF 10 27 00 00 41 EF FF FF 10 27 00 00 AC 30 00 00 10 27 00 00 EC 07 00 00 10 27 00 00 74 FC FF FF 10 27 00 00 72 08 00 00 10 27 00 00 24 16 00 00 10 27 00 00 B2 03 00 00

(You may need to remove some DNG files at the end; take a look at them in your image viewer software, i.e. Photoshop.  If they look like bad frames you'll know right away.


Shield

  • Senior
  • ****
  • Posts: 254
9e 08 - 2206 frames; should be enough to fix corrupt 8GB file

Begin Footer

52 41 57 4D 80 07 38 04 00 5F 37 00 9e 08 00 00 01 00 00 00 A8 5D 00 00 18 02 98 19 18 02 98 19 01 00 00 00 00 20 15 0B 26 05 00 00 20 08 00 00 38 0E 00 00 50 34 49 00 0E 00 00 00 07 08 00 00 BB 35 00 00 00 00 00 00 00 00 00 00 88 07 00 00 08 05 00 00 1E 00 00 00 92 00 00 00 26 05 00 00 1A 08 00 00 00 00 00 00 00 00 00 00 00 01 01 02 01 00 00 00 42 1A 00 00 10 27 00 00 85 FD FF FF 10 27 00 00 3D FC FF FF 10 27 00 00 41 EF FF FF 10 27 00 00 AC 30 00 00 10 27 00 00 EC 07 00 00 10 27 00 00 74 FC FF FF 10 27 00 00 72 08 00 00 10 27 00 00 24 16 00 00 10 27 00 00 B2 03 00 00




Shield

  • Senior
  • ****
  • Posts: 254
80 04 = 1152 frames; should be exact number for corrput 4GB files.

Footer
52 41 57 4D 80 07 38 04 00 5F 37 00 80 04 00 00 01 00 00 00 A8 5D 00 00 18 02 98 19 18 02 98 19 01 00 00 00 00 20 15 0B 26 05 00 00 20 08 00 00 38 0E 00 00 50 34 49 00 0E 00 00 00 07 08 00 00 BB 35 00 00 00 00 00 00 00 00 00 00 88 07 00 00 08 05 00 00 1E 00 00 00 92 00 00 00 26 05 00 00 1A 08 00 00 00 00 00 00 00 00 00 00 00 01 01 02 01 00 00 00 42 1A 00 00 10 27 00 00 85 FD FF FF 10 27 00 00 3D FC FF FF 10 27 00 00 41 EF FF FF 10 27 00 00 AC 30 00 00 10 27 00 00 EC 07 00 00 10 27 00 00 74 FC FF FF 10 27 00 00 72 08 00 00 10 27 00 00 24 16 00 00 10 27 00 00 B2 03 00 00


Hex is hurting my brain, so that's all for now.  If you want other file sizes let me know.
Shawn

Shield

  • Senior
  • ****
  • Posts: 254
Can a MOD move this to the "workflow" forum?
Thanks!

Shawn

boytecreative

  • Just arrived
  • *
  • Posts: 1
Thanks for your hard work Shield. Looks like you're doing this on a PC platform, you don't know if mac works the same do you?

Copy/Paste didn't work from browser to the editor, so I typed it in by hand, confirmed multiple times, and still haven't had any luck after I save it and then redrop it back into the ML raw2dng converter.

I'm on a 2013 iMac, tried two different editors (010 editor and Hex Fiend), type in the code at the very bottom of the code (is there something I am supposed to do in order to get to the footer?), save it, and then drag the raw file back on to the raw2dng and receive the same error "Error: This ain't a lv_rec RAW file"

I also tried two different file sizes, 4.29gb and 2.99gb.

Any ideas?

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Mac needs newer converter if it can't read over 2.x gb.

Shield

  • Senior
  • ****
  • Posts: 254
Mac needs newer converter if it can't read over 2.x gb.

I see on the new build the footer is auto-saved, which makes my thread rather pointless.  First of all great job, and I guess you can delete this now... :'(

DaveAbbott

  • New to the forum
  • *
  • Posts: 8
Hey guys, how do I work out what I should change the values to?

I've got a 2.68GB file that was shot at 1280 x 720 at 25 fps.

I'm able to extract files using this technique but each frame it extracts is a collage of 9 frames. If I can work out the correct value I can probably recover a nice bit of footage.

Thanks in advance.

Edit: Nevermind. I found a file of very similar size and copied the footer from that. Thanks Shield, I couldn't have done it without you!

DerekDock

  • Freshman
  • **
  • Posts: 59
So I was referred to this thread by the ML twitter to fix what appears to be corrupted RAW files. Anyone know if this works? I see that there are a ton of FFFFFFF hexs at the end of my file but also sporadic patches throughout the file. Fixing the end enables me to run through the process of converting and then to lightroom but it's just Digital pink noise in LR.

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Obviously not pointless for people with damaged files.

Paste a footer of correctitude onto the end and re-save.

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12360
  • Quarantined
You can also upload a small clip (not more than 100MB though, since my net connection is limited).

DerekDock

  • Freshman
  • **
  • Posts: 59
If you guys want one of the clips to dissect let me know but i just went and reshot everything as it seemed too corrupted to fix and the newest build worked smooth. Thanks for all your efforts!

Haliburton

  • New to the forum
  • *
  • Posts: 44
Thanks, Shawn (Shield).

1% is right:

Obviously not pointless for people with damaged files.

Paste a footer of correctitude onto the end and re-save.

The collage of 9 mini-frames that DaveAbbott experienced, appears to happen if the footer is copied from RAW file of a different camera and/or resolution.

What worked for me, was to copy the last 192 bytes (eg. 12 lines x 16 bytes per line; begins with RAWM as seen in the ASCII column) of a file from the same camera shot at the same resolution, and append it to the damaged file, replacing any final truncated line.

At this point, you will only be able to extract as many frames as the file you copied the footer from has, but at least the frame size will be correct, avoiding the mini-frames problem.

Next, replace the 4th group of 4 bytes, as Shield pointed out in bold:

52 41 57 4D 80 07 38 04 00 5F 37 00 F4 21 00 00 01 00 00 00 A8 5D 00 00 18 02 98 19 18 02 98 19 01 00 00 00 00 20 15 0B 26 05 00 00 20 08 00 00 38 0E 00 00 50 34 49 00 0E 00 00 00 0C 08 00 00 98 3A 00 00 00 00 00 00 00 00 00 00 88 07 00 00 08 05 00 00 1E 00 00 00 92 00 00 00 26 05 00 00 1A 08 00 00 00 00 00 00 00 00 00 00 00 01 01 02 01 00 00 00 42 1A 00 00 10 27 00 00 85 FD FF FF 10 27 00 00 3D FC FF FF 10 27 00 00 41 EF FF FF 10 27 00 00 AC 30 00 00 10 27 00 00 EC 07 00 00 10 27 00 00 74 FC FF FF 10 27 00 00 72 08 00 00 10 27 00 00 24 16 00 00 10 27 00 00 82 03 00 00

According to the number of frames you shot (thus size of your *.RAW file), choose the next bigger number of frames according to Shield's list:

66 22 00 00 = 8806 frames  (Roughly the fix for a corrupt 32 GB file at Shield’s resolution of 1920x1080)
66 11 00 00 = 4454 frames  (Roughly the fix for a corrupt 16 GB file at Shield’s resolution of 1920x1080)
9e 08 00 00 = 2206 frames  (Roughly the fix for a corrupt 8  GB file at Shield’s resolution of 1920x1080)
80 04 00 00 = 1152 frames  (Roughly the fix for a corrupt 4  GB file at Shield’s resolution of 1920x1080)

Yes, you'll end up with a garbage .dng files representing the excess of the number chosen above, beyond the actual number of frames you shot, but you can just throw those out.

I’m using hexfiend for Mac http://ridiculousfish.com/hexfiend/

Note to boytecreative: I found that hexfiend would only save changes if "Saved as…" a new file name.

As least in my first few baby steps with hexfield, it didn’t seem to save files in place.

eatbuckshot

  • New to the forum
  • *
  • Posts: 24
wow hahaha just a couple hours ago I also discovered this fix using the same exact program, hxd
trying to save some footage

I am a computer engineer though, and it's helpful to use
https://bitbucket.org/hudson/magic-lantern/src/1222c61e8120e24f2d8fd4836179c5891a4bc20f/modules/lv_rec/lv_rec.h?at=unified
Code: [Select]
#ifndef _lv_rec_h_
#define _lv_rec_h_

#include "raw.h"

/* file footer data */
typedef struct
{
    unsigned char magic[4];
    unsigned short xRes;
    unsigned short yRes;
    unsigned int frameSize;
    unsigned int frameCount;
    unsigned int frameSkip;
    unsigned int sourceFpsx1000;
    unsigned int reserved3;
    unsigned int reserved4;
    struct raw_info raw_info;
} lv_rec_file_footer_t;

#endif
where each char is 1 byte (2 hex characters), short is 2 bytes, and int is 4 bytes, that way you can crossreference the struct definition with the number's you are editing in hex.

the raw hex stores these numbers in "little endian" which means that if you want to obtain the real value of an integer from raw hex you would have to write it in reverse( raw hex: "52 41 57 4D 80 07 38 04 00 5F 37 00 F4 21 00 00 ..."  is 00 00 21 F4 or just 0x21F4)
I used windows calculator in programmer mode to convert from hex to dec quickly (f4 f5)

I used footers from raw videos that were correct to calculate how many frames i had using the framesize field which is the size of a frame in bytes.  I took the file size and divided by the frame size to get a rough rounded down frame count that i would translate into hex, into little endian and write into the raw hex in that location in the footer.

Shield

  • Senior
  • ****
  • Posts: 254
I recorded a 64GB file tonight and the footer was MIA.

Here's the HEX that is slightly larger than for a 64GB file, but should cover all 64GB 1920x1080 23.976 files:

52 41 57 4D 80 07 38 04 00 5F 37 00 66 46 00 00 01 00 00 00 A8 5D 00 00 18 02 98 19 18 02 98 19 01 00 00 00 00 20 15 0B 26 05 00 00 20 08 00 00 38 0E 00 00 50 34 49 00 0E 00 00 00 0C 08 00 00 98 3A 00 00 00 00 00 00 00 00 00 00 88 07 00 00 08 05 00 00 1E 00 00 00 92 00 00 00 26 05 00 00 1A 08 00 00 00 00 00 00 00 00 00 00 00 01 01 02 01 00 00 00 42 1A 00 00 10 27 00 00 85 FD FF FF 10 27 00 00 3D FC FF FF 10 27 00 00 41 EF FF FF 10 27 00 00 AC 30 00 00 10 27 00 00 EC 07 00 00 10 27 00 00 74 FC FF FF 10 27 00 00 72 08 00 00 10 27 00 00 24 16 00 00 10 27 00 00 82 03 00 00

It will unpack 18022 frames.

Shawn

MarkvC

  • New to the forum
  • *
  • Posts: 2
This is my first post on this forum so i apologise if this has been answered else where but i searched and this is the only thread that came up.
I shot 15 clips of which 6 went over the 4gb mark. The card still had approximately 13gb of spaced remaining. I used Raw2DNG version 0.13 to convert the clips to DNG's. Of all the clips only the ones that whet over the 4gb mark came up with this error:
Error: This ain't a lv_rec RAW file
I have been through this process and replaced the footer for a 4.29gb file with the 8GB  footer from above and when i tried to open the DNG image sequence in After Effects i got a lot of very corrupt looking images with psychedelic colors in them.
Please help 
This is not some thing that I can reshoot as it was dolphins feeding on small fish. :( :( :(

xfornos

  • New to the forum
  • *
  • Posts: 2
MarkVc, I have the same problem, with a file 4'13GB.
I need the solution, it's so important.

Thank you.

Barry Williams films

  • New to the forum
  • *
  • Posts: 2
MarkV Im having the same problem also.....Man I thought I had it.......SMH

Gigi_Five

  • Just arrived
  • *
  • Posts: 1
The problem is:
CF is fat32 so file longer than 4GB does not have enough addressing space so ML splits the file and writes info of entire recording to last file. This is what you have to do, you must join those two files on some other file system i.e. (NTFS). The command is simple:

for example if you have "M29-1817.RAW" and "M29-1817.R00", then the command is (in command prompt):
copy /b M29-1817.RAW + M29-1817.R00 M29-JOINED.RAW

this is for windows, there must be some similar command on mac for joining files.

it worked for me..

Regards

BrotherD

  • New to the forum
  • *
  • Posts: 49
If you are recording and run out of space on the card, when you try to extract the dng files you'll get the following error:

Error: This ain't a lv_rec RAW file

You need to replace the file footer information to get this back.

Here's what I did, and I'm sure there are easier ways, but this is free.

Step 1:
Download the freeware Hex editor from here:
http://mh-nexus.de/en/downloads.php?product=HxD

Step 2: Open the .raw file in the hex editor.  Scroll all the way to the bottom.

You have 2 choices at this point:

Option 1 - Record another file with the same settings on the card, and retrieve the footer information in the hex editor.  It should be the last 12 lines of the file.  The downside to doing it this way is it'll only extract the same number of DNG files that the secondary file has listed; i.e. if your 2nd file is 200 megs or so, if you copy that file's footer information to the (assuming) larger troubled file, you'll only be able to pull out the first 50 or so dng files.

So I suggest you do #2:

Option 2 - Copy and paste this into your file footer:

52 41 57 4D 80 07 38 04 00 5F 37 00 F4 21 00 00 01 00 00 00 A8 5D 00 00 18 02 98 19 18 02 98 19 01 00 00 00 00 20 15 0B 26 05 00 00 20 08 00 00 38 0E 00 00 50 34 49 00 0E 00 00 00 0C 08 00 00 98 3A 00 00 00 00 00 00 00 00 00 00 88 07 00 00 08 05 00 00 1E 00 00 00 92 00 00 00 26 05 00 00 1A 08 00 00 00 00 00 00 00 00 00 00 00 01 01 02 01 00 00 00 42 1A 00 00 10 27 00 00 85 FD FF FF 10 27 00 00 3D FC FF FF 10 27 00 00 41 EF FF FF 10 27 00 00 AC 30 00 00 10 27 00 00 EC 07 00 00 10 27 00 00 74 FC FF FF 10 27 00 00 72 08 00 00 10 27 00 00 24 16 00 00 10 27 00 00 82 03 00 00

Save the file, and start unpacking your dng's!

This will work for file sizes up to 32gb.
**Of note - say your "bad" file was smaller than 32GB - let's say it was 11GB - by using this footer it will try to unpack 8692 DNG files.  Since I'm not smart enough to read hex, I just estimate where the good dng files should be and delete everything after it.

Here's a screen shot of the pasted in footer:



Shield I hope you or someone can help me out. Today is the first time I have seen the "This ain't a lv_rec Raw file" problem so I need  help fixing this raw file.

My problems are: Copying the number there are two options: paste write and paste insert? One way, or maybe both, I did it twice,  pasted in the right column with the symbols. In your screen shot the symbols are at the right of the numbers you copied?  I was hoping but not surprised that method did not work.  Now it is time to seek help. This was an 8gb card and the file is 281mbs. Is there a way to avoid this from happening again?

Derrick   


BrotherD

  • New to the forum
  • *
  • Posts: 49
I am still need help opening a 288mb "This ain't a lv_rec Raw file." Raw2dng or Eyeframe could not open it. The file was on a 8gb sd card that only had three raw files, none larger than 488mb's on it? I tried to follow the instructions by copying and saving the "numbers" twice to the file using the HxD program? Somebody help!

Derrick

jas.brooks

  • New to the forum
  • *
  • Posts: 14
Can confirm that this method worked for me on OS X. I had a corrupted (header-less) file caused by filling the card whilst shooting (I'm 99% sure).

Using a free hex editor called "0xED.app" I copied the last 12 lines (16 bytes per line) from another shot with similar settings. Replaced the file size bytes (bytes 13 & 14) with the code for a 4gb file, and once converted, just deleted the blank black frames.

Thanks Shield! Nice method. :-)

jason

clapalm

  • New to the forum
  • *
  • Posts: 6
The problem is:
CF is fat32 so file longer than 4GB does not have enough addressing space so ML splits the file and writes info of entire recording to last file. This is what you have to do, you must join those two files on some other file system i.e. (NTFS). The command is simple:

for example if you have "M29-1817.RAW" and "M29-1817.R00", then the command is (in command prompt):
copy /b M29-1817.RAW + M29-1817.R00 M29-JOINED.RAW

this is for windows, there must be some similar command on mac for joining files.

it worked for me..

Regards

I'm having the same problem and I am using a Mac.  Can anyone please suggest the Mac solution for joining the .RAW and .R00 files?

Thanks