2012-05-04 64 views
4

例如,將mkv文件轉儲到某些文本(如mkvinfo -v)中,編輯它並重新構建,將二進制數據保留爲十六進制轉儲將會很有用。是否有任何工具將matroska(mkv)轉換爲/從文本文件?

喜歡的東西:

$ mkv2xml <test.mkv> test.xml 
$ head test.xml 
<EBML> 
    <EBMLVersion>1</EBMLVersion> 
    <MaxIdLen>4</<MaxIdLen> 
    <MaxSizeLen>8</MaxSizeLen> 
    <DocType>matroska</DocType> 
    <DocTypeVersion>2</DocTypeVersion> 
    <DocTypeReadVersion>2</DocTypeReadVersion> 
    <Segment> 
     <Tracks> 
     <Track> 
      <TrackNumber>1</TrackNumber> 
      <CodecID>V_MJPEG</CodecID> 
      <Video><PixelWidth>320</PixelWidth><PixelHeight>240</PixelHeight></Video> 
     </Track> 
     </Tracks> 
     <Cluster> 
      <Timecode>5.023</TimeCode> 
      <SimpleBlock track="1" time="5.045"> 
       ffd8fffe001a80...... 
$ xml2mkv < test.xml | mplayer -cache 100 - 

這可以,只要看看輸出是簡化編寫[調試]工具與視頻工作,而木香實際上搞亂/多路分解細節有用。

+0

看起來像'mkvinfo -v -X提供-v'的MKV的完全轉儲。現在正在尋找從「mkvinfo -X」到mkv文件的轉換。 –

回答

5

實現自己在Python:https://github.com/vi/mkvparse

可以轉換爲XML,改變的東西(有xml2/2xml,例如),轉換回在一個流水線玩。

示例XML文件:http://vi-server.org/pub/xml2mkv_test.xml

修剪(甚至更多)片斷位置:

<mkv2xml> 
<EBML> 
    <EBMLVersion>1</EBMLVersion> 
    <DocType>matroska</DocType> 
</EBML> 
<Segment> 
<Info> 
    <TimecodeScale>1000000</TimecodeScale> 
    <MuxingApp>libebml v1.0.0 + libmatroska v1.0.0</MuxingApp> 
    <Duration>46665.0</Duration> 
    <DateUTC>1282406803.0</DateUTC> 
    <SegmentUID>9d516a0f927a12d286e1502d23d0fdb0</SegmentUID> 
</Info> 
<Tracks> 
    <TrackEntry> 
    <TrackNumber>1</TrackNumber> 
    <TrackType>1</TrackType> 
    <CodecID>V_MPEG4/ISO/AVC</CodecID> 
    <CodecPrivate> 
     014d401fffe10014274d401fa918080093600d418041adb0ad7bdf0101000428 
     ce09c8 
    </CodecPrivate> 
    <Video> 
     <PixelWidth>1024</PixelWidth> 
     <PixelHeight>576</PixelHeight> 
    </Video> 
    </TrackEntry> 
    <TrackEntry> 
    <TrackNumber>2</TrackNumber> 
    <TrackType>2</TrackType> 
    <CodecID>A_AAC</CodecID> 
    <Audio> 
     <SamplingFrequency>48000.0</SamplingFrequency> 
     <Channels>2</Channels> 
    </Audio> 
    </TrackEntry> 
    <TrackEntry> 
    <TrackNumber>3</TrackNumber> 
    <CodecID>S_TEXT/UTF8</CodecID> 
    </TrackEntry> 
    ... 
</Tracks> 
<Cluster> 
    <Timecode>0</Timecode> 
    <SimpleBlock> 
    <track>1</track> 
    <timecode>0.0</timecode> 
    <keyframe/> 
    <data> 
     00004e1925b82001ebd34d359f84a010001019b0f94a107609ec4dc0b6341175 
     98899cbb3a0a9de562532111ed77f7876006014200856a5fc3c2ccdf6e10a385 
     ... 
    </data> 
    </SimpleBlock> 
    <SimpleBlock> 
    <track>10</track> 
    <timecode>0.009</timecode> 
    <keyframe/> 
    <data> 
     01449ffe0b246a488f09c715768924b01aa2e9b2415aaa29e4696becea270d36 
     a0d565bd24d5e6f09f3d4e000a8f192aa6aaa071f2ba14bd2fa14d633ad665ee 
     72e92eadce23415fd6bb871941941b1bfd5b0e75ad6826755e61ef5483f93cd3 
     82d61c779fa74b4acd62572b399ac3d9039900e94a5c542e4110dd29b65e2000 
     220011a10c00000000b0a8540100880380 
    </data> 
    <data> 
     0144d7902c180b04c28161a8482a160a048aa1209848423208cdeed6de7c6b7a 
     ..... 
    </data> 
    ... 
    </SimpleBlock> 
    <BlockGroup> 
    <Block> 
     <track>4</track> 
     <timecode>0.042</timecode> 
     <duration>3.375</duration> 
     <data encoding="text"><![CDATA[A jobb oldaladon láthatod... 
...tudod mit...]]></data> 
    </Block> 
    <BlockDuration>3375</BlockDuration> 
    </BlockGroup> 
    <BlockGroup> 
    <Block> 
     <track>5</track> 
     <timecode>0.042</timecode> 
     <duration>3.375</duration> 
     <data encoding="text"><![CDATA[Auf der rechten Seite sieht man...|...rate mal...]]></data> 
    </Block> 
    <BlockDuration>3375</BlockDuration> 
    </BlockGroup> 
</Cluster> 
</Segment> 
</mkv2xml> 
相關問題