Debian – Copy multiple PGS subtitle tracks with FFmpeg

debianffmpegsubtitlesvideo

I'm using Debian 9. I have a file with several audio tracks and subtitles in PGS. I'd like to pass the video to h265 and keep all the audio tracks and subtitles as they are to an .mkv container, since as I understand it mp4 does not support image-based subtitles.

The command that I use is:

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

but I get this error in 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

And, wanting to copy them one at a time, simply burn the first one.

Here is the data of the file in question:

In summary:

Expected result: Recode a video file to h265 and copy all the audio and subtitles without modifying them or burn them in the video to be able to choose which one to use.

Result obtained: Error due to lack of parameters for the subtitles.

Is there a way to do it directly from ffmpeg without having to extract the subtitles one by one, and then add them to the video through some program like mkvmerge?

Best Answer

Stream copy (re-mux) everything but the video:

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

-map 0 includes all streams from the input to the output instead of relying on the default stream selection behavior which only includes one stream per stream type.

Related Question