2008-09-21

mkv视频的处理

  随着高清的普及,以mkv封装发布的视频越来越多。这种格式的视频需要处理的话直接用普通的傻瓜式程序是不可能的,而使用mencoder又会改变封装,这个过程会产生奇怪的问题。比如不同步,时间轴不准等等。这个时候就需要使用强大的MKVToolnix。
  官方对它的定义是:MKVToolnix -- Cross-platform tools for Matroska
  当然就是跨平台,又开源的东西了。我这次用的是linux平台来解说。也可自己参照官网的文档:http://www.bunkus.org/videotools/mkvtoolnix/source.html
  MKVToolnix包括mkvmerge mkvinfo mkvextract
  mkvmerge的gui版使用mmg命令启动。下面主要介绍一下我自己常用的功能:

切割mkv视频:
  mkvmerge在切割方面提供了三种方法,见split参数解释:
  

Splits the output file after a given size or a given time. Please note that tracks can only be split right before a key frame. Due to buffering mkvmerge will split right before the next key frame after the split point has been reached. Therefore the split point may be a bit off from what the user has specified.
At the moment mkvmerge supports three different modes.
1. Splitting by size.
The parameter d may end with k, m or g to indicate that the size is in KB, MB or GB respectively. Otherwise a size in Bytes is assumed. After the current output file has reached this size limit a new one will be started. The size: prefix may be omitted for compatibility reasons.
2. Splitting after a duration.
The paramter must have the form HH:MM:SS.nnnnnnnnn for specifying the duration in up to nano-second precision or a number n followed by the letter ’s’ for the duration in seconds. "HH" is the number of hours, "MM" the number of minutes, "SS" the number of seconds and "nnnnnnnnn" the number of nanoseconds. Both the number of hours and the number of nanoseconds can be omitted. There can be up to nine digits after the decimal point. After the duration of the contents in the current output has reached this limit a new output file will be started. The duration: prefix may be omitted for compatibility reasons.
3. Splitting after specific timecodes.
The parameters A, B etc must all have the same format as the ones used for the duration (see above). The list of timecodes is separated by commas. After the current file has reached the current split point’s timecode a new file is created. Then the next split point given in this list is used. The timecodes: prefix must not be omitted.
For this splitting mode the output filename is treated differently than for the normal operation. It may contain a printf like expression ’%d’ including an optional field width, e.g. ’%02d’. If it does then the current file number will be formatted appropriately and inserted at that point in the filename. If there is no such pattern then a pattern of ’-%03d’ is assumed right before the file’s extension: ’-o output.mkv’ would result in ’output-001.mkv’ and so on. If there’s no extension then ’-%03d’ will be appended to the name.  
  废话很长,其实就是三种,一个按大小分割,一个按每次分割出的文件有多长时间分割,还有一个按照时间点分割也就是从头开始,当时间到你填入的时间点时它会自动分割一个文件。
比如我填50s,160s那么视频会被分成三个片段,一个从头到50s第二个从50s到160s,第三个从160s到结束。


提取mkv视频中的流:
  直接用mkvextract命令就好了。

封装成mkv:
  同样使用mkvmerge就好了。

没有评论: