Fix "Generate scene changes" decimal point issue - thx Max :)

This commit is contained in:
Nikolaj Olsson 2018-03-30 11:05:38 +02:00
parent e2fa84b5dd
commit e6f9cf2e6a
3 changed files with 7 additions and 3 deletions

View File

@ -24,8 +24,10 @@
* Update Tesseract OCR from 3.02 to 4.0 (beta 1)
* Ctrl+a/ctrl+d/ctrl+shift+i works in more lists - thx tormento
* Remember OCR spell check dictionary for tesseract - thx raymondjpg
* Add some style support to "Modify selection"
* FIXED:
* Fix "Add to names list" in OCR spell check - thx daed-alus/Sergiy
* Fix "Generate scene changes" decimal point issue - thx Max
* Fix "Remove text for HI" issue - thx btsix
* Fix casing issue regarding "President" - thx Kolle
* Fix hashtag issue in "Fix common errors"

View File

@ -3,6 +3,7 @@ using Nikse.SubtitleEdit.Logic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
@ -18,7 +19,7 @@ namespace Nikse.SubtitleEdit.Forms
private readonly double _frameRate = 25;
private readonly string _videoFileName;
private double _lastSeconds;
private static readonly Regex TimeRegex = new Regex(@"pts_time:\d+.\d+", RegexOptions.Compiled);
private static readonly Regex TimeRegex = new Regex("pts_time:", RegexOptions.Compiled);
private bool _abort;
public ImportSceneChanges(VideoInfo videoInfo, string videoFileName)
@ -258,9 +259,9 @@ namespace Nikse.SubtitleEdit.Forms
var match = TimeRegex.Match(outLine.Data);
if (match.Success)
{
var timeCode = match.Value.Replace("pts_time:", string.Empty).Replace(",", ".");
var timeCode = match.Value.Replace("pts_time:", string.Empty).Replace(",", ".").Replace("٫", ".").Replace("⠨", ".");
double seconds;
if (double.TryParse(timeCode, out seconds) && seconds > 0.2)
if (double.TryParse(timeCode, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out seconds) && seconds > 0.2)
{
_timeCodes.AppendLine(TimeCode.FromSeconds(seconds).ToShortDisplayString());
_lastSeconds = seconds;

View File

@ -6251,6 +6251,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
msg.StartsWith("Tesseract Open Source OCR Engine", StringComparison.OrdinalIgnoreCase) ||
msg.Contains("Too few characters", StringComparison.OrdinalIgnoreCase) ||
msg.Contains("Empty page", StringComparison.OrdinalIgnoreCase) ||
msg.Contains(" diacritics", StringComparison.OrdinalIgnoreCase) ||
msg.Contains("Weak margin", StringComparison.OrdinalIgnoreCase))
{
return;