The problem I faced
When a Blu-ray rip fails in MakeMKV with [c]MEDIUM ERROR: L-EC UNCORRECTABLE ERROR[/c], I do proper cleaning and hope for the best.
While that works for mass-market discs, it is not an option for rare, out-of-print (OOP), or boutique Blu-ray releases. For example, Takeshi Kitano's films on Blu-ray (such as Outrage or Hana-Bi, where a new copy can easily cost up to €111 (current price on amazon)) are becoming increasingly scarce and expensive. Throwing away a rare disc because a single 2 KB sector at the layer transition is unreadable—when 99.99% of the 47 GB disc is completely healthy—is a huge loss for physical media preservation.
As MakeMKV is designed for bit-perfect archival rips, it enforces a strict all-or-nothing policy: if even a single 2048-byte sector fails hardware error correction, it aborts the entire rip and deletes the output file. There are posts in the Forum complaining about this behaviour, but this is not one of these posts.
This post documents an end-to-end forensic workflow on Linux Mint to rescue a damaged dual-layer Blu-ray that suffered from both USB optical drive disconnects and permanent physical sector damage at the layer break—recovering 99.99% of the movie with lossless video and audio. I was immensely helped by an LLM in arriving at this process. Please don't feel offended by that.
---
1. System Environment, Hardware & Required Packages
Here is my Hardware / Software setup, so we are in Linux-Land. There seem to be ports of the import ddrescue library, but I cannot make any statement about comparable software for Windows.
- Host PC: Beelink SER-series Mini-PC (`x86_64`, internal NVMe SSD capable of ~700 MB/s sequential I/O during remuxing)
- OS: Linux Mint 22.x (Ubuntu 24.04 LTS base, `gcc 13.2.0`)
- Optical Drive: LG [c]HL-DT-ST BD-RE BU40N[/c] (Firmware `1.00` — ultra-slim 9.5mm Blu-ray/UHD drive)
- USB-to-SATA Enclosure Bridge: Initio Corporation [c]13fd:0840[/c] (`bcdDevice 1.14`, operating over `usb-storage` / `/dev/sr0`)
- Powered USB Hub: TP-Link UH700 7-Port USB 3.0 Hub (12V / 2.5A = 30W external power adapter), plugged specifically into one of the hub's three 1.5A BC 1.2 high-current ports.
MakeMKV must be installed natively (not inside a sandboxed Flatpak/Snap) so its shared library [c]libmmbd.so.0[/c] is accessible in [c]/usr/lib/x86_64-linux-gnu/[/c]. On Linux, the native MakeMKV is preferred by me over the Flatpak version as I had other permission difficulties with that, but I never bothered to actually look into how to use the flatpak version.
Code: Select all
sudo apt update && sudo apt install gddrescue ffmpeg libbluray2 mkvtoolnix mkvtoolnix-gui -y
- MakeMKV (`v2.0.0`): Performs the initial AACS drive handshake, generates `discatt.dat` (volume keys), and provides `libmmbd.so.0`.
- GNU ddrescue (`v1.27`): Forensic block-level imaging tool (`ddrescue`). Reads `/dev/sr0` in 2048-byte sectors, jumps over unreadable sectors (`-n`), trims damage boundaries, and logs progress in a mapfile.
- libmmbd.so.0 + libbluray2: Routes `libbluray` AACS/BD+ decryption calls through MakeMKV's decryption engine.
- FFmpeg (`v6.1.1`) & MKVToolNix (`mkvmerge v82.0`): Demuxes/copies raw streams around the damaged sectors and stitches the clean segments into the final `.mkv`.
2. Phase 1: Diagnosing & Fixing "Posix error - No such device"
Initially, ripping the disc at 5x speed failed partway through `/BDMV/STREAM/00006.m2ts` (around byte offset `17583046656`) with:
Code: Select all
Error 'Posix error - No such device' occurred while reading '/dev/sr0' at offset '17583046656'
Code: Select all
[sr0] Sense Key : Medium Error [current]
[sr0] Add. Sense: L-EC uncorrectable error
critical medium error, dev sr0, sector 46567804
...
usb 1-3.2: USB disconnect, device number 4
device offline error, dev sr0, sector 46564480
usb 1-3.2: new high-speed USB device number 17 using xhci_hcd
usb 1-3.2: New USB device found, idVendor=13fd, idProduct=0840
sr 4:0:0:0: Power-on or device reset occurred
sr 4:0:0:0: Attached scsi CD-ROM sr1
At `sector 46567804` (~23.8 GB physical offset, right at the outer rim / layer transition of a BD-50), a 5x CAV drive is spinning at maximum RPM. When the LG `BU40N` hits a bad sector (`L-EC uncorrectable error`), it slams the spindle brakes and fires its focus/tracking coils at maximum current (>1.1A) while stalling the SATA bus for several seconds to retry. This causes the enclosure's Initio `13fd:0840` USB bridge chip to brown out or trip its watchdog timer. When it reboots 1 second later, MakeMKV still holds `/dev/sr0` open, so the Linux kernel assigns the reconnected drive to `/dev/sr1`, stranding MakeMKV.
Stabilizing the Hardware Layer:
- Clean the disc radially: Wash with warm water and mild dish soap, wiping straight from center hub to outer edge (never in circles). So this tip stays, it is really helpful.
- Use a 1.5A High-Current USB Port: Moved the drive to a dedicated 1.5A port on the powered TP-Link UH700 hub. This seems to be true for power-efficient mini-pcs like my Beelink. Probably on proper desktops you can skip this.
- Disable Linux USB Autosuspend permanently: Added [c]usbcore.autosuspend=-1[/c] to `GRUB_CMDLINE_LINUX_DEFAULT` in `/etc/default/grub` (`sudo update-grub`), and applied immediately for the current session:
Disabling autosuspend is helpful because the Linux Kernel might register the optical drive as idle when in fact it is simply stalled. In that situation the drive would be suspended and then reregistered under a different name (/dev/sr0 -> /dev/sr1). This causes a failure situation, which is often accompanied by POSIX errors like these.
Code: Select all
echo -1 | sudo tee /sys/module/usbcore/parameters/autosuspendCode: Select all
Error 'Posix error - No such device' occurred while reading '/dev/sr0' at offset '17583046656' - Increase Linux SCSI Timeout from 30s to 60s:
Code: Select all
echo 60 | sudo tee /sys/block/sr0/device/timeout - Cap Drive Speed to 2x in `~/.MakeMKV/settings.conf`:
With MakeMKV closed, edited `~/.MakeMKV/settings.conf` to cap the `BU40N` at `2x` speed, preventing high-RPM braking spikes and giving the laser 2.5x longer dwell time over marginal pits:Code: Select all
speed_BD-RE_HL-DT-ST_BD-RE_BU40N_1.00_MO3P8TJ3935 = "2" speed_HL-DT-ST_BD-RE_BU40N_1.00_211612201528_MO3P8TJ3935 = "2"
---
3. Phase 2: Why Hardlinking MakeMKV's Output Only Saves Half the Movie
If you try to save MakeMKV's work before it deletes the file upon failure:
- In Standard MKV Rip Mode: MakeMKV writes the Matroska (`EBML`) header and `Cues` index only at the very end of the rip. A hardlinked `.mkv` from an aborted rip has zeroed headers and is unplayable.
- In Decrypted Backup Mode: MakeMKV writes valid `.m2ts` transport stream files from byte 0. Hardlinking `BDMV/STREAM/00006.m2ts` mid-backup (`ln 00006.m2ts movie.m2ts`) before MakeMKV fails gives a valid video file—but only up to the bad sector (01:01:55). MakeMKV has no option to skip over a bad sector and continue reading the remaining minutes of the disc.
---
4. Phase 3: Forensic Block Imaging with GNU ddrescue
To rescue the second half of the movie after the damaged sector, we decoupled reading the physical disc from MakeMKV using GNU ddrescue.
Using `-b 2048` (optical sector size) and `-n` (`--no-scrape` on Pass 1), `ddrescue` reads all healthy sectors quickly, leaps over the damaged area when the drive slows down to 1x safe mode, and then trims the damaged gap from both directions:
Code: Select all
sudo ddrescue -b 2048 -n /dev/sr0 /home/User_1/Videos/disc_rescue.iso /home/User_1/Videos/rescue.log
sudo chown $USER:$USER /home/User_1/Videos/disc_rescue.iso
Code: Select all
# pos size status
0x00000000 0x58D230000 +
0x58D230000 0x00000800 -
0x58D230800 0x574BCF800 +
---
5. Phase 4: Overcoming AACS Encryption on a Rescued ISO (`discatt.dat`)
Because `ddrescue` copies raw sectors from `/dev/sr0`, the `.m2ts` streams inside `disc_rescue.iso` are still AACS-encrypted, and an `.iso` file lacks the physical Blu-ray ROM Mark needed for an AACS drive handshake.
How to give MakeMKV the keys for a rescued ISO:
- Put the physical Blu-ray in the drive again (if you ever took it out in the first place), open MakeMKV, and click the Backup icon.
- UNCHECK "Decrypt video files" and start the backup. (When "Decrypt video files" is unchecked, MakeMKV immediately writes the AACS volume/disc data into [c]discatt.dat[/c] in the root of the backup folder within the first few seconds!).
- Once `discatt.dat` is created, stop the backup and eject the physical disc.
- Loop-mount `disc_rescue.iso` and create a virtual disc directory that pairs the ISO contents with `discatt.dat`:
Code: Select all
mkdir -p /home/User_1/Videos/iso_mount /home/User_1/Videos/virtual_disc
sudo mount -o loop /home/User_1/Videos/disc_rescue.iso /home/User_1/Videos/iso_mount
ln -s /home/User_1/Videos/iso_mount/* /home/User_1/Videos/virtual_disc/
cp /home/User_1/Videos/backup/OUTRAGE_BD/discatt.dat /home/User_1/Videos/virtual_disc/discatt.dat
Why MakeMKV Still Aborted at 700 MB/s (`HashCheck Error`):
When MakeMKV reached offset `17586683904` inside `virtual_disc`, it aborted with:
Code: Select all
The source file '/BDMV/STREAM/00006.m2ts' is corrupt or invalid at offset 17586683904, attempting to work around
Too many AV synchronization issues in file '/BDMV/STREAM/00006.m2ts'
Encountered 326 errors of type 'HashCheck Error'
0 titles saved, 1 failed
---
6. Phase 5: Extracting & Stitching Around the Damage via `libmmbd` + `FFmpeg` + `mkvmerge`
To use MakeMKV's decryption engine without MakeMKV's muxer aborting on the zeroed sector, we symlinked MakeMKV's `libmmbd.so.0` to `libaacs.so.0` and `libbdplus.so.0`:
So this is the fun part. We have MakeMKV, the decryption engine and MakeMKV, the archival muxer. Usually they work hand in hand, but here we replace the muxer by ffmpeg and libbluray. But for this step, the discatt.dat is important to have, without it we could not decrypt the data in the virtual disc.
Code: Select all
sudo ln -sf /usr/lib/x86_64-linux-gnu/libmmbd.so.0 /usr/lib/x86_64-linux-gnu/libaacs.so.0
sudo ln -sf /usr/lib/x86_64-linux-gnu/libmmbd.so.0 /usr/lib/x86_64-linux-gnu/libbdplus.so.0
Step 1: Extract Part 1 (00:00:00 up to the damaged sector at 01:01:55)
We output to `.m2ts` first because FFmpeg's Matroska muxer aborts if a corrupted packet loses its timestamp (`Can't write packet with unknown timestamp`), whereas the `mpegts` muxer cleanly writes every valid packet right up until `libbluray`'s filter stops at the zeroed sync byte:
Code: Select all
ffmpeg -err_detect ignore_err -fflags +genpts+igndts+discardcorrupt \
-i bluray:/home/User_1/Videos/virtual_disc \
-map 0:v -map 0:a -c copy /home/User_1/Videos/ClassicMovie_rescued.m2ts
Step 2: Seek Past the Layer-Break Damage and Extract Part 2 (01:03:15 to 01:49:13)
Using `ffmpeg -ss` before `-i bluray:...` uses the Blu-ray playlist (`00004.mpls`) seek table to jump directly to a clean byte offset after the damaged layer transition, copying the remaining 46 minutes of the movie at ~50x speed:
Code: Select all
ffmpeg -ss 01:03:15 -i bluray:/home/User_1/Videos/virtual_disc \
-map 0:0 -map 0:1 -map 0:2 -c copy /home/User_1/Videos/ClassicMovie_part2.m2ts
Because a raw byte seek into a `DTS-HD Master Audio` stream can land between a DTS 5.1 core frame and its lossless residual extension (`[dca] Residual encoded channels are present without core`), `mkvmerge` will initially reject appending Part 2 (`The number of channels of the two audio tracks is different: 0 and 5`).
Trimming the first `0.2` seconds off Part 2 (`-ss 0.2`) aligns the start of Part 2 onto a clean 5.1 DTS-HD core header so `mkvmerge` can stitch Part 1 and Part 2 seamlessly:
Code: Select all
Here we could use a video editor to stitch part 1 and 2 together, but then we'd have to re-encode and render. Of course MKVToolNix GUI could do the stitching as well, but here we stay in the terminal.
# 1. Remux Part 1 into a clean MKV
mkvmerge -o /home/User_1/Videos/part1_clean.mkv /home/User_1/Videos/ClassicMovie_rescued.m2ts
# 2. Trim the split 0.2s boundary audio packet from Part 2 and remux to MKV
ffmpeg -ss 0.2 -i /home/User_1/Videos/ClassicMovie_part2.m2ts -map 0 -c copy /home/User_1/Videos/part2_clean.mkv
# 3. Concatenate Part 1 + Part 2 into the final movie
mkvmerge -o /home/User_1/Videos/ClassicMovie_complete.mkv /home/User_1/Videos/part1_clean.mkv + /home/User_1/Videos/part2_clean.mkv
Code: Select all
sudo umount /home/User_1/Videos/iso_mount
rm -rf /home/User_1/Videos/iso_mount /home/User_1/Videos/virtual_disc /home/User_1/Videos/disc_rescue.iso