
我有一個.mov
文件,其中包含mov_text
使用舊版(現已棄用)QuickTime 7 Pro 的“文字軌道”功能創建的 格式字幕軌道。這是ffmpeg -i myfile.mov
我對他們的了解:
Stream #0:4(eng): Subtitle: mov_text (text / 0x74786574), 640x116, 0 kb/s (default)
Metadata:
rotate : 0
creation_time : 2021-11-20T03:08:45.000000Z
handler_name : Apple Text Media Handler
目前我仍然可以使用 QuickTime 7 Pro,在那裡我可以提取字幕,然後轉換為 SubRip 或其他程式可以讀取的其他格式。但是,我需要更新我的系統,而 QuickTime 7 Pro 無法在 macOS Catalina 及更高版本上運行,因此我正在尋找一種方法,以便仍然能夠在較新的系統上存取這些字幕。這似乎ffmpeg
是要走的路,但我仍然被困住了。
這是我嘗試過的:
ffmpeg -i test.mov -map 0:s:0 -c copy -f data QT-subtitles.txt
為我提供了字幕的純文本,但沒有時間戳,因此將字幕轉換為其他格式毫無用處。
ffmpeg -i test.mov -map 0:s:0 QT-subtitles.srt
正確地將字幕轉換為 SubRip(包括時間戳記)。但它擺脫了換行符和其他格式。
它還向我提供以下發現無效資料的錯誤訊息:
Stream mapping:
Stream #0:4 -> #0:0 (mov_text (native) -> subrip (srt))
Press [q] to stop, [?] for help
[mov_text @ 0x7fa492823200] invalid UTF-8 byte in subtitle
[mov_text @ 0x7fa492823200] Invalid UTF-8 in decoded subtitles text; maybe missing -sub_charenc option
Error while decoding stream #0:4: Invalid data found when processing input
[mov_text @ 0x7fa492823200] invalid UTF-8 byte in subtitle
[mov_text @ 0x7fa492823200] Invalid UTF-8 in decoded subtitles text; maybe missing -sub_charenc option
Error while decoding stream #0:4: Invalid data found when processing input
size= 6kB time=00:02:04.30 bitrate= 0.4kbits/s speed=3.32e+04x
video:0kB audio:0kB subtitle:3kB other streams:0kB global headers:0kB muxing overhead: 82.697044%
下面的評論中指定的建議-c text
或-sub_charenc
全部給了我相同的結果。
因此,我希望找到一種方法將字幕提取到一個簡單的文字檔案中,該檔案要么仍然是 QTText 格式(見下文),要么以其他方式保留換行符和其他格式。這是當我透過 QuickTime 7 Pro 提取並匯出原始 QuickTime 文字軌道時,原始 QuickTime 文字軌道看起來像文字檔案的樣子(請參閱規格這裡)。
{QTtext}{font:Verdana}{plain}{size:36}{textColor: 65535, 65535, 65535}{backColor: 0, 0, 0}{justify:default}{timeScale:30}{width:640}{height:116}{timeStamps:absolute}{language:0}{textEncoding:0}
[00:00:00.00]
Text here {bold} bold word {plain} text here
[00:00:01.12]
Text here text here text here
Next line here (respects spaces)
[00:00:02.14]
然後我可以簡單地編寫一個腳本來將格式化標籤(例如{bold}
等)轉換為 html 標籤,我相信 SubRip 可以理解。
除了從檔案副檔名(例如或 )ffmpeg
猜測我需要什麼之外,是否有其他方法可以指定輸出格式? (我特別想,如果我能夠指定為輸出,它可能會給我一個像上面那樣的 QTText 格式的文件......但我該怎麼做呢?)srt
txt
mov_text
如果ffmpeg
不能完成這項工作,我很樂意嘗試其他工具。
答案1
如果您願意將 mov_text 字幕轉碼為其他內容(例如 Subrip SRT 檔案),您可以嘗試以下操作:
ffmpeg -i test.mov -map 0:s:0 -c:s srt subtitles.srt