Author Topic: .SRT to .SSA parsing bug?  (Read 917 times)

NovicED

  • Newbie
  • *
  • Posts: 5
.SRT to .SSA parsing bug?
« on: December 24, 2018, 01:11:11 AM »
Using Avidemux 2.7.1-181128

Tried to load existing .SRT subtitle file only to find it created an empty .SSA file.
Traced the problem to the timestamp format which was:

##:##:##.###

The SSA converter in Avidemux appears to only accept:

##:##:##,###

To verify I manually edited the first few entries and those then worked.

The player in Win10 recognizes either time format and properly
Avidemux should too.

NovicED

  • Newbie
  • *
  • Posts: 5
Re: .SRT to .SSA parsing bug?
« Reply #1 on: December 24, 2018, 03:55:14 AM »
I was able to edit the SRT file but now there is a greater problem.  When trying to burn the subtitles
into the video, the text is delayed by about 4 seconds.  This shows up in both preview mode and
saved video.  Is this another bug - or something technical Avidemux has difficulty achieving?

 

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3461
Re: .SRT to .SSA parsing bug?
« Reply #2 on: December 24, 2018, 10:11:46 AM »
Quote
The SSA converter in Avidemux appears to only accept:

##:##:##,###

Yes, the correct decimal separator for timestamps in .srt is a comma, so this is strictly speaking not a bug but adherence to specifications.

Quote
When trying to burn the subtitles into the video, the text is delayed by about 4 seconds.  This shows up in both preview mode and saved video.

Did you verify the subtitle file with Aegisub? What is the presentation timestamp (PTS) of the first frame of this particular video in Avidemux?

NovicED

  • Newbie
  • *
  • Posts: 5
Re: .SRT to .SSA parsing bug?
« Reply #3 on: December 28, 2018, 07:00:24 AM »
Quote
The SSA converter in Avidemux appears to only accept:

##:##:##,###

Yes, the correct decimal separator for timestamps in .srt is a comma, so this is strictly speaking not a bug but adherence to specifications.

Now that other sub editors (apparently) and players are accepting either '.'  or ',' it's something tools
like Avidemux can't really afford ignore.  I've since d/loaded Aegisub and notice it doesn't like '.' either.

Quote
Quote
When trying to burn the subtitles into the video, the text is delayed by about 4 seconds.  This shows up in both preview mode and saved video.

Did you verify the subtitle file with Aegisub? What is the presentation timestamp (PTS) of the first frame of this particular video in Avidemux?

Aegisub shows no obvious problem (after I'd converted the '.' the ',') other than CPS warnings.

How do I find the PTS and how might this affect the subttl sync?  Sorry but I'm new to video editing.
« Last Edit: December 28, 2018, 07:31:08 AM by eumagga0x2a »

eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3461
Re: .SRT to .SSA parsing bug?
« Reply #4 on: December 28, 2018, 07:43:59 AM »
I've fixed quote tags for better legibility.

How do I find the PTS and how might this affect the subttl sync?

Avidemux uses unsigned values to store timestamps (both decode and presentation) of video frames. If a video contains B-frames (frames which require more than a single one previously decoded frame for being decoded, with at least one of these reference frames displayed later), presentation times of all frames have to be delayed as timestamps can't go negative.

Another reason for differing timestamps might be audio shift (advancing audio WRT video = delaying video). This means, whoever created the original .srt, might have used a tool which doesn't agree with Avidemux about timing in the video. Usually this disagreement is very small, but sometimes it is not.

The PTS of the first frame is the time shown in the bottom left corner of Avidemux right when you load a video.

NovicED

  • Newbie
  • *
  • Posts: 5
Re: .SRT to .SSA parsing bug?
« Reply #5 on: January 06, 2019, 03:59:41 AM »
Sorry for the delay replying and thanks for the explanation.  Checked the videos
I'm using for testing and the PTS shown varies from 0 to under 1 second.

I've created my own SRT file for testing:

1
00:00:02,500 --> 00:00:05,000
Subtitle 1:  2.500 to 5.000 seconds.

2
00:00:10,000 --> 00:00:15,000
Subtitle 2:  10.000 to 15.000 seconds.

3
00:00:20,500 --> 00:00:25,000
Subtitle 3:  20.500 to 25.000 seconds.

4
00:00:30,000 --> 00:00:35,000
Subtitle 4:  30.000 to 35.000 seconds.

Avidemux converts all the SRT entries to SSA format:

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:02.500,0:00:05.000,Default,,0000,0000,0000,,Subtitle 1:  2.500 to 5.000 seconds.
Dialogue: 0,0:00:10.000,0:00:15.000,Default,,0000,0000,0000,,Subtitle 2:  10.000 to 15.000 seconds.
Dialogue: 0,0:00:20.500,0:00:25.000,Default,,0000,0000,0000,,Subtitle 3:  20.500 to 25.000 seconds.
Dialogue: 0,0:00:30.000,0:00:35.000,Default,,0000,0000,0000,,Subtitle 4:  30.000 to 35.000 seconds.

However when I 'preview' the output I see only subtitles 2 & 4 (at the correct timestamp).  Subtitles
not beginning on an integral number of seconds are not processed at all.  Tried it on two videos with
the same result.

p.s. I ended up hard coding the subtitles by capturing Win10 videoplayer output.  Nevertheless I'd
still like to sort out what is the issue with Avidemux' handling of subtitles.


eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3461
Re: .SRT to .SSA parsing bug?
« Reply #6 on: January 06, 2019, 01:44:45 PM »
The supported time format is xx:xx:xx.xx, NOT xx:xx:xx.xxx. WFM with unflawed time format, see attached .ssa file.

NovicED

  • Newbie
  • *
  • Posts: 5
Re: .SRT to .SSA parsing bug?
« Reply #7 on: January 08, 2019, 05:53:34 AM »
The supported time format is xx:xx:xx.xx, NOT xx:xx:xx.xxx. WFM with unflawed time format, see attached .ssa file.

That may explain the 'delay' I was initially getting i.e. Avidemux interpreting the
illegal numeric string in the SSA file and possibly producing a different time.

Given SRT format specifies 3 decimal digits, Avidemux SRT/SSA converter should
properly convert it to 2 decimal SSA format - but doesn't.  Strange the bug hasn't
been noticed before this and squashed.

I now have enough info to proceed.  Thanks for pinning down the problem.


eumagga0x2a

  • Moderator
  • Hero Member
  • *****
  • Posts: 3461
Re: .SRT to .SSA parsing bug?
« Reply #8 on: January 08, 2019, 02:03:57 PM »