1

I am trying to extract subtitle timestamps from a M2TS file using ffprobe. This does not work as expected. The M2TS file is known to contain 1001 subtitles in track 4, but I am getting about 4000 timestamps. Furthermore, those timestamps are related in a weird manner and are unsorted.

The command line I am using:

ffprobe -show_entries packet=stream_index,pts,duration -of compact=p=0:nk=1 input.m2ts > ts.txt

ts.txt then contain blocks like the following (I have inserted blank lines for readability):

4|57795041|N/A|
4|57795000|N/A|
4|57789168|N/A|
4|57789250|N/A|
4|57789250|N/A|
4|57982728|N/A|
4|57982687|N/A|
4|57982686|N/A|

4|63380621|N/A|
4|63380580|N/A|
4|63374748|N/A|
4|63374830|N/A|
4|63374830|N/A|

... and so on

Each block corresponds with one subtitle. The timestamps in a block are not sorted. The last two timestamps in a block are identical or differ by 1 tick at maximum. The timebase is 90000 ticks / s.

I am convinced that my problem is due to my lack of understanding of how ffprobe works and how subtitle timestamps are embedded in a container. Could somebody please shortly explain how to extract subtitle timestamps the correct way? I am only interested in PTS timestamps.

I then have added frame information to the output and have made it print the section and the keys:

ffprobe -show_entries packet=stream_index,pts,duration:frame -of compact input.m2ts > ts.txt

This didn't help; the following shows a sample from the output:

packet|stream_index=4|pts=76826553|duration=N/A|
packet|stream_index=4|pts=76826144|duration=N/A|
packet|stream_index=4|pts=76826143|duration=N/A|
subtitle|

Besides being more verbose, there now are additional subtitle section entries, but they don't contain data. Of course, there now also are additional frame section entries, but I didn't show them since none of them is related to subtitles.

Finally, I'd like to state that ffprobe in general seems to be an appropriate tool to extract PTS timestamps: The audio and video timestamps that I extract the same way are all correct. It's just the subtitle timestamps that impose a problem.

2
  • Does this post help ?
    – harrymc
    Commented Mar 24 at 11:46
  • Thanks a lot for the hint, but unfortunately no. SRT is text-based as far as I know, while subtitles in M2TS file are image-based. ffmpeg outputs the error message Subtitle encoding currently only possible from text to text or bitmap to bitmap when executing ffmpeg -i input.m2ts -map 0:4 output.srt. Actually, I don't need to extract the subtitles in the sense of "demuxing"; instead, I need the subtitle PTS timestamps (preferably in text form so that I can easily process them further).
    – Binarus
    Commented Mar 24 at 12:29

0

You must log in to answer this question.

Browse other questions tagged .