From 96f8132f6e1c316b2d9fcc06fddea80f89e2c645 Mon Sep 17 00:00:00 2001 From: faush01 Date: Fri, 29 Aug 2014 16:42:56 +1000 Subject: [PATCH] make sure start and end times are different --- MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs b/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs index 09f45aa61..285eed168 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/VttWriter.cs @@ -18,7 +18,16 @@ namespace MediaBrowser.MediaEncoding.Subtitles { cancellationToken.ThrowIfCancellationRequested(); - writer.WriteLine(@"{0:hh\:mm\:ss\.fff} --> {1:hh\:mm\:ss\.fff}", TimeSpan.FromTicks(trackEvent.StartPositionTicks), TimeSpan.FromTicks(trackEvent.EndPositionTicks)); + TimeSpan startTime = TimeSpan.FromTicks(trackEvent.StartPositionTicks); + TimeSpan endTime = TimeSpan.FromTicks(trackEvent.EndPositionTicks); + + // make sure the start and end times are different and seqential + if (endTime.TotalMilliseconds <= startTime.TotalMilliseconds) + { + endTime = startTime.Add(TimeSpan.FromMilliseconds(1)); + } + + writer.WriteLine(@"{0:hh\:mm\:ss\.fff} --> {1:hh\:mm\:ss\.fff}", startTime, endTime); var text = trackEvent.Text;