使用 FFmpeg 複製多個 PGS 字幕軌道

使用 FFmpeg 複製多個 PGS 字幕軌道

我使用的是 Debian 9。我想將視訊傳遞到 h265 並將所有音軌和字幕保留到 .mkv 容器中,因為據我了解 mp4 不支援基於圖像的字幕。

我使用的命令是:

ffmpeg -i entrada.264.mkv -c:v libx265 -f matroska -map 0 salida.265.mkv

但我在 ffmpeg 中收到此錯誤:

[matroska,webm @ 0x55ec1759fee0] Could not find codec parameters for stream 6 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 0x55ec1759fee0] Could not find codec parameters for stream 7 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 0x55ec1759fee0] Could not find codec parameters for stream 8 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 0x55ec1759fee0] Could not find codec parameters for stream 9 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 0x55ec1759fee0] Could not find codec parameters for stream 10 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 0x55ec1759fee0] Could not find codec parameters for stream 11 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Only SUBTITLE_ASS type supported.
Subtitle encoding failed

而且,如果想一次複製一個,只要刻錄第一​​個即可。

這裡是相關文件的資料:

總之:

預期結果:將視訊檔案重新編碼為 h265,並複製所有音訊和字幕而不對其進行修改或將其刻錄到視訊中,以便能夠選擇使用哪一個。

所得的結果:由於缺少字幕參數而出錯。

有沒有一種方法可以直接從 ffmpeg 中完成,而不必逐一提取字幕,然後透過 mkvmerge 等程式將它們添加到影片中?

答案1

串流複製(重新重複使用)除影片之外的所有內容:

ffmpeg -i entrada.264.mkv -map 0 -c copy -c:v libx265 salida.265.mkv

-map 0包括從輸入到輸出的所有流,而不是依賴預設流選擇行為其中每種流類型僅包含一個流。

答案2

這不是一個錯誤。這是一條警告訊息。返回-loglevel warning訊息:

ffmpeg -i entrada.264.mkv -loglevel warning -c:v libx265 -f matroska -map 0 salida.265.mkv

-loglevel error抑制它:

ffmpeg -i entrada.264.mkv -loglevel error -c:v libx265 -f matroska -map 0 salida.265.mkv

我透過以下方式測試了我自己輸出的 mkv 檔案的所有字幕字幕編輯它們都完好無損。我認為顯示此警告只是為了在您決定稍後重新編碼這些字幕時向您發出警告。

相關內容