个人工具

“UbuntuHelp:BackupDVD”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/BackupDVD}} {{Languages|UbuntuHelp:BackupDVD}} == How to Backup a DVD == If you happen to own a number of DVDs and wish to back them up, this art...)
 
 
(未显示同一用户的5个中间版本)
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/BackupDVD}}
 
{{From|https://help.ubuntu.com/community/BackupDVD}}
 
{{Languages|UbuntuHelp:BackupDVD}}
 
{{Languages|UbuntuHelp:BackupDVD}}
 
 
== How to Backup a DVD ==
 
== How to Backup a DVD ==
 
If you happen to own a number of DVDs and wish to back them up, this article is for you.  It has been constructed to aid the casual user with overcoming some of the tricky DVD issues that might crop up during fair-use archiving.  This article specifically tries to tackle double layer DVD to single layer DVD (DVD9 to DVD5 formats).  Why yet another article for DVD9 to DVD5 copying?  As you will surely find out, some DVDs resist the scripts that are out there to do this.  Although not streamlined, this article '''should''' successfully backup even the most tightly wound up DVDs on the market.  If the easier tools work, use them.  If they don't, try the following technique.
 
If you happen to own a number of DVDs and wish to back them up, this article is for you.  It has been constructed to aid the casual user with overcoming some of the tricky DVD issues that might crop up during fair-use archiving.  This article specifically tries to tackle double layer DVD to single layer DVD (DVD9 to DVD5 formats).  Why yet another article for DVD9 to DVD5 copying?  As you will surely find out, some DVDs resist the scripts that are out there to do this.  Although not streamlined, this article '''should''' successfully backup even the most tightly wound up DVDs on the market.  If the easier tools work, use them.  If they don't, try the following technique.
 
 
{i} ''This process will not backup the menus, only the primary title.''
 
{i} ''This process will not backup the menus, only the primary title.''
 
 
We will require tcrequant (transcode package), mplex (mjpegtools package), dvdauthor (dvdauthor package), and mplayer (mplayer package) to successfully do this.  If you don't have these tools add them via:
 
We will require tcrequant (transcode package), mplex (mjpegtools package), dvdauthor (dvdauthor package), and mplayer (mplayer package) to successfully do this.  If you don't have these tools add them via:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install transcode mplayer dvdauthor mjpegtools
 
sudo apt-get install transcode mplayer dvdauthor mjpegtools
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Dump the DVD Main Title to Individual Files ===
 
=== Dump the DVD Main Title to Individual Files ===
 
While there are numerous guides out there to deal with archiving a DVD, this one will use a tried and true technique which deals with all sorts of troublesome DVDs.  These issues might include split timecodes and a plethora of other little dittys that will get in your way.
 
While there are numerous guides out there to deal with archiving a DVD, this one will use a tried and true technique which deals with all sorts of troublesome DVDs.  These issues might include split timecodes and a plethora of other little dittys that will get in your way.
 
 
First, use a DVD player to locate the exact title location of our primary title.  In the following example, we have deduced that the primary title is located at the sixteenth location.
 
First, use a DVD player to locate the exact title location of our primary title.  In the following example, we have deduced that the primary title is located at the sixteenth location.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
mplayer -dumpaudio -dumpfile output.ac3 dvd://16
 
mplayer -dumpaudio -dumpfile output.ac3 dvd://16
 
mplayer -dumpvideo -dumpfile output.m2v dvd://16
 
mplayer -dumpvideo -dumpfile output.m2v dvd://16
 
</nowiki></pre>
 
</nowiki></pre>
 
 
This will strip the main title into two separate files -- namely output.ac3 (the audio) and output.m2v (the video).  
 
This will strip the main title into two separate files -- namely output.ac3 (the audio) and output.m2v (the video).  
 
+
{i} ''If the wrong audio track is offered, force mplayer to use the correct one by providing the -aid <AUDIO TRACK> parameter with the proper audio track number. The correct audio track can be identified by using mplayer -v which lists available audio tracks. These are not necessarily numbered sequentially.''
{i} ''If the wrong audio track is offered, force mplayer to use the correct one buy providing the -aid <AUDIO TRACK> parameter with the proper audio track number. The correct audio track can be identified by using mplayer -v which lists available audio tracks. These are not necessarily numbered sequentially.''
+
 
+
 
Note that some protected dvds require dvdnav to read them correctly, which is not compiled in by default in the ubuntu package. To compile a deb do:
 
Note that some protected dvds require dvdnav to read them correctly, which is not compiled in by default in the ubuntu package. To compile a deb do:
 
<pre><nowiki>
 
<pre><nowiki>
第35行: 第26行:
 
... now edit debian/rules adding the flag --enable-dvdnav to one of the environment variables with the configure flags...
 
... now edit debian/rules adding the flag --enable-dvdnav to one of the environment variables with the configure flags...
 
<pre><nowiki>
 
<pre><nowiki>
dpkg-buildpackage -ns -uc
+
dpkg-buildpackage -sn -uc
 
cd ..
 
cd ..
 
sudo apt-get install mplayer*.deb mencoder*.deb
 
sudo apt-get install mplayer*.deb mencoder*.deb
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Now use:
 
Now use:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
mplayer -dumpaudio -dumpfile output.ac3 dvdnav://16
 
mplayer -dumpaudio -dumpfile output.ac3 dvdnav://16
 
mplayer -dumpvideo -dumpfile output.m2v dvdnav://16
 
mplayer -dumpvideo -dumpfile output.m2v dvdnav://16
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
=== Requantize the Video to DVD5 Size ===
 
=== Requantize the Video to DVD5 Size ===
 
This is quite fast as we are not completely re-encoding the stream.
 
This is quite fast as we are not completely re-encoding the stream.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
tcrequant -i output.m2v -o output_shrunk.m2v -f 1.5
 
tcrequant -i output.m2v -o output_shrunk.m2v -f 1.5
 
</nowiki></pre>
 
</nowiki></pre>
 
 
{i} ''The -f 1.5 here is the shrinkage factor, and is a pretty good guess for most DVDs.  If you are very particular and want to maximize the disk use use the following formula to calculate the proper value.''
 
{i} ''The -f 1.5 here is the shrinkage factor, and is a pretty good guess for most DVDs.  If you are very particular and want to maximize the disk use use the following formula to calculate the proper value.''
 
 
<pre><nowiki>
 
<pre><nowiki>
 
FACTOR = (TOTAL_M2V_VIDEO_SIZE / (4700000000 - TOTAL_AC3_FILE_SIZE)) * 1.04
 
FACTOR = (TOTAL_M2V_VIDEO_SIZE / (4700000000 - TOTAL_AC3_FILE_SIZE)) * 1.04
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Combine the New Video with the Old Audio ===
 
=== Combine the New Video with the Old Audio ===
 
Again, quite simple.
 
Again, quite simple.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
mplex -f 8 -o final_output.mpg output_shrunk.m2v output.ac3
 
mplex -f 8 -o final_output.mpg output_shrunk.m2v output.ac3
 
</nowiki></pre>
 
</nowiki></pre>
 
 
{i} ''The -f 8 here tells mplex to create a compliant DVD format stream.''
 
{i} ''The -f 8 here tells mplex to create a compliant DVD format stream.''
 
 
If the above command works flawlessly, you probably didn't even need this guide in the first place.  Test your audio sync in a player and see if it worked on the final output file.  If the sync is out, you can adjust it by executing the above line with a ''-O'' option to offset the audio.   
 
If the above command works flawlessly, you probably didn't even need this guide in the first place.  Test your audio sync in a player and see if it worked on the final output file.  If the sync is out, you can adjust it by executing the above line with a ''-O'' option to offset the audio.   
 
 
If, on the other hand, you get some error about %d not in the filename, read on...
 
If, on the other hand, you get some error about %d not in the filename, read on...
 
 
==== Nasty DVDs ====
 
==== Nasty DVDs ====
 
Usually most users end up getting frustrated at the above error and start Googling their way into insanity.  Have faith however, the following '''should''' solve your problem!  Although it isn't pretty, it will backup even the most stubborn DVDs out there.
 
Usually most users end up getting frustrated at the above error and start Googling their way into insanity.  Have faith however, the following '''should''' solve your problem!  Although it isn't pretty, it will backup even the most stubborn DVDs out there.
 
 
===== Output to Multiple Files =====
 
===== Output to Multiple Files =====
 
Let's fix the above command so it will crank out several files.  You might want to do this in a new directory as it may poop out ''many'' mpgs.
 
Let's fix the above command so it will crank out several files.  You might want to do this in a new directory as it may poop out ''many'' mpgs.
第82行: 第59行:
 
mplex -f 8 -o final_output%d.mpg output_shrunk.m2v output.ac3
 
mplex -f 8 -o final_output%d.mpg output_shrunk.m2v output.ac3
 
</nowiki></pre>
 
</nowiki></pre>
 
 
{i} ''The %d here tells mplex that it is now free to crank out as many split files as required by the video file.''
 
{i} ''The %d here tells mplex that it is now free to crank out as many split files as required by the video file.''
 
 
====== Remove Blank MPGs ======
 
====== Remove Blank MPGs ======
 
Here is where the nightmare starts.  Once mplex is finished, you will need to browse through all of your final_output#.mpg files.  Usually there are many that are very small black short mpgs.  Play them in a media player to confirm.  What you are looking for is your primary title files.  Make a note of them all, and discard the rest of the files.
 
Here is where the nightmare starts.  Once mplex is finished, you will need to browse through all of your final_output#.mpg files.  Usually there are many that are very small black short mpgs.  Play them in a media player to confirm.  What you are looking for is your primary title files.  Make a note of them all, and discard the rest of the files.
 
 
{i} ''Because we are now dealing with a tricky (and probably copy protected) DVD, our audio will be completely out of sync.  Ignore this for now.''
 
{i} ''Because we are now dealing with a tricky (and probably copy protected) DVD, our audio will be completely out of sync.  Ignore this for now.''
 
 
===== Strip the Video Stream AGAIN =====
 
===== Strip the Video Stream AGAIN =====
 
So now we have who knows how many mpgs containing our copy protected / tricky / poorly made DVD.  Because mplex tried to sync the sound to the tricky sections that are now gone, we will need to rip our lovely main title out of the mix again.  To do this, simply re-issue the mplayer command to strip the video.  You will need to strip each video stream into individual m2v files.
 
So now we have who knows how many mpgs containing our copy protected / tricky / poorly made DVD.  Because mplex tried to sync the sound to the tricky sections that are now gone, we will need to rip our lovely main title out of the mix again.  To do this, simply re-issue the mplayer command to strip the video.  You will need to strip each video stream into individual m2v files.
第96行: 第69行:
 
mplayer -dumpvideo -dumpfile <OUTPUT_FILENAME_##.m2v> <INPUT_FILENAME##.MPG>
 
mplayer -dumpvideo -dumpfile <OUTPUT_FILENAME_##.m2v> <INPUT_FILENAME##.MPG>
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Now we should have a series of m2v files that contain ''only'' our primary title without all the garbage chunks that were causing grief before.  You can now remove all of the older mpg files.  You will only require the ''newest'' m2v files created above along with the original sound track.
 
Now we should have a series of m2v files that contain ''only'' our primary title without all the garbage chunks that were causing grief before.  You can now remove all of the older mpg files.  You will only require the ''newest'' m2v files created above along with the original sound track.
 
 
===== Concatenate the Video Stream =====
 
===== Concatenate the Video Stream =====
 
Let's make the multiple files one again so we can sync up our singular sound file to the new title:
 
Let's make the multiple files one again so we can sync up our singular sound file to the new title:
第105行: 第76行:
 
</nowiki></pre>
 
</nowiki></pre>
 
{i} ''The above assumes you re-named your output m2v files file1, file2, and file3.  Put whatever your files are here in order.''
 
{i} ''The above assumes you re-named your output m2v files file1, file2, and file3.  Put whatever your files are here in order.''
 
 
===== Combine the Video with Audio AGAIN =====
 
===== Combine the Video with Audio AGAIN =====
 
Same as our earlier step:
 
Same as our earlier step:
第111行: 第81行:
 
mplex -f 8 -o final_output%d.mpg final_title.m2v output.ac3
 
mplex -f 8 -o final_output%d.mpg final_title.m2v output.ac3
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Phew!  That was a lot of work eh?  To summarize what we have done:
 
Phew!  That was a lot of work eh?  To summarize what we have done:
 
* Stripped the video and audio out of our primary title to the hard disk.
 
* Stripped the video and audio out of our primary title to the hard disk.
第118行: 第87行:
 
* Re-stripped the video out of our primary title mpegs and discarded the problematic blanks.
 
* Re-stripped the video out of our primary title mpegs and discarded the problematic blanks.
 
* Re-combined the audio with the newly stripped video.
 
* Re-combined the audio with the newly stripped video.
 
 
=== Make the DVD Structure ===
 
=== Make the DVD Structure ===
 
We will now use dvdauthor to create the proper DVD format in a directory.   
 
We will now use dvdauthor to create the proper DVD format in a directory.   
 
 
==== Generate a Configuration File ====
 
==== Generate a Configuration File ====
 
First, we will need to create a config file for the dvdauthor.  Put the following into your favourite text editor and change the appropriate names of the mpegs to match your output:
 
First, we will need to create a config file for the dvdauthor.  Put the following into your favourite text editor and change the appropriate names of the mpegs to match your output:
 
<pre><nowiki>
 
<pre><nowiki>
 
<dvdauthor>
 
<dvdauthor>
<vmgm />
+
    <vmgm />
<titleset>
+
    <titleset>
<titles>
+
        <titles>
<pgc>
+
            <pgc>
<vob file="final_output1.mpg" chapters="0" />
+
                <vob file="final_output1.mpg" chapters="0" />
<vob file="final_output2.mpg" />
+
                <vob file="final_output2.mpg" />
</pgc>
+
            </pgc>
</titles>
+
        </titles>
</titleset>
+
    </titleset>
 
</dvdauthor>
 
</dvdauthor>
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Save the file as '''dvdauthor.xml'''
 
Save the file as '''dvdauthor.xml'''
 
 
==== Make the DVD Structure Itself ====
 
==== Make the DVD Structure Itself ====
 
Pretty self explanatory:
 
Pretty self explanatory:
第145行: 第110行:
 
dvdauthor -o dvddirectory -x dvdauthor.xml
 
dvdauthor -o dvddirectory -x dvdauthor.xml
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Now you should have a proper DVD structure in your good old dvddirectory below where you have been working.
 
Now you should have a proper DVD structure in your good old dvddirectory below where you have been working.
 
 
=== Make the ISO and Burn It ===
 
=== Make the ISO and Burn It ===
 
The following command will take the above directory and make an ISO image for you to mount and test before burning.  Hope all went well...
 
The following command will take the above directory and make an ISO image for you to mount and test before burning.  Hope all went well...
第153行: 第116行:
 
mkisofs -dvd-video -o DVD.iso ./dvddirectory/
 
mkisofs -dvd-video -o DVD.iso ./dvddirectory/
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Wow.  Long road.  It should work for even the most nasty DVDs out there.
 
Wow.  Long road.  It should work for even the most nasty DVDs out there.
 
 
=== Burn It without ISO ===
 
=== Burn It without ISO ===
 
<pre><nowiki>
 
<pre><nowiki>
 
growisofs -Z /dev/dvd -dvd-video dvddirectory/
 
growisofs -Z /dev/dvd -dvd-video dvddirectory/
 
</nowiki></pre>
 
</nowiki></pre>
 
+
----
[[category:CategoryDocumentation]]
+
[[category:CategoryBackupRecovery]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 21:39的最新版本


How to Backup a DVD

If you happen to own a number of DVDs and wish to back them up, this article is for you. It has been constructed to aid the casual user with overcoming some of the tricky DVD issues that might crop up during fair-use archiving. This article specifically tries to tackle double layer DVD to single layer DVD (DVD9 to DVD5 formats). Why yet another article for DVD9 to DVD5 copying? As you will surely find out, some DVDs resist the scripts that are out there to do this. Although not streamlined, this article should successfully backup even the most tightly wound up DVDs on the market. If the easier tools work, use them. If they don't, try the following technique. {i} This process will not backup the menus, only the primary title. We will require tcrequant (transcode package), mplex (mjpegtools package), dvdauthor (dvdauthor package), and mplayer (mplayer package) to successfully do this. If you don't have these tools add them via:

sudo apt-get install transcode mplayer dvdauthor mjpegtools

Dump the DVD Main Title to Individual Files

While there are numerous guides out there to deal with archiving a DVD, this one will use a tried and true technique which deals with all sorts of troublesome DVDs. These issues might include split timecodes and a plethora of other little dittys that will get in your way. First, use a DVD player to locate the exact title location of our primary title. In the following example, we have deduced that the primary title is located at the sixteenth location.

mplayer -dumpaudio -dumpfile output.ac3 dvd://16
mplayer -dumpvideo -dumpfile output.m2v dvd://16

This will strip the main title into two separate files -- namely output.ac3 (the audio) and output.m2v (the video). {i} If the wrong audio track is offered, force mplayer to use the correct one by providing the -aid <AUDIO TRACK> parameter with the proper audio track number. The correct audio track can be identified by using mplayer -v which lists available audio tracks. These are not necessarily numbered sequentially. Note that some protected dvds require dvdnav to read them correctly, which is not compiled in by default in the ubuntu package. To compile a deb do:

sudo apt-get build-dep mplayer
sudo apt-get install libdvdnav-dev
apt-get source mplayer
cd mplayer-xxxx

... now edit debian/rules adding the flag --enable-dvdnav to one of the environment variables with the configure flags...

dpkg-buildpackage -sn -uc
cd ..
sudo apt-get install mplayer*.deb mencoder*.deb

Now use:

mplayer -dumpaudio -dumpfile output.ac3 dvdnav://16
mplayer -dumpvideo -dumpfile output.m2v dvdnav://16

Requantize the Video to DVD5 Size

This is quite fast as we are not completely re-encoding the stream.

tcrequant -i output.m2v -o output_shrunk.m2v -f 1.5

{i} The -f 1.5 here is the shrinkage factor, and is a pretty good guess for most DVDs. If you are very particular and want to maximize the disk use use the following formula to calculate the proper value.

FACTOR = (TOTAL_M2V_VIDEO_SIZE / (4700000000 - TOTAL_AC3_FILE_SIZE)) * 1.04

Combine the New Video with the Old Audio

Again, quite simple.

mplex -f 8 -o final_output.mpg output_shrunk.m2v output.ac3

{i} The -f 8 here tells mplex to create a compliant DVD format stream. If the above command works flawlessly, you probably didn't even need this guide in the first place. Test your audio sync in a player and see if it worked on the final output file. If the sync is out, you can adjust it by executing the above line with a -O option to offset the audio. If, on the other hand, you get some error about %d not in the filename, read on...

Nasty DVDs

Usually most users end up getting frustrated at the above error and start Googling their way into insanity. Have faith however, the following should solve your problem! Although it isn't pretty, it will backup even the most stubborn DVDs out there.

Output to Multiple Files

Let's fix the above command so it will crank out several files. You might want to do this in a new directory as it may poop out many mpgs.

mplex -f 8 -o final_output%d.mpg output_shrunk.m2v output.ac3

{i} The %d here tells mplex that it is now free to crank out as many split files as required by the video file.

Remove Blank MPGs

Here is where the nightmare starts. Once mplex is finished, you will need to browse through all of your final_output#.mpg files. Usually there are many that are very small black short mpgs. Play them in a media player to confirm. What you are looking for is your primary title files. Make a note of them all, and discard the rest of the files. {i} Because we are now dealing with a tricky (and probably copy protected) DVD, our audio will be completely out of sync. Ignore this for now.

Strip the Video Stream AGAIN

So now we have who knows how many mpgs containing our copy protected / tricky / poorly made DVD. Because mplex tried to sync the sound to the tricky sections that are now gone, we will need to rip our lovely main title out of the mix again. To do this, simply re-issue the mplayer command to strip the video. You will need to strip each video stream into individual m2v files. {i} If someone knows how to clean this step up, please adjust the wiki accordingly.

mplayer -dumpvideo -dumpfile <OUTPUT_FILENAME_##.m2v> <INPUT_FILENAME##.MPG>

Now we should have a series of m2v files that contain only our primary title without all the garbage chunks that were causing grief before. You can now remove all of the older mpg files. You will only require the newest m2v files created above along with the original sound track.

Concatenate the Video Stream

Let's make the multiple files one again so we can sync up our singular sound file to the new title:

cat file1.m2v file2.m2v file3.m2v > final_title.m2v

{i} The above assumes you re-named your output m2v files file1, file2, and file3. Put whatever your files are here in order.

Combine the Video with Audio AGAIN

Same as our earlier step:

mplex -f 8 -o final_output%d.mpg final_title.m2v output.ac3

Phew! That was a lot of work eh? To summarize what we have done:

  • Stripped the video and audio out of our primary title to the hard disk.
  • Shrunk the video to fit on a DVD5 format disk.
  • Combined the audio and video together into multiple files because of problems.
  • Re-stripped the video out of our primary title mpegs and discarded the problematic blanks.
  • Re-combined the audio with the newly stripped video.

Make the DVD Structure

We will now use dvdauthor to create the proper DVD format in a directory.

Generate a Configuration File

First, we will need to create a config file for the dvdauthor. Put the following into your favourite text editor and change the appropriate names of the mpegs to match your output:

<dvdauthor>
    <vmgm />
    <titleset>
        <titles>
            <pgc>
                <vob file="final_output1.mpg" chapters="0" />
                <vob file="final_output2.mpg" />
            </pgc>
        </titles>
    </titleset>
</dvdauthor>

Save the file as dvdauthor.xml

Make the DVD Structure Itself

Pretty self explanatory:

dvdauthor -o dvddirectory -x dvdauthor.xml

Now you should have a proper DVD structure in your good old dvddirectory below where you have been working.

Make the ISO and Burn It

The following command will take the above directory and make an ISO image for you to mount and test before burning. Hope all went well...

mkisofs -dvd-video -o DVD.iso ./dvddirectory/

Wow. Long road. It should work for even the most nasty DVDs out there.

Burn It without ISO

growisofs -Z /dev/dvd -dvd-video dvddirectory/