个人工具

UbuntuHelp:BackupDVD/zh

来自Ubuntu中文

跳转至: 导航, 搜索


如何备份DVD

如果你恰好有几张DVD要备份,那么这篇文章正适合你。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. 尽管不是最简单的,但这篇文章甚至应该可以成功备份市面划伤最严重的DVD。如果有更简单的工具可以做到这些,那就用它们。如果那些工具做不到,试试下面的技巧。 {i} 这一过程将不会备份选单(DVD开始前的选单),只会备份主要的章节。我们将会用到 tcrequant (transcode package), mplex (mjpegtools package), dvdauthor (dvdauthor package)和mplayer (mplayer package)。如果你没有这些工具,使用下面的命令安装:

sudo apt-get install transcode mplayer dvdauthor mjpegtools

Dump the DVD Main Title to Individual Files

现在有无数篇的指导你如何备份DVD的文章,而这篇文章将使用一种经过证明可以有效处理各种棘手DVD的技巧。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 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:

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 -ns -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

将视频瘦身到DVD5的大小

由于并未完全重新编码数据流,所以这一过程将非常快。

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

{i} 此处的 -f 1.5 是压缩率,对于大多数DVD来说,这个值很好猜出来。如果你需要非常精确的数值或者想充分利用磁盘空间,请使用以下公式计算合适的大小。

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

将新的视频和旧的音频合并

这一步也很简单。

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

{i} 此处的 -f 8 告诉mplex编码器建立一个适合DVD格式的视频流。 如果上述的命令一切正常,你甚至可能从一开始就不需要这份指导。用播放器测试一下你的音频,看看他是否能和最终的输出文件同步。如果不同步,你可以通过在上面的命令后加一个 -O 选项来修正音频的偏移。如果,也有可能,你得到了一些关于"%d不在文件名内(%d not in the filename)"的错误,那么请继续往下看...

损坏的DVD

通常大多是用户在看到上面的错误后会受到挫折并开始疯狂地在Google上搜索。 无论如何请坚持你的信念,下面的方法应该可以解决你的问题! 尽管不是很好,但它甚至能将最顽固的DVD备份到那里。

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.

删除空白的MPG文件

现在,噩梦开始了。当mplex编码完成後,你需要浏览每个最终输出的#.mpg文件。通常其中会有许多非常小的空白mpg文件。用媒体播放器打开他们来确认是否为空白文件。你要找出主要的文件,并将他们标记出来,然後删除剩下的文件。 {注} 由于我们现在正在处理一个复杂(可能还有版权保护)的DVD,我们的音频可能完全不同步。现在先暂时忽视它。

再次分离视频流

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:

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

{i} 上面的命令假设你已把输出的m2v文件重命名为file1, file2和file3。这里的所有文件需按顺序存放。

再次合并视频和音频

和先前的步骤一样:

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

呃! 要做的事真多不是么? 总结一下我们所做的事:

  • 从主要章节中分离音视频和音频到硬盘。
  • 将视频压缩到DVD5格式光盘的大小。
  • 由于某些问题,将音频和视频合并到复合文件中。
  • 再次从主要章节的mpeg文件中分离视频,并删除那些有问题的空白。
  • 再次合并音频和分离後的视频。

建立DVD结构

现在,我们将使用Dvdauthor在文件夹里建立正确的DVD结构。

制作配置文件

首先,我们要为Dvdauthor制作一个配置文件。把以下代码复制到你最喜欢的文本编辑器里,并按照输出结果更改其中的mpge文件名:

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

将文件保存为dvdauthor.xml

自动建立DVD结构

很好的自动生成代码:

dvdauthor -o dvddirectory -x dvdauthor.xml

现在,在你先前使用的DVD文件夹下面应该已经有正确的DVD结构了。

生成ISO镜像并刻录

下面的命令将使用上述的目录并在刻录前为你生成一个ISO镜像以便储存和测试。希望一切顺利...

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

喔。很长的过程。即使是损坏最严重的DVD也应该能够输出到那个目录。

不生成ISO镜像直接刻录

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