edison23

Zápisky šíleného jazykového editora

Exctract blue-ray video streams from ISO file under Linux (Ubuntu)

Datum: 2018-05-01
Kategorie: Guides EN

To be able to encode blue-ray (BD) source into some more universal format, you have to first have access to single video/audio streams that comprise the BD. These are video files with extension .m2ts inside which is an Advanced Video Codec (High@L4.1) video and PCM audio. For now, this article will skip the subtitles because I currently don’t have a BD with subtitles on my disk. These files are normally playable in a player like MPV.

Little warning ahead: some people on forums claim following method didn’t work for them. This might be because of some DRM protection, might not, I don’t know. The method worked for me, when I’ll come upon a BD for which it doesn’t, I’ll try to find another way and update this article.

To get to streams, you need to mount the ISO into a folder. After that, it’ll be normally accessible as a folder. To do that, follow these steps (and always read documentation of the commands before you execute them!):

Let’s say, your directory looks like this:

$ ls
my-bluray.iso

Create a new directory under root privileges and mount the ISO into that directory:

$ sudo mkdir my-bd-iso
$ sudo mount -o loop my-blueray.iso my-bd-iso
mount: /dev/loop1 is write-protected, mounting read-only
$ 

If that succeeded, you can copy the files out of the folder (you don’t have to), view them and encode them. The structure of the BD may be slightly different, but you’ll find the video streams in something like this:

$ ls my-bd-iso/BDMV/STREAMS/
-r-xr-xr-x 1 nobody nogroup  318590976 Apr 27  2017 00000.m2ts
-r-xr-xr-x 1 nobody nogroup 5898645504 Apr 27  2017 00001.m2ts
-r-xr-xr-x 1 nobody nogroup 5639411712 Apr 27  2017 00002.m2ts
-r-xr-xr-x 1 nobody nogroup 5912027136 Apr 27  2017 00003.m2ts
-r-xr-xr-x 1 nobody nogroup 5522374656 Apr 27  2017 00004.m2ts
edison23@myComputer:~/home/encoding$

All of them should have sufficient permissions for you to read them (you can’t write into them), so now you can use for example ffmpeg to encode them into something smaller and more usable. For example:

$ ffmpeg -i my-bd-iso/BDMV/STREAM/00001.m2ts -map 0:v:0 -map 0:a:0 -c:a aac -strict -2 -b:a 320k -ac 2 -c:v libx264 -preset veryslow -crf 18 my-blueray-encoded-01.mkv