1

TL;DR: After cutting a video with ffmpeg, subtitles are invisible in VLC player even though there is a subtitle stream.


I have an MP4 file of a TV recording of a movie and I want to cut off the parts at the beginning and the end that belong to other programs.

The file contains one video and two audio streams (which are not causing problems) and one subtitle stream:

Stream #0:3(deu): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
Metadata:
  handler_name    : SubtitleHandler

To cut the file to my needs while keeping all of the streams, I used the -map 0 option:

ffmpeg -ss 00:06:49 -i in.mp4 -to 02:15:38 -map 0 -c copy out1.mp4

This worked pretty well and all streams are intact, however the subtitles came out somewhat misaligned, with a delay varying between zero and a couple of seconds throughout the movie. Also, ffmpeg gave me a bunch of errors of the form

[mp4 @ 0000023b9c3cb4c0] Application provided duration: -401 / timestamp: 8136600 is out of range for mov/mp4 format
[mp4 @ 0000023b9c3cb4c0] pts has no value

but the file out1.mp4 is still created and working.

I read that putting the -ss after the input is somehow more accurate, so next I tried

ffmpeg -i in.mp4 -ss 00:06:49 -to 02:22:27 -map 0 -c copy out2.mp4

Again, all streams are there (and this time without any ffmpeg errors), but now the subtitles are not showing up in VLC even when selected. Meanwhile, in Microsoft Films & TV, I can see the subtitles flashing on the screen for a split second before disappearing.

I extracted all of the subtitle files. In out1.srt, subtitles look like

8
00:00:57,204 --> 00:00:58,204
<font face="Serif" size="18">(Trinity:) Ist alles vorbereitet?</font>

9
00:00:58,205 --> 00:00:59,205
<font face="Serif" size="18">(Trinity:) Ist alles vorbereitet?</font>

so subtitles are being shown for exactly one second or multiples thereof, even though this is not consistently the case in the original file. Meanwhile, in both in.srt and out2.srt the subtitles are of the form

8
00:00:56,520 --> 00:00:56,520
<font face="Serif" size="18">(Trinity:) Ist alles vorbereitet?</font>

9
00:00:56,600 --> 00:00:56,600
<font face="Serif" size="18">(Trinity:) Ist alles vorbereitet?</font>

i.e., only to be (sometimes repeatedly) displayed for one millisecond. This would explain the flashing/not showing of subtitles when watching out2.mp4, but why is this not happening for in.mp4 and how can I prevent it altogether?

To recap:

  • in.mp4, the uncut file, has subtitles working perfectly. According to in.srt, subtitles are displayed for 1ms.
  • out1.mp4 has working subtitles, but they are a bit misaligned with varying delays. According to out1.srt, subtitles are displayed for 1s. The seemingly random misalignment is visible in the timestamps.
  • out2.mp4 has a subtitle stream that is not working. The only difference between in.srt and out2.srt is that the former contains the subtitles for the cut-out parts as well, and that, according to the timestamps, all subtitles are shifted by exactly 6min49s.

So it looks like out2.mp4 has the subtitles shifted exactly as I need them without any delays, but how do I get them to show?

0

You must log in to answer this question.

Browse other questions tagged .