『漫游』酷论坛>『影音数码技术学习交流』>影音精华区>[原创] .mkv 檔的擷取

[原创] .mkv 檔的擷取

weilai@2003-08-29 20:04

假設 in.mkv 為
Track ID 1: video (V_MS/VFW/FOURCC, XVID)
Track ID 2: audio (A_MPEG/L3)
Track ID 3: subtitles (S_TEXT/ASS)
的複合檔

Tools: libcharset.dll、libiconv.dll、mkvmerge.exe、mkvextract.exe、中文內碼轉換器 Convertz
首先要知道為第幾 Track ID (後以TID 稱之)為何?
指令: mkvmerge.exe -i in.mkv
即可得如上資訊 Track ID 1: video...

現在要擷取 TID 1 :
指令: mkvextract.exe tracks in.mkv 1:in_video.avi
即可得 in_video.avi

要擷取 TID 2 :
指令: mkvextract.exe tracks in.mkv 2:in_audio .mp3
即可得 in_audio .mp3

皆下來是重頭戲擷取 TID 3 (字幕檔) :
指令: mkvextract.exe tracks in.mkv 3:in_subtitles.ass
即可得 in_subtitles.ass

但這裡有一點問題會的到英文+亂碼(或空字元)
通常 .mkv 的字幕檔為適應各語系下的 OS 會用 UTF-8 (Unicode 的一支)編碼
所以改成
指令: mkvextract.exe tracks in.mkv -c UTF-8 3:in_subtitles.ass
在此得到的 out_subtitles.ass 可能由於DOS作用於OS語系的問題還是選錯 charset 的原因,因此還是會得到英文+亂碼的字幕檔
此時最後只要用 Convertz 將 in_subtitles.ass 字幕檔內碼由 UTF-8 轉成 BIG-5 即完成 (簡體或許不會有此問題)

當然方法不只一個還可用 VirtualDubMod 但成功率不高
畢竟其從 1.5.xx 才開始支援 .mkv 的 multi-Track 特別是 .ass .ssa

PS.擷取字幕檔時常被視為大忌,望看到的人不要廣為流傳,應此此不提供Tools 的載點

其實 -c 這個 chapters 有一大排字元code 用對了就可得到正確的字幕檔,有興趣的可自己研究 ^^
引用

風之殤@2003-08-29 20:28

GOOD~~感謝weilai兄

置頂$&UP
引用

weilai@2003-08-29 20:33

再補充一下 用 Convertz 將 in_subtitles.ass 字幕檔內碼由 UTF-8 轉成 BIG-5 後可在開檔另存,選 UTF-8 內碼此時就恢復成原檔
引用

weilai@2003-08-29 21:02

最後補充一下指令使用手冊

mkvmerge -o [global options] [options] [@optionsfile ...]
===========================[global options]==============================
Global options:
-v, --verbose verbose status
-q, --quiet suppress status output
-o, --output out Write to the file .
--title Title for this output file. <br /> --chapters <file> Read chapter information from the file. <br /> --global-tags <file> Read global tags from a XML file. <br />=========================== <br /> General output control (still global, advanced options): <br /> --cluster-length <n[ms]> Put at most n data blocks into each cluster. <br /> If the number is postfixed with 'ms' then <br /> put at most n milliseconds of data into each <br /> cluster. <br /> --no-cues Do not write the cue data (the index). <br /> --no-meta-seek Do not write any meta seek information. <br /> --meta-seek-size <d> Reserve d bytes for the meta seek entries. <br /> --no-lacing Do not use lacing. <br />=========================== <br /> File splitting and linking (still global): <br /> --split <d[K,M,G]|HH:MM:SS|ns> <br /> Create a new file after d bytes (KB, MB, GB) <br /> or after a specific time. <br /> --split-max-files <n> Create at most n files. <br /> --dont-link Don't link splitted files. <br /> --link-to-previous <UID> Link the first file to the given UID. <br /> --link-to-next <UID> Link the last file to the given UID. <br />=========================== <br /> Attachment support (still global): <br /> --attachment-description <desc> <br /> Description for the following attachment. <br /> --attachment-mime-type <mime type> <br /> Mime type for the following attachment. <br /> --attach-file <file> Creates a file attachment inside the <br /> Matroska file. <br /> --attach-file-once <file> <br /> Creates a file attachment inside the <br /> firsts Matroska file written. <br />===========================[options]===================================== <br /> Options for each input file: <br /> -a, --atracks <n,m,...> Copy audio tracks n,m etc. Default: copy all <br /> audio tracks. <br /> -d, --vtracks <n,m,...> Copy video tracks n,m etc. Default: copy all <br /> video tracks. <br /> -s, --stracks <n,m,...> Copy subtitle tracks n,m etc. Default: copy <br /> all subtitle tracks. <br /> -A, --noaudio Don't copy any audio track from this file. <br /> -D, --novideo Don't copy any video track from this file. <br /> -S, --nosubs Don't copy any text track from this file. <br /> -y, --sync <TID:d[,o[/p]]> <br /> Synchronize, delay the audio track with the <br /> id TID by d ms. <br /> d > 0: Pad with silent samples. <br /> d < 0: Remove samples from the beginning. <br /> o/p: Adjust the timecodes by o/p to fix <br /> linear drifts. p defaults to 1000 if <br /> omitted. Both o and p can be floating point <br /> numbers. <br /> --default-track <TID> Sets the 'default' flag for this track. <br /> --cues <TID:none|iframes|all> <br /> Create cue (index) entries for this track: <br /> None at all, only for I frames, for all. <br /> --language <TID:lang> Sets the language for the track (ISO639-2 <br /> code, see --list-languages). <br /> -t, --tags <TID:file> Read tags for the track from a XML file. <br /> --aac-is-sbr <TID> Track with the ID is HE-AAC/AAC+/SBR-AAC. <br />===========================[options] for video tracks==================== <br /> Options that only apply to video tracks: <br /> -f, --fourcc <FOURCC> Forces the FourCC to the specified value. <br /> Works only for video tracks. <br /> --aspect-ratio <f|a/b> Sets the aspect ratio. <br />===========================[options] for text subtitle tracks============ <br /> Options that only apply to text subtitle tracks: <br /> --sub-charset <TID:charset> <br /> Sets the charset the text subtitles are <br /> written in for the conversion to UTF-8. <br /> <br />===========================單獨============================= <br /> Other options: <br /> -i, --identify <file> Print information about the source file. <br /> -l, --list-types Lists supported input file types. <br /> --list-languages Lists all ISO639 languages and their <br /> ISO639-2 codes. <br /> -h, --help Show this help. <br /> -V, --version Show version information. <br /> @optionsfile Reads additional command line options from <br /> the specified file (see man page).<div><a href="post.php?action=quote&fid=90&tid=163078&pid=3990600&article=3&page=1">引用</a></div><hr /><p class="b"><p><p class="green">weilai@2003-08-29 21:04</p>Usage: mkvextract tracks <inname> [options] [TID1:out1 [TID2:out2 ...]] <br /> or mkvextract tags <inname> [options] <br /> or mkvextract attachments <inname> [options] [AID1:out1 [AID2:out2 ...]] <br /> or mkvextract chapters <inname> [options] <br /> or mkvextract <-h|-V> <br /> <br /> The first word tells mkvextract what to extract. The second must be the <br /> source file. The only 'global' option that can be used with all modes is <br /> '-v' or '--verbose' to increase the verbosity. All other options depend <br /> on the mode. <br /> <br /> First mode extracts some tracks to external files. <br /> -c charset Convert text subtitles to this charset. <br /> TID:out Write track with the ID TID to the file 'out'. <br /> <br /> Second mode extracts the tags and converts them to XML. The output is <br /> written to the standard output. The output can be used as a source <br /> for mkvmerge. <br /> <br /> Third mode extracts attachments from inname. <br /> AID:outname Write the attachment with the ID AID to 'outname'. <br /> <br /> Fourth mode extracts the chapters and converts them to XML. The output is <br /> written to the standard output. The output can be used as a source <br /> for mkvmerge. <br /> -s, --simple Exports the chapter infomartion in the simple format <br /> used in OGM tools (CHAPTER01=... CHAPTER01NAME=...). <br /> <br /> These options can be used instead of the mode keyword to obtain <br /> further information: <br /> -v, --verbose Increase verbosity. <br /> -h, --help Show this help. <br /> -V, --version Show version information.<div><a href="post.php?action=quote&fid=90&tid=163078&pid=3990635&article=4&page=1">引用</a></div><hr /><p class="b"><p><p class="green">風之殤@2003-08-29 21:14</p>剛測試過 完全OK ^_^ <br /> <br />在VDM出新版之前 這是最好的辦法了 <br /> <br />再次感謝weilai兄的大力協助<div><a href="post.php?action=quote&fid=90&tid=163078&pid=3990780&article=5&page=1">引用</a></div><hr /><p class="b"><p><p class="green">风的召唤@2003-08-29 21:43</p>有个小问题~~~~mkvextract.exe 要怎么和mmg关联啊,而且mmg里面的命令好象不能改只能复制运行里执行 好麻烦啊<div><a href="post.php?action=quote&fid=90&tid=163078&pid=3991022&article=6&page=1">引用</a></div><hr /><p class="b"><p><p class="green">坏坏@2003-08-30 01:52</p>有没有在LINUX下播放MKV的软件呀。<div><a href="post.php?action=quote&fid=90&tid=163078&pid=3993952&article=7&page=1">引用</a></div><hr /><p class="b"><p><p class="green">weilai@2003-08-30 08:39</p><blockquote class="blockquote3"><div class="quote">引用 </div><div class="text"><i>最初由 风的召唤 发布</i> <br /><b>有个小问题~~~~mkvextract.exe 要怎么和mmg关联啊,而且mmg里面的命令好象不能改只能复制运行里执行 好麻烦啊 </b></div></blockquote> <br /> <br />上面所提的是在 DOS 執行的指令 <br />mmg 是 mkvmerge 的圖形介面基本上與所提指令無關<div><a href="post.php?action=quote&fid=90&tid=163078&pid=3995571&article=8&page=1">引用</a></div><hr /><p class="b"><p><p class="green">weilai@2003-08-30 08:55</p><blockquote class="blockquote3"><div class="quote">引用 </div><div class="text"><i>最初由 坏坏 发布</i> <br /><b>有没有在LINUX下播放MKV的软件呀。 </b></div></blockquote> <br /> <br />到這裡看看 <br /><a href="http://www.piorunek.pl/~dominik/linux/pkgs/mplayer/" target="_blank" >http://www.piorunek.pl/~dominik/linux/pkgs/mplayer/</a><div><a href="post.php?action=quote&fid=90&tid=163078&pid=3995706&article=9&page=1">引用</a></div><hr /><p class="b"><p><p class="green">OII@2003-08-30 12:11</p>等mkv等字幕及RAW分離的方法被廣為流傳之時 <br />mkv可能就會被放棄採用 <br />因為會被盜版商加以利用 成為商業工具<div><a href="post.php?action=quote&fid=90&tid=163078&pid=3997571&article=10&page=1">引用</a></div><hr /><p class="b"><p><p class="green">風之殤@2003-08-30 14:24</p><blockquote class="blockquote3"><div class="quote">引用 </div><div class="text"><i>最初由 OII 发布</i> <br /><b>等mkv等字幕及RAW分離的方法被廣為流傳之時 <br />mkv可能就會被放棄採用 <br />因為會被盜版商加以利用 成為商業工具 </b></div></blockquote> <br /> <br />MKV要是用內崁字幕的話 似乎就沒啥特色了 <br /> <br />畢竟RV9+AC-3的效果似乎沒人喜歡....... <br /> <br />基本上HK和TW的D版商根本不削用這裡的東西 2區VOB直灌才是他們愛用的技倆 <br /> <br />只有CN的D版商會用CDR當看影片的媒體 DVD才是王道啊......就算D版也是:p<div><a href="post.php?action=quote&fid=90&tid=163078&pid=3999477&article=11&page=1">引用</a></div><hr /><p class="b"><p><p class="green">big@2003-08-30 14:50</p><blockquote class="blockquote3"><div class="quote">引用 </div><div class="text"><i>最初由 風之殤 发布</i> <br /><b> <br /> <br />MKV要是用內崁字幕的話 似乎就沒啥特色了 <br /> <br />畢竟RV9+AC-3的效果似乎沒人喜歡....... <br /> <br />基本上HK和TW的D版商根本不削用這裡的東西 2區VOB直灌才是他們愛用的技倆 <br /> <br />只有CN的D版商會用CDR當看影片的媒體 DVD才是王道啊......就算D版也是:p </b></div></blockquote> <br /> <br />寒....現在新出的d版哪有2區直灌的呀.... <br />都是tv側錄+字幕的..... <br />hk和tw都是這樣做的... <br />除了有些大陸的d商用decss來重製的....還算有些良心.... <br />其它的都是tv轉的或ysys出來的垃圾........(bs錄的還有點可看性)<div><a href="post.php?action=quote&fid=90&tid=163078&pid=3999822&article=12&page=1">引用</a></div><hr /><p class="b"><p><p class="green">耀天使@2003-08-30 19:49</p>提取出来的字幕只有时间轴而且 字幕跟特效跟本看不到<div><a href="post.php?action=quote&fid=90&tid=163078&pid=4003843&article=13&page=1">引用</a></div><hr /><p class="b"><p><p class="green">weilai@2003-08-30 20:02</p><blockquote class="blockquote3"><div class="quote">引用 </div><div class="text"><i>最初由 耀天使 发布</i> <br /><b>提取出来的字幕只有时间轴而且 字幕跟特效跟本看不到 </b></div></blockquote> <br /> <br />那是 -c <chapters> 這個參數設定的問題 <br />請自行研究 <br /> <br />PS.不太想使 mkv 的使用因此阻絕,所以希望成功的人不要大肆宣揚 ^^||<div><a href="post.php?action=quote&fid=90&tid=163078&pid=4003996&article=14&page=1">引用</a></div><hr /><p><a href="read.php?tid=163078&displayMode=1&page=1">«</a><b>1</b><a href="read.php?tid=163078&displayMode=1&page=2">2</a><a href="read.php?tid=163078&displayMode=1&page=3">3</a><a href="read.php?tid=163078&displayMode=1&page=4">4</a><a href="read.php?tid=163078&displayMode=1&page=5">5</a><a href="read.php?tid=163078&displayMode=1&page=5">»</a>共5页</p> | <a href="#top">TOP</a><body></html>