Recovering from read errors in Linux

Discussion of advanced MakeMKV functionality, expert mode, conversion profiles
Cobalt
Posts: 3
Joined: Tue Nov 14, 2017 3:37 pm

Recovering from read errors in Linux

Post by Cobalt »

I recently encountered a blu-ray disc that caused MakeMKV to consistently throw a read error when reading one of the titles. Fortunately, that title was not the main feature so I could still watch the movie. However, I realised the bad title was a behind the scenes feature in the disc extras that I really wanted too. After poking around these forums and using my Linux knowledge I found the following procedure to work. It's very manual and can probably be improved but I'm posting it in case this helps another MakeMKV Linux user rip a disc with bad sectors.

The key tool is ddrescue whose manual explains how to read faulty optical media:

https://www.gnu.org/software/ddrescue/m ... ical-media

Step 1:

Use ddrescue to make a raw copy of the blu-ray disc to an image file and also a map file which identifies the bad areas of the disc (the bytes it could not read):

Code: Select all

ddrescue -n -b2048  /dev/sr0 brimage mapfile
This creates (in the current directory) an image file called brimage which is a byte for byte copy of the blu ray disc at /dev/sr0 (which refers to your blu-ray drive device). The file brimage will contain zeros for those parts of the disk that ddrescue could not read. The map file mapfile is a text file which lists the sections ddrescue failed to read.

Step 2:

Rerun ddrescue to repeatedly read the bad sectors and attempt to recover as much as it can:

Code: Select all

ddrescue -d -r1 -b2048 /dev/sr0 brimage mapfile
This command updates the map file and the image file. It also reports the size of the read error. You may have to repeat the above command several times. Hopefully, the reported read error size decreases down to zero. (In my case it went down to 230K and no further. This turned out to be acceptable as that meant I'd only lost about 4 or 5 frames from the video stream.)

Step 3:

As described by JohnYaya, use MakeMKV to copy the blu-ray disc without decryption:
JohnYaya wrote:Start a backup, uncheck the decrypt option. Let it run until it gets to the first m2ts file. At that point, it has saved the disc code, which is a file called "discatt.dat". Stop the backup, quit MakeMKV, [...]
In these examples, I'm going to use ~/backup/THE_MATRIX as the sub-directory that is specified in MakeMKV as the output folder.

Step 4:

Delete the incomplete BDMV directory from the backup folder:

Code: Select all

rm  -rvf ~/backup/THE_MATRIX/BDMV
Mount the image file on /mnt

Code: Select all

sudo mount -o loop brimage /mnt
Copy the entire BDMV directory from within the image file to the MakeMKV backup folder:

Code: Select all

cp -rv /mnt/BDMV ~/backup/THE_MATRIX/
Step 5:

Follow the last part of JohnYaya instructions:
JohnYaya wrote:[...] start MakeMKV, select File>Open Files and navigate to and double click the discatt.dat file.
The discatt.dat file will be somewhere within the backup folder ~/backup/THE_MATRIX/.

And now you can use MakeMKV to rip the backup to mkv files. But first change the output folder in MakeMKV to something else, for example, ~/Videos/THE_MATRIX (i.e. where you usually rip your discs to).

Step 6:

Clean up. You can delete the backup folder and the disc image once you have the titles ripped to mkv files.

Code: Select all

rm -rvf ~/backup/THE_MATRIX
sudo umount /mnt
rm brimage mapfile

That's it. I hope it is helpful.

Cheers
kaligari
Posts: 1
Joined: Fri Mar 02, 2018 4:33 pm

Re: Recovering from read errors in Linux

Post by kaligari »

hi Cobalt,

is it possible to do the same recovering on Windows? I found only this video recovery software and it doesn't help me. THanks!

Edited to remove link; the link has nothing to do with recovering from optical media read errors.
Cobalt
Posts: 3
Joined: Tue Nov 14, 2017 3:37 pm

Re: Recovering from read errors in Linux

Post by Cobalt »

kaligari wrote:hi Cobalt,

is it possible to do the same recovering on Windows? I found only this video recovery software and it doesn't help me. THanks!

I am sorry, this technique is for Linux. I do not think that ddrescue is available for Windows. I do not use Windows and do not know what Windows software would do the same task as ddrescue.

Good luck with recovering your disc.
crackers8199
Posts: 5
Joined: Thu Mar 08, 2018 9:11 am

Re: Recovering from read errors in Linux

Post by crackers8199 »

is there a trick to getting this to work that i'm missing? i followed everything exactly and i still can't get makemkv to get past the "corrupt or invalid at offset xxxxxx, attempting to work around" parts of the file...it has been running for 4+ hours and is stuck in the same spot. the "time remaining" counter just keeps increasing. now it's up to 24+ hours remaining.
nilpin
Posts: 1
Joined: Tue May 15, 2018 9:12 pm

Re: Recovering from read errors in Linux

Post by nilpin »

kaligari wrote:hi Cobalt,

is it possible to do the same recovering on Windows? I found only this video recovery software and it doesn't help me. THanks!

Edited to remove link; the link has nothing to do with recovering from optical media read errors.
For Windows systems, I suggest using a Linux Live cd - the following page details how to install ddrescue using Knoppix Linux. https://www.data-medics.com/forum/how-t ... -t133.html

I found this post while looking for a way of doing this on a Mac. I'm currently trying this on a Mac and I'll come back with any steps that are different when/if I get this working.
spidernut
Posts: 1
Joined: Fri Feb 22, 2019 2:43 am

Re: Recovering from read errors in Linux

Post by spidernut »

I followed the instructions above, and still had some problems - makemkv was able to "work around" a smaller error, but then gave up when it encountered a longer damaged stretch. I managed to salvage the disk though, by using mplayer with makemkv to seek around the error.

I followed the instructions to create a backup, with the discatt.dat file, and with the BDMV directory copied in from a ddrescue-created image.

Then:
mplayer br://0 -bluray-device /path/to/backup -dumpstream
Then, more such calls, but with -sb options to cause mplayer to seek past the errors. There is some trial and error involved in figuring out where to seek to. After the first error, you can look at the filesize of the first dumped stream, and add to it (roughly a few MB/s) to guess at where to seek to. You'll want to rename the stream.dump before starting again, since it will get overwritten if you don't.

For the disk I was working on, I lost 6 seconds of the film, but that's way better than losing the whole thing.

Thanks.
lepathi
Posts: 2
Joined: Wed Jun 10, 2020 12:29 pm

Re: Recovering from read errors in Linux

Post by lepathi »

Doing this I was able to create an Image of Alita: Battle Angel with "only" 70MB corrupt sectors.

Yet, I am unable to rip the movie with makeMKV due to 342 'HashCheck Errors". Did anybody experience similar and/or has a workaround for me to get that movie ripped?
Rojma
Posts: 68
Joined: Tue Jan 07, 2014 12:52 pm

Re: Recovering from read errors in Linux

Post by Rojma »

I've used the process from the below link which allowed me to ultimately rip content from a damaged disc with the result being only a second or two of garbled audio/video. It is very similar to the above process:

https://html5.litten.com/how-to-fix-rec ... cd-or-dvd/
lepathi
Posts: 2
Joined: Wed Jun 10, 2020 12:29 pm

Re: Recovering from read errors in Linux

Post by lepathi »

Rojma wrote:
Fri Jun 19, 2020 2:56 pm
I've used the process from the below link which allowed me to ultimately rip content from a damaged disc with the result being only a second or two of garbled audio/video. It is very similar to the above process:

https://html5.litten.com/how-to-fix-rec ... cd-or-dvd/
I already did multiple runs, let it run for more than a week, yet makeMKV always fails ripping at the same position. Currently I am at 60mb and this is the extend of how much I can recover. I would be completely happy with that, because it theoretically only means a loss of 0,1%. Unbelievable that a small scratch on a new 4K-Bluray is causing so much trouble. 😔

Can't I just tell makeMKV to ignore corrupt data and get everything ripped that's fine?
xr200
Posts: 56
Joined: Tue Nov 10, 2015 3:11 am

Re: Recovering from read errors in Linux

Post by xr200 »

Can't I just tell makeMKV to ignore corrupt data and get everything ripped that's fine?
No, you can't. MakeMKV will only succeed if it can read every bit correctly.
Similarly, if you download a PCLOS *iso file, you need every single bit to be
correct: there's no way to say "oh heck, that's close enough."

You do have options in MakeMKV under Preferences -> IO -> Read Retry Count to set a high value,
and MakeMKV will keep trying to re-read a failed section of the disc until some criterion is met.
But just setting this value to a big number doesn't mean you'll fix the problem: it does mean
MakeMKV will run longer.

DVD and Blu-Ray players that you connect to your TV have software that is written to skip/ignore
small glitches when you play an optical disc with minor flaws so you don't see them on your
TV. MakeMKV does not ignore errors: it's either correct, or it's wrong.
MrVanx
Posts: 18
Joined: Mon Mar 23, 2015 9:52 pm

Re: Recovering from read errors in Linux

Post by MrVanx »

Hi All,
Im in the process of re-encoding a bunch of my bluray collection to h265 (which is going well) and one of my discs is being a pain.

Ive started the process in the original post, just out of interest how long did the ddrescue section (parts 1 and 2) take for anyone whos tried this??

Its mainly for an idea of how long it will take to try and recover this (if its a few days then I will set my latest handbrake job going first).

Cheers all
Rojma
Posts: 68
Joined: Tue Jan 07, 2014 12:52 pm

Re: Recovering from read errors in Linux

Post by Rojma »

It depends on the level of damage. I think I had one go for like 4-5 days and multiple runs before it was able to fully recover all data. I've had others only go for a few hours.
MrVanx
Posts: 18
Joined: Mon Mar 23, 2015 9:52 pm

Re: Recovering from read errors in Linux

Post by MrVanx »

Rojma wrote:
Sat Jun 27, 2020 4:09 pm
It depends on the level of damage. I think I had one go for like 4-5 days and multiple runs before it was able to fully recover all data. I've had others only go for a few hours.
I took the plunge so we'll see how it goes. It made quick progress to around 40% in less than an hour then started working slowly so it's no doubt spotted the bad area of the disc (yes it looks spotless which is even more annoying!) so fingers crossed it can churn it. I knew moving to Linux was a good idea in 2015! Teehee!

Edit: first pass took ~16hrs with 99.99% of the disc rescued, 1057k in bad sectors and 25 read errors, second step (first go) gave me the same with 1407 read errors, second go gave me 736 read errors, same again and im now on my 4th run of step 2 so hopefully that starts to go down a bit.
MrVanx
Posts: 18
Joined: Mon Mar 23, 2015 9:52 pm

Re: Recovering from read errors in Linux

Post by MrVanx »

OK so I followed the guide (thanks!), the number of read errors didnt drop below 736 after ~6 times of trying step 2, bad sector size was 1507kb. So i called it quits at that point and moved onto step 3 and got as far as opening the "backup" using the discatt.dat file.

I encountered a hash check error and 5 out of the 6 titles on the disc were listed once the backup was open, unfortunately only 3 of those successfully exported to mkv files (corrupted files?). I have been able to rip successfully 5 out of the 6 titles in makemkv previously (though since then the disc has struggled to be opened by makemkv let alone rip anything useful), so its just the one title I havent been able to get at, the error area must be tiny because ive watched the offending title and didnt notice anything on the blu-ray player.

At this stage Im willing to try a few more goes maybe giving the disc an extra detailed clean to see if we can free the remaining data in there :)

Just out of interest is it possible to rip the title directly in handbrake using the integration functionality of makemkv or am I misunderstanding how it works? (VLC direct playback is working fine).
Rojma
Posts: 68
Joined: Tue Jan 07, 2014 12:52 pm

Re: Recovering from read errors in Linux

Post by Rojma »

I strongly recommend you only use isoprophl alcohol to clean the disc. For me using alcohol has resolved almost all read issues I have had with disc read issues. Using other methods suggested around the interwebs, such as liquid hand soap, has actually led to more problems for me.
Post Reply