22 декабря 2011 г.

Копирование защищённых DVD в Linux


Дано: диск с защитой от копирования с хорошим фильмом на борту, который нужно конвертировать в .mkv файл, чтобы смотреть кино без лишних проблем где-угодно.

Ресурс: ОС Linux, диск, дисковод внешний Самсунг

Делаем:

Ставим из репозиториев пакет libdvdread4

Заходим в /usr/share/doc/libdvdread4 и даём команду:

sudo ./install-css.sh

что притянет необходимые нам пакеты. Казалось бы, должно работать, ан нет:

user# dd if=/dev/cdrom of=dvd.iso
67200+0 записей считано
67200+0 записей написано
скопировано 34406400 байт (34 MB), 10,645 c, 3,2 MB/c


Я попробовал скопировать с помощью Brasero, который и подсказал ответ:


надо установить пакет regionset:

user# sudo apt-get install regionset

Читаем про него в /usr/share/doc/regionset/README:

regionset -- reads/sets the region code of DVD drives
-----------------------------------------------------
regionset allows you to check and set the region code of DVD drives.
What the hell are region codes?
===============================
Video DVDs contain most often a region code flag indicating the geographical region where the DVD was published (enabling the film industry to control the distribution). There are eight region codes possible, currently six are used:
1 North America (USA and Canada)
2 Europe, Middle East, South Africa and Japan
3 Southeast Asia, Taiwan, Korea
4 Latin America, Australia, New Zealand
5 Former Soviet Union (Russia, Ukraine, etc.), rest of Africa, India
6 China

On delivery, most DVD drives have no region code set. The drive firmware allows yu to change the region code, but on nearly all drives you are limited to five (5) changes. After the fifth change, the DVD drive will stay fixed on that code -- on some drives you can upgrade the drive firmware and have then additional five changes, on other drives you won't be able to change the region code any more.

There are a couple of region code free DVDs on the market, but some drives will deny playing them without setting a region code for the drive first. After setting the region code, the drive will refuse playing any Video DVD (perhaps also Audio DVDs, I never had one to try out) with a different region code than its own.

So if you set a DVD drive to region code 2 (RC2), you'll only be able to play region-code-2-DVDs from Europe, Middle East, South Africa and Japan -- the drive will definitively not play any US or Canadian DVD, nor Austrailian or Chinese. So if you cannot play a DVD because of the wrong region code, there is nothing the DVD player software can do about but changing the region code of the drive if you have any changes left.

So always be very very careful changing the region code, it could be your last try before you're forced to buy a new drive (or play foreign DVDs forever).

Installation
============
Just unpack the package (you probably already did if you can read this file), then call "make". After compiling, you'll find the binary "regionset" in the directory which you should copy to /usr/sbin (as root, of course)

How to use the programm
=======================
You need write access to the DVD drive, either by group or by being root. The more, there absolutely definitively and in any case *must* be a readable Data CD or Data/Video DVD in the drive -- it does not matter if it's your favourite Windows CD, a video or a DVD with your last backup.

By default, regionset will use /dev/dvd to find your DVD drive. You can adjust this by entering the path to the DVD device as first command line parameter (please absolute path!).

If everything goes well, regionset will show you the current region code of the drive, how often it has been changed and how many changes are left. If there are any changes left, it asks for the new region code (see table above). After confirmation, the new region code will be set -- if you enter the same region code as the current one of the drive or just break the programm, regionset will just exit without setting the new code. On successful change of the region code, you'll get a confirmation.

The Credits
===========
regioncode.c was written by Christian Wolff <scarabaeus@convergence.de> of Convergence and published as part of the package dvd_disc_20000215.tar.gz on the Convergence homepage. Due to changes of the german copyright law, the package was removed because it had some relations to CSS and copying DVDs.

There were no mirrors (at least none I could find), so I decided to pack regionset.c and a CSS free version of the UDF functions together and redistribute it. Oh, I added some outputs, nothing to speak of, and rated the whole thing as version 0.1. I plan to add some command line arguments to make regionset more scripting-friendly in later versions.

Hope you find the tool useful,
Sincerely,
Mirko D�lle <cooper@linvdr.org>


Проблема у меня была в том, что вообще не был установлен регион дисковода, мне нужен регион 5 (Former Soviet Union (Russia, Ukraine, etc.), rest of Africa, India). Менять регион пользователю можно всего 5 раз, так что будьте аккуратны. Меняем регион:

user# regionset /dev/sr1
regionset version 0.1 -- reads/sets region code on DVD drives
Current Region Code settings:
RPC Phase: II
type: NONE
vendor resets available: 4
user controlled changes resets available: 5
drive plays discs from region(s):, mask=0xFF
Would you like to change the region setting of your drive? [y/n]:y
Enter the new region number for your drive [1..8]:5
New mask: 0xFFFFFFEF, correct? [y/n]:y
Region code set successfully!


После этих операций будет (нужное подчеркнул):

user# regionset /dev/sr1
...
vendor resets available: 4
user controlled changes resets available: 4
drive plays discs from region(s): 5, mask=0xEF


Теперь можно копировать диск. Рабочий алгоритм такой:
1. создаём iso образ DVD диска с помощью Brasero (этот образ можно невозбранно прожигать на болванку и получать рабочий диск с фильмом). Либо, в моём случае:
2. разархивируем образ в нужный каталог
3. конвертируем содержимое каталога VIDEO_TS в нужный формат с помощью Handbrake