This is the procedure I know to convert a DVD image to another videoformat (v.g. MP4):
这是我所知道的将DVD图像转换成另一个视频格式的过程(vg . MP4):
- concatenate the
VTS_01_
n.VOB
files insideVIDEO_TS
folder (for n >= 0) into a single VOB file. - 连接VTS_01_n。在VIDEO_TS文件夹中的VOB文件(对于n >= 0)进入一个VOB文件。
- use
avconv
orffmpeg
in order to convert that VOB into another format. - 使用avconv或ffmpeg来将VOB转换成另一种格式。
So far so good, however now I want to convert the DVD image with the subtitles. As far as I know the MKV format supports subtitles, so it seems an obvious choice. Alternatively I might use any other format with hard subtitles (subtitles as part of the video image).
到目前为止还不错,不过现在我想把DVD图像换成字幕。据我所知MKV格式支持字幕,所以这似乎是一个显而易见的选择。或者,我可以使用任何其他格式的硬字幕(字幕作为视频图像的一部分)。
However, the subtitle encoding in the DVD image is dvdsub
and I get the following error
然而,DVD图像中的字幕编码是dvdsub,我得到了以下错误。
Only SUBTITLE_ASS type supported.
Subtitle encoding failed
However, when running avconv -codecs
I get:
然而,当我运行avconv -codecs时:
...
DES dvdsub DVD subtitles
...
And the -c:s copy
switch, while it prevents the command to fail, it does not seem to produce a subtitle that the player can understand.
而且-c:s复制开关,当它阻止命令失败时,它似乎没有产生玩家可以理解的字幕。
So, how can I create ass
subtitles from dvdsub
using avconv
?
那么,如何使用avconv在dvdsub上创建ass字幕呢?
My VOB file has eight subtitle channels and two audio channels. The Ubuntu video app does not show any subtitles, and only the first audio channel seems to be working, do the DVD image might be broken.
我的VOB文件有八个字幕频道和两个音频频道。Ubuntu视频应用程序没有显示任何字幕,而且只有第一个音频通道似乎在工作,DVD图像可能会被破坏。
Another file, for a double-layer DVD, displays the Subtitle encoding error, however when using the -c:s copy
switch it further displays:
另一个文件,对于双层DVD,显示字幕编码错误,但是当使用-c:s拷贝开关它进一步显示:
Application provided invalid, non monotonically increasing dts to muxer in stream 2: 49 >= 49
av_interleaved_write_frame(): Invalid argument
Thank you in advance for any ideas on how to solve these problems.
感谢您对如何解决这些问题的任何想法。
(I am using Ubuntu where ffmpeg
is an alias for avconv
. I know it is possible to install the real ffmpeg but so far I have not done so.)
(我正在使用Ubuntu, ffmpeg是avconv的别名。我知道安装真正的ffmpeg是可能的,但到目前为止我还没有这样做。
update: commands and console outputs:
更新:命令和控制台输出:
commands
命令
cat VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB VTS_01_4.VOB VTS_01_5.VOB > ~/temp/mymovie.VOB
cd ~/temp
avconv -i mymovie.VOB
output
输出
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[mpeg @ 0x1a64d40] max_analyze_duration reached
Input #0, mpeg, from 'mymovie.VOB':
Duration: 00:00:01.95, start: 0.280633, bitrate: -2147483 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 7500 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x20]: Subtitle: dvdsub
Stream #0.2[0x21]: Subtitle: dvdsub
Stream #0.3[0x22]: Subtitle: dvdsub
Stream #0.4[0x23]: Subtitle: dvdsub
Stream #0.5[0x24]: Subtitle: dvdsub
Stream #0.6[0x25]: Subtitle: dvdsub
Stream #0.7[0x26]: Subtitle: dvdsub
Stream #0.8[0x27]: Subtitle: dvdsub
Stream #0.9[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream #0.10[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
At least one output file must be specified
command
命令
avconv -i mymovie.VOB mymovie.mkv
output
输出
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[mpeg @ 0x1cdad40] max_analyze_duration reached
Input #0, mpeg, from 'mymovie.VOB':
Duration: 00:00:01.95, start: 0.280633, bitrate: -2147483 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 7500 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x20]: Subtitle: dvdsub
Stream #0.2[0x21]: Subtitle: dvdsub
Stream #0.3[0x22]: Subtitle: dvdsub
Stream #0.4[0x23]: Subtitle: dvdsub
Stream #0.5[0x24]: Subtitle: dvdsub
Stream #0.6[0x25]: Subtitle: dvdsub
Stream #0.7[0x26]: Subtitle: dvdsub
Stream #0.8[0x27]: Subtitle: dvdsub
Stream #0.9[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream #0.10[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
File 'mymovie.mkv' already exists. Overwrite ? [y/N] y
[buffer @ 0x1ce23c0] w:720 h:480 pixfmt:yuv420p
Output #0, matroska, to 'mymovie.mkv':
Metadata:
encoder : Lavf53.21.1
Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 29.97 tbc
Stream #0.1: Audio: libvorbis, 48000 Hz, 5.1, s16
Stream #0.2: Subtitle: ass, 200 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
Stream #0:9 -> #0:1 (ac3 -> libvorbis)
Stream #0:1 -> #0:2 (dvdsub -> ass)
Press ctrl-c to stop encoding
[ass @ 0x1ce0140] Only SUBTITLE_ASS type supported.
Subtitle encoding failed
command
命令
avconv -i mymovie.VOB -c:s copy mymovie.mkv
output omitted.
输出省略。
command
命令
avconv -i mymovie.mkv
output
输出
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[matroska,webm @ 0xbc1d40] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from 'mymovie.mkv':
Metadata:
ENCODER : Lavf53.21.1
Duration: 01:05:09.47, start: 0.000000, bitrate: N/A
Stream #0.0: Video: mpeg4 (Simple Profile), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 1k tbn, 30k tbc (default)
Stream #0.1: Audio: vorbis, 48000 Hz, 5.1, s16 (default)
Stream #0.2: Subtitle: dvdsub (default)
At least one output file must be specified
Now, for the double-layer: commands
现在,对于双层:命令。
cat VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB VTS_01_4.VOB VTS_01_5.VOB VTS_01_6.VOB VTS_01_7.VOB VTS_01_8.VOB > ~/temp/mylongmovie.VOB
cd ~/temp
avconv -i mylongmovie.VOB mylongmovie.mkv
output
输出
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[mpeg @ 0x13c2d40] max_analyze_duration reached
Input #0, mpeg, from 'Cosmos-0203.VOB':
Duration: 00:00:30.24, start: 0.280633, bitrate: 2103365 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 8000 kb/s, 27.46 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x20]: Subtitle: dvdsub
Stream #0.2[0x21]: Subtitle: dvdsub
Stream #0.3[0x22]: Subtitle: dvdsub
Stream #0.4[0x23]: Subtitle: dvdsub
Stream #0.5[0x24]: Subtitle: dvdsub
Stream #0.6[0x25]: Subtitle: dvdsub
Stream #0.7[0x26]: Subtitle: dvdsub
Stream #0.8[0x27]: Subtitle: dvdsub
Stream #0.9[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream #0.10[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
File 'mylongmovie.mkv' already exists. Overwrite ? [y/N] y
[buffer @ 0x13ca3c0] w:720 h:480 pixfmt:yuv420p
Output #0, matroska, to 'mylongmovie.mkv':
Metadata:
encoder : Lavf53.21.1
Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 59.94 tbc
Stream #0.1: Audio: libvorbis, 48000 Hz, 5.1, s16
Stream #0.2: Subtitle: ass, 200 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
Stream #0:9 -> #0:1 (ac3 -> libvorbis)
Stream #0:1 -> #0:2 (dvdsub -> ass)
Press ctrl-c to stop encoding
[ass @ 0x13d19c0] Only SUBTITLE_ASS type supported.
Subtitle encoding failed
command
命令
avconv -i mylongmovie.VOB -c:s copy mylongmovie.mkv
output
输出
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
[mpeg @ 0xce1d40] max_analyze_duration reached
Input #0, mpeg, from 'mylongmovie.VOB':
Duration: 00:00:30.24, start: 0.280633, bitrate: 2103365 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 8000 kb/s, 27.46 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream #0.1[0x20]: Subtitle: dvdsub
Stream #0.2[0x21]: Subtitle: dvdsub
Stream #0.3[0x22]: Subtitle: dvdsub
Stream #0.4[0x23]: Subtitle: dvdsub
Stream #0.5[0x24]: Subtitle: dvdsub
Stream #0.6[0x25]: Subtitle: dvdsub
Stream #0.7[0x26]: Subtitle: dvdsub
Stream #0.8[0x27]: Subtitle: dvdsub
Stream #0.9[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Stream #0.10[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
File 'mylongmovie.mkv' already exists. Overwrite ? [y/N] y
[buffer @ 0xce93c0] w:720 h:480 pixfmt:yuv420p
Output #0, matroska, to 'mylongmovie.mkv':
Metadata:
encoder : Lavf53.21.1
Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 59.94 tbc
Stream #0.1: Audio: libvorbis, 48000 Hz, 5.1, s16
Stream #0.2: Subtitle: dvdsub
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
Stream #0:9 -> #0:1 (ac3 -> libvorbis)
Stream #0:1 -> #0:2 (copy)
Press ctrl-c to stop encoding
[matroska @ 0xce4b40] Application provided invalid, non monotonically increasing dts to muxer in stream 2: 49 >= 49
av_interleaved_write_frame(): Invalid argument
2 个解决方案
#1
33
Short answer: Skip down to section Full commandline and download ffmpeg
from this site.
简短回答:跳到完整的命令行,从这个站点下载ffmpeg。
Originally, I planned to answer how to do this with avconv
because (a) that answer is still missing and (b) avconv
seems to be the default on ubuntu systems today. However it seems it's currently too buggy to accomplish this - at least for my testcases.
最初,我打算用avconv来回答这个问题,因为(a)答案仍然缺失,(b) avconv似乎是今天ubuntu系统的默认值。不过,现在看来,要完成这个任务,似乎还太麻烦了——至少对于我的测试案例来说是这样。
ffmpeg setup
ffmpeg设置
Since you ask for either avconv
or ffmpeg
, and I just learned that avconv
is a fork of ffmpeg
(see this answer for a discussion), I downloaded a current version of ffmpeg
from this site as the aforementioned answer explains. Windows builds are also available. For a typical current 64bit Linux build the direct link would be to this page. It contains daily builds. So scroll down until you see the latest and greatest, download, and unpack with e.g. tar xzvf ffmpeg.static.64bit.2014-02-14.tar.gz
. The advantage of a static build is that it has less, if no, dependencies. Unpacking the tarfile created two new executables ffmpeg
and ffprobe
in the current dir.
既然您要求avconv或ffmpeg,我刚刚了解到avconv是ffmpeg的一个分支(请参见这个问题的讨论),我从这个站点下载了一个当前版本的ffmpeg,正如前面提到的答案所解释的那样。Windows的构建也是可用的。对于一个典型的当前64位Linux构建,直接链接应该是在这一页。它包含每日构建。所以向下滚动,直到看到最新的、最伟大的、下载的和unpack,比如tar xzvf ffmpeg.static.64bit.2014-02-14.tar.gz。静态构建的优点是,它的依赖性更小。在当前目录中打开tarfile创建两个新的可执行文件ffmpeg和ffprobe。
Basic command line
基本的命令行
Now we can use this latest ffmpeg
to copy all streams inside the mymovie.vob*
to a different format. For example:
现在我们可以使用这个最新的ffmpeg来复制mymovie中的所有流。vob*的格式不同。例如:
./ffmpeg -i mymovie.vob -c:v copy -c:a copy -c:s copy -map 0 mymovie.mkv
This command line
这个命令行
- reads in from the input file
-i filename
- 从输入文件-i文件名中读取。
- copies video streams therein
-c:v copy
- 复制视频在其中-c:v拷贝。
- copies audio streams therein
-c:a copy
- 拷贝音频文件-c:拷贝。
- copies subtitles therein
-c:s copy
- 复制字幕-c:s拷贝。
- and instead of just using the first of each, it uses, and copies all of them
-map 0
- 而不是只使用第一个,它使用,并复制所有的-map 0。
- to the output file
outputfile
- 到输出文件outputfile。
Let's expand the above command line to workaround some possible bugs in the tool, or corrupt input files, or just specifics about .vob
files.
让我们扩展上面的命令行来解决工具中的一些可能的错误,或者损坏的输入文件,或者只是关于.vob文件的细节。
Work around for error Can't write packet with unknown timestamp
为错误而工作不能写带有未知时间戳的包。
Add the options -fflags +genpts
before the input file.
在输入文件之前添加选项- ff滞后+genpts。
./ffmpeg -fflags +genpts -i mymovie.vob -c:v copy -c:a copy -c:s copy -map 0 mymovie.mkv
Options in ffmpeg
always only affect input or output files named after the current option. Those two options must affect the input file, so they must come first.
ffmpeg中的选项总是只影响以当前选项命名的输入或输出文件。这两个选项必须影响输入文件,所以它们必须首先出现。
This workaround is covered in this bug ticket and may not help in all cases.
这种方法在这个bug中得到了解决,在所有情况下可能都没有帮助。
Missing some or all subtitles
遗漏了一些或全部字幕。
This is very typical behaviour when processing .vob
files and is covered in the ffmpeg
FAQ. Video container filetypes such as .avi
or .mp4
or .mkv
have headers (data at the start of a file) listing all content of the file. This makes it easy for players and conversion tools to know what kind of data to expect. .vob
files do not have such an explicit header. So when ffmpeg
or avconv
start, they look at the first couple thousand bytes. In vob files, the subtitles may start very late. In my testcase the first subtitle appears after several seconds, so the tools do not see it during startup. Here's typical example output during coding in these situations:
这是处理.vob文件时非常典型的行为,并且在ffmpeg FAQ中包含。视频容器文件类型,如.avi或.mp4或.mkv有标题(文件开头的数据)列出文件的所有内容。这使得玩家和转换工具很容易知道要期望什么类型的数据,.vob文件没有这样明确的标题。所以当ffmpeg或avconv开始时,他们会看到前几千个字节。在vob文件中,字幕可能会很晚才开始。在我的testcase中,第一个副标题在几秒钟后出现,所以在启动时工具没有看到它。下面是在这些情况下编码的典型示例输出:
Output #0, matroska, to 'test.mkv':
Metadata:
encoder : Lavf55.32.101
Stream #0:0: Video: mpeg2video (mpg2 / 0x3267706D), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, max. 9800 kb/s, 25 fps, 1k tbn, 90k tbc
Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 448 kb/s
Stream #0:2: Audio: dts ([1] [0][0] / 0x2001), 48000 Hz, 5.1(side), 768 kb/s
Stream #0:3: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 448 kb/s
Stream #0:4: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 224 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Stream #0:2 -> #0:2 (copy)
Stream #0:3 -> #0:3 (copy)
Stream #0:4 -> #0:4 (copy)
Press [q] to stop, [?] for help
[mpeg @ 0x31f2540] New subtitle stream 0:5 at pos:16945166 and DTS:22.2473s
[mpeg @ 0x31f2540] New subtitle stream 0:6 at pos:16951310 and DTS:22.2473s
[mpeg @ 0x31f2540] New subtitle stream 0:7 at pos:16957454 and DTS:22.2873s
[mpeg @ 0x31f2540] New subtitle stream 0:8 at pos:16963598 and DTS:22.2873s
[mpeg @ 0x31f2540] New subtitle stream 0:9 at pos:18405390 and DTS:25.4873s
[mpeg @ 0x31f2540] New subtitle stream 0:10 at pos:18417678 and DTS:25.4873s
[mpeg @ 0x31f2540] New subtitle stream 0:11 at pos:264593422 and DTS:288.207sts/s
[mpeg @ 0x31f2540] New subtitle stream 0:12 at pos:264597518 and DTS:288.207s
frame=24694 fps=7322 q=-1.0 Lsize= 859345kB time=00:16:27.74 bitrate=7127.1kbits/s
video:632823kB audio:224996kB subtitle:0 data:0 global headers:0kB muxing overhead 0.177935%
As one can see, new subtitle streams were found during the actual encoding. If one would try to add -map 5
option to include that stream, ffmpeg
would complain during startup that this stream number does not exist.
可以看到,在实际编码过程中发现了新的字幕流。如果您试图添加-map 5选项来包含该流,那么ffmpeg将在启动时抱怨这个流编号不存在。
The solution is to tell ffmpeg
to analyze more bytes at the start of the file in order to find all streams.
解决方案是让ffmpeg在文件开始时分析更多的字节,以便找到所有的流。
Try adding the options -analyzeduration 1000000k -probesize 1000000k
before the input file.
在输入文件之前,尝试添加选项-analyzeduration 1000000k -probesize 1000000k。
Try increasing the numbers if the streams are still not found. In my testcases those numbers were big enough. The output then changes to:
如果仍然没有发现流,可以尝试增加数字。在我的测试中,这些数字足够大。然后输出更改为:
Input #0, mpeg, from 'mymovie.vob':
Duration: 00:59:39.90, start: 0.287267, bitrate: 5915 kb/s
Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg), 720x576 [SAR 64:45 DAR 16:9], max. 9800 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x80]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Stream #0:2[0x89]: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 768 kb/s
Stream #0:3[0x82]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Stream #0:4[0x83]: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
Stream #0:5[0x20]: Subtitle: dvd_subtitle
Stream #0:6[0x21]: Subtitle: dvd_subtitle
Stream #0:7[0x22]: Subtitle: dvd_subtitle
Stream #0:8[0x23]: Subtitle: dvd_subtitle
Stream #0:9[0x24]: Subtitle: dvd_subtitle
Stream #0:10[0x25]: Subtitle: dvd_subtitle
Stream #0:11[0x26]: Subtitle: dvd_subtitle
Stream #0:12[0x27]: Subtitle: dvd_subtitle
File 'test.mkv' already exists. Overwrite ? [y/N] y
Output #0, matroska, to 'test.mkv':
Metadata:
encoder : Lavf55.32.101
Stream #0:0: Video: mpeg2video (mpg2 / 0x3267706D), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, max. 9800 kb/s, 25 fps, 1k tbn, 90k tbc
Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 448 kb/s
Stream #0:2: Audio: dts ([1] [0][0] / 0x2001), 48000 Hz, 5.1(side), 768 kb/s
Stream #0:3: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 448 kb/s
Stream #0:4: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 224 kb/s
Stream #0:5: Subtitle: dvd_subtitle
Stream #0:6: Subtitle: dvd_subtitle
Stream #0:7: Subtitle: dvd_subtitle
Stream #0:8: Subtitle: dvd_subtitle
Stream #0:9: Subtitle: dvd_subtitle
Stream #0:10: Subtitle: dvd_subtitle
Stream #0:11: Subtitle: dvd_subtitle
Stream #0:12: Subtitle: dvd_subtitle
Full commandline
完整的命令行
./ffmpeg -fflags +genpts -analyzeduration 1000000k -probesize 1000000k -i mymovie.vob -c:v copy -c:a copy -c:s copy -map 0 mymovie.mkv
Any of the copies can be replaced with a codec to actually convert, and likely compress, the data. But if it's just the three copies, then the command can be simplified to:
任何副本都可以用编解码器替换,以实际转换,并可能压缩数据。但如果只是三个副本,那么命令可以简化为:
./ffmpeg -fflags +genpts -analyzeduration 1000000k -probesize 1000000k -i mymovie.vob -c copy -map 0 mymovie.mkv
All of these options are also supported by avconv
. However this tool seems to still have a problem with some subtitles. If you see this error:
avconv也支持所有这些选项。然而,这个工具似乎仍然有一些字幕的问题。如果你看到这个错误:
[matroska @ 0x383aee60] Application provided invalid, non monotonically increasing dts to muxer in stream 7: 58280 >= 58280
av_interleaved_write_frame(): Invalid argument
You can workaround by downloading the latest ffmpeg
and using that tool instead, as I've explained above.
您可以通过下载最新的ffmpeg并使用该工具来解决问题,正如我在上面解释的那样。
#2
#1
33
Short answer: Skip down to section Full commandline and download ffmpeg
from this site.
简短回答:跳到完整的命令行,从这个站点下载ffmpeg。
Originally, I planned to answer how to do this with avconv
because (a) that answer is still missing and (b) avconv
seems to be the default on ubuntu systems today. However it seems it's currently too buggy to accomplish this - at least for my testcases.
最初,我打算用avconv来回答这个问题,因为(a)答案仍然缺失,(b) avconv似乎是今天ubuntu系统的默认值。不过,现在看来,要完成这个任务,似乎还太麻烦了——至少对于我的测试案例来说是这样。
ffmpeg setup
ffmpeg设置
Since you ask for either avconv
or ffmpeg
, and I just learned that avconv
is a fork of ffmpeg
(see this answer for a discussion), I downloaded a current version of ffmpeg
from this site as the aforementioned answer explains. Windows builds are also available. For a typical current 64bit Linux build the direct link would be to this page. It contains daily builds. So scroll down until you see the latest and greatest, download, and unpack with e.g. tar xzvf ffmpeg.static.64bit.2014-02-14.tar.gz
. The advantage of a static build is that it has less, if no, dependencies. Unpacking the tarfile created two new executables ffmpeg
and ffprobe
in the current dir.
既然您要求avconv或ffmpeg,我刚刚了解到avconv是ffmpeg的一个分支(请参见这个问题的讨论),我从这个站点下载了一个当前版本的ffmpeg,正如前面提到的答案所解释的那样。Windows的构建也是可用的。对于一个典型的当前64位Linux构建,直接链接应该是在这一页。它包含每日构建。所以向下滚动,直到看到最新的、最伟大的、下载的和unpack,比如tar xzvf ffmpeg.static.64bit.2014-02-14.tar.gz。静态构建的优点是,它的依赖性更小。在当前目录中打开tarfile创建两个新的可执行文件ffmpeg和ffprobe。
Basic command line
基本的命令行
Now we can use this latest ffmpeg
to copy all streams inside the mymovie.vob*
to a different format. For example:
现在我们可以使用这个最新的ffmpeg来复制mymovie中的所有流。vob*的格式不同。例如:
./ffmpeg -i mymovie.vob -c:v copy -c:a copy -c:s copy -map 0 mymovie.mkv
This command line
这个命令行
- reads in from the input file
-i filename
- 从输入文件-i文件名中读取。
- copies video streams therein
-c:v copy
- 复制视频在其中-c:v拷贝。
- copies audio streams therein
-c:a copy
- 拷贝音频文件-c:拷贝。
- copies subtitles therein
-c:s copy
- 复制字幕-c:s拷贝。
- and instead of just using the first of each, it uses, and copies all of them
-map 0
- 而不是只使用第一个,它使用,并复制所有的-map 0。
- to the output file
outputfile
- 到输出文件outputfile。
Let's expand the above command line to workaround some possible bugs in the tool, or corrupt input files, or just specifics about .vob
files.
让我们扩展上面的命令行来解决工具中的一些可能的错误,或者损坏的输入文件,或者只是关于.vob文件的细节。
Work around for error Can't write packet with unknown timestamp
为错误而工作不能写带有未知时间戳的包。
Add the options -fflags +genpts
before the input file.
在输入文件之前添加选项- ff滞后+genpts。
./ffmpeg -fflags +genpts -i mymovie.vob -c:v copy -c:a copy -c:s copy -map 0 mymovie.mkv
Options in ffmpeg
always only affect input or output files named after the current option. Those two options must affect the input file, so they must come first.
ffmpeg中的选项总是只影响以当前选项命名的输入或输出文件。这两个选项必须影响输入文件,所以它们必须首先出现。
This workaround is covered in this bug ticket and may not help in all cases.
这种方法在这个bug中得到了解决,在所有情况下可能都没有帮助。
Missing some or all subtitles
遗漏了一些或全部字幕。
This is very typical behaviour when processing .vob
files and is covered in the ffmpeg
FAQ. Video container filetypes such as .avi
or .mp4
or .mkv
have headers (data at the start of a file) listing all content of the file. This makes it easy for players and conversion tools to know what kind of data to expect. .vob
files do not have such an explicit header. So when ffmpeg
or avconv
start, they look at the first couple thousand bytes. In vob files, the subtitles may start very late. In my testcase the first subtitle appears after several seconds, so the tools do not see it during startup. Here's typical example output during coding in these situations:
这是处理.vob文件时非常典型的行为,并且在ffmpeg FAQ中包含。视频容器文件类型,如.avi或.mp4或.mkv有标题(文件开头的数据)列出文件的所有内容。这使得玩家和转换工具很容易知道要期望什么类型的数据,.vob文件没有这样明确的标题。所以当ffmpeg或avconv开始时,他们会看到前几千个字节。在vob文件中,字幕可能会很晚才开始。在我的testcase中,第一个副标题在几秒钟后出现,所以在启动时工具没有看到它。下面是在这些情况下编码的典型示例输出:
Output #0, matroska, to 'test.mkv':
Metadata:
encoder : Lavf55.32.101
Stream #0:0: Video: mpeg2video (mpg2 / 0x3267706D), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, max. 9800 kb/s, 25 fps, 1k tbn, 90k tbc
Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 448 kb/s
Stream #0:2: Audio: dts ([1] [0][0] / 0x2001), 48000 Hz, 5.1(side), 768 kb/s
Stream #0:3: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 448 kb/s
Stream #0:4: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 224 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Stream #0:2 -> #0:2 (copy)
Stream #0:3 -> #0:3 (copy)
Stream #0:4 -> #0:4 (copy)
Press [q] to stop, [?] for help
[mpeg @ 0x31f2540] New subtitle stream 0:5 at pos:16945166 and DTS:22.2473s
[mpeg @ 0x31f2540] New subtitle stream 0:6 at pos:16951310 and DTS:22.2473s
[mpeg @ 0x31f2540] New subtitle stream 0:7 at pos:16957454 and DTS:22.2873s
[mpeg @ 0x31f2540] New subtitle stream 0:8 at pos:16963598 and DTS:22.2873s
[mpeg @ 0x31f2540] New subtitle stream 0:9 at pos:18405390 and DTS:25.4873s
[mpeg @ 0x31f2540] New subtitle stream 0:10 at pos:18417678 and DTS:25.4873s
[mpeg @ 0x31f2540] New subtitle stream 0:11 at pos:264593422 and DTS:288.207sts/s
[mpeg @ 0x31f2540] New subtitle stream 0:12 at pos:264597518 and DTS:288.207s
frame=24694 fps=7322 q=-1.0 Lsize= 859345kB time=00:16:27.74 bitrate=7127.1kbits/s
video:632823kB audio:224996kB subtitle:0 data:0 global headers:0kB muxing overhead 0.177935%
As one can see, new subtitle streams were found during the actual encoding. If one would try to add -map 5
option to include that stream, ffmpeg
would complain during startup that this stream number does not exist.
可以看到,在实际编码过程中发现了新的字幕流。如果您试图添加-map 5选项来包含该流,那么ffmpeg将在启动时抱怨这个流编号不存在。
The solution is to tell ffmpeg
to analyze more bytes at the start of the file in order to find all streams.
解决方案是让ffmpeg在文件开始时分析更多的字节,以便找到所有的流。
Try adding the options -analyzeduration 1000000k -probesize 1000000k
before the input file.
在输入文件之前,尝试添加选项-analyzeduration 1000000k -probesize 1000000k。
Try increasing the numbers if the streams are still not found. In my testcases those numbers were big enough. The output then changes to:
如果仍然没有发现流,可以尝试增加数字。在我的测试中,这些数字足够大。然后输出更改为:
Input #0, mpeg, from 'mymovie.vob':
Duration: 00:59:39.90, start: 0.287267, bitrate: 5915 kb/s
Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg), 720x576 [SAR 64:45 DAR 16:9], max. 9800 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x80]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Stream #0:2[0x89]: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 768 kb/s
Stream #0:3[0x82]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
Stream #0:4[0x83]: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
Stream #0:5[0x20]: Subtitle: dvd_subtitle
Stream #0:6[0x21]: Subtitle: dvd_subtitle
Stream #0:7[0x22]: Subtitle: dvd_subtitle
Stream #0:8[0x23]: Subtitle: dvd_subtitle
Stream #0:9[0x24]: Subtitle: dvd_subtitle
Stream #0:10[0x25]: Subtitle: dvd_subtitle
Stream #0:11[0x26]: Subtitle: dvd_subtitle
Stream #0:12[0x27]: Subtitle: dvd_subtitle
File 'test.mkv' already exists. Overwrite ? [y/N] y
Output #0, matroska, to 'test.mkv':
Metadata:
encoder : Lavf55.32.101
Stream #0:0: Video: mpeg2video (mpg2 / 0x3267706D), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, max. 9800 kb/s, 25 fps, 1k tbn, 90k tbc
Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 448 kb/s
Stream #0:2: Audio: dts ([1] [0][0] / 0x2001), 48000 Hz, 5.1(side), 768 kb/s
Stream #0:3: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 448 kb/s
Stream #0:4: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 224 kb/s
Stream #0:5: Subtitle: dvd_subtitle
Stream #0:6: Subtitle: dvd_subtitle
Stream #0:7: Subtitle: dvd_subtitle
Stream #0:8: Subtitle: dvd_subtitle
Stream #0:9: Subtitle: dvd_subtitle
Stream #0:10: Subtitle: dvd_subtitle
Stream #0:11: Subtitle: dvd_subtitle
Stream #0:12: Subtitle: dvd_subtitle
Full commandline
完整的命令行
./ffmpeg -fflags +genpts -analyzeduration 1000000k -probesize 1000000k -i mymovie.vob -c:v copy -c:a copy -c:s copy -map 0 mymovie.mkv
Any of the copies can be replaced with a codec to actually convert, and likely compress, the data. But if it's just the three copies, then the command can be simplified to:
任何副本都可以用编解码器替换,以实际转换,并可能压缩数据。但如果只是三个副本,那么命令可以简化为:
./ffmpeg -fflags +genpts -analyzeduration 1000000k -probesize 1000000k -i mymovie.vob -c copy -map 0 mymovie.mkv
All of these options are also supported by avconv
. However this tool seems to still have a problem with some subtitles. If you see this error:
avconv也支持所有这些选项。然而,这个工具似乎仍然有一些字幕的问题。如果你看到这个错误:
[matroska @ 0x383aee60] Application provided invalid, non monotonically increasing dts to muxer in stream 7: 58280 >= 58280
av_interleaved_write_frame(): Invalid argument
You can workaround by downloading the latest ffmpeg
and using that tool instead, as I've explained above.
您可以通过下载最新的ffmpeg并使用该工具来解决问题,正如我在上面解释的那样。