Exctract blue-ray vi­deo stre­ams from ISO file un­der Li­nux (Ubuntu)

To be able to en­code blue-ray (BD) source into some more uni­ver­sal for­mat, you have to first have ac­cess to sin­gle video/audio stre­ams that com­prise the BD. These are vi­deo fi­les with ex­tension .m2ts in­side which is an Advan­ced Vi­deo Co­dec (High@L4.1) vi­deo and PCM au­dio. For now, this ar­ticle will skip the sub­tit­les be­cause I currently don’t have a BD with sub­tit­les on my disk. These fi­les are nor­mally pla­ya­ble in a pla­yer like MPV.

Little war­ning ahead: some pe­o­ple on fo­rums claim following me­thod didn’t work for them. This mi­ght be be­cause of some DRM pro­tection, mi­ght not, I don’t know. The me­thod wor­ked for me, when I’ll come upon a BD for which it doesn’t, I’ll try to find ano­ther way and up­date this ar­ticle.

To get to stre­ams, you need to mount the ISO into a fol­der. Af­ter that, it’ll be nor­mally ac­ces­si­ble as a fol­der. To do that, follow these steps (and always read do­cu­men­tation of the com­mands be­fore you execute them!):

Let’s say, your di­rec­tory lo­oks like this:

edison23@myComputer:~/home/encoding$ ls

Cre­ate a new di­rec­tory un­der root pri­vi­le­ges and mount the ISO into that di­rec­tory:

edison23@myComputer:~/home/encoding$ sudo mkdir my-bd-iso
edison23@myComputer:~/home/encoding$ sudo mount -o loop my-blueray.iso my-bd-iso
mount: /dev/loop1 is write-protected, mounting read-only

If that suc­ce­e­ded, you can copy the fi­les out of the fol­der (you don’t have to), view them and en­code them. The structure of the BD may be sli­ghtly di­f­fe­rent, but you’ll find the vi­deo stre­ams in so­me­thing like this:

edison23@myComputer:~/home/encoding$ 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

All of them should have su­f­fi­ci­ent per­mis­si­ons for you to read them (you can’t write into them), so now you can use for exam­ple ffm­peg to en­code them into so­me­thing smaller and more usa­ble. For exam­ple:

edison23@myComputer:~/home/encoding$ 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

Leave a Reply

Your email address will not be published. Required fields are marked *