private void RefreshCheckBoxes(string language) { _netflixQualityController = new NetflixQualityController { Language = language, VideoFileName = _videoFileName }; checkBoxNoItalics.Checked = !_netflixQualityController.AllowItalics; checkBoxNoItalics.Enabled = !_netflixQualityController.AllowItalics; var sceneChangesExists = false; if (_netflixQualityController.VideoExists) { if (SceneChangeHelper.FromDisk(_videoFileName).Count > 0) { sceneChangesExists = true; } } checkBoxSceneChange.Checked = _netflixQualityController.VideoExists && sceneChangesExists; checkBoxSceneChange.Enabled = _netflixQualityController.VideoExists && sceneChangesExists; var checkFrameRate = _subtitleFormat.GetType() == new NetflixTimedText().GetType(); checkBoxTtmlFrameRate.Checked = checkFrameRate; checkBoxTtmlFrameRate.Enabled = checkFrameRate; checkBoxDialogHypenNoSpace.Text = !_netflixQualityController.DualSpeakersHasHyphenAndNoSpace ? "Dual Speakers: Use a hyphen with a space" : "Dual Speakers: Use a hyphen without a space"; checkBox17CharsPerSecond.Text = string.Format(LanguageSettings.Current.NetflixQualityCheck.MaximumXCharsPerSecond, _netflixQualityController.CharactersPerSecond); checkBoxMaxLineLength.Text = string.Format(LanguageSettings.Current.NetflixQualityCheck.MaximumLineLength, _netflixQualityController.SingleLineMaxLength); }
/// <summary> /// Maximum duration: 7 seconds per subtitle event /// </summary> public void Check(Subtitle subtitle, NetflixQualityController controller) { foreach (Paragraph p in subtitle.Paragraphs) { if (p.Duration.TotalMilliseconds > 7000) { var fixedParagraph = new Paragraph(p, false); fixedParagraph.Duration.TotalMilliseconds = 7000; string comment = "Maximum duration: 7 seconds per subtitle event"; controller.AddRecord(p, fixedParagraph, comment); } } }
private void RefreshCheckBoxes(string language) { _netflixQualityController = new NetflixQualityController { Language = language, VideoFileName = _videoFileName, FrameRate = _frameRate }; checkBoxNoItalics.Checked = !_netflixQualityController.AllowItalics; checkBoxNoItalics.Enabled = !_netflixQualityController.AllowItalics; int halfSecGapInFrames = (int)Math.Round(_frameRate / 2, MidpointRounding.AwayFromZero); checkBoxGapBridge.Text = $"Frame gap: 3 to {halfSecGapInFrames - 1} frames => 2 frames"; var shotChangesExist = false; if (_netflixQualityController.VideoExists) { if (ShotChangeHelper.FromDisk(_videoFileName).Count > 0) { shotChangesExist = true; } } checkBoxShotChange.Checked = shotChangesExist; checkBoxShotChange.Enabled = shotChangesExist; var checkFrameRate = _subtitleFormat.GetType() == new NetflixTimedText().GetType(); checkBoxTtmlFrameRate.Checked = checkFrameRate; checkBoxTtmlFrameRate.Enabled = checkFrameRate; var speakerStyle = _netflixQualityController.SpeakerStyle; var checkBoxSpeakerStyleText = "Dual Speakers: Use a hyphen without a space"; if (speakerStyle == DialogType.DashBothLinesWithSpace) { checkBoxSpeakerStyleText = "Dual Speakers: Use a hyphen with a space"; } else if (speakerStyle == DialogType.DashSecondLineWithSpace) { checkBoxSpeakerStyleText = "Dual Speakers: Use a hyphen with a space to denote the second speaker only"; } else if (speakerStyle == DialogType.DashSecondLineWithoutSpace) { checkBoxSpeakerStyleText = "Dual Speakers: Use a hyphen without a space to denote the second speaker only"; } checkBoxSpeakerStyle.Text = checkBoxSpeakerStyleText; checkBox17CharsPerSecond.Text = string.Format(LanguageSettings.Current.NetflixQualityCheck.MaximumXCharsPerSecond, _netflixQualityController.CharactersPerSecond); checkBoxMaxLineLength.Text = string.Format(LanguageSettings.Current.NetflixQualityCheck.MaximumLineLength, _netflixQualityController.SingleLineMaxLength); }
public void TestNetflixCheckItalicsKeep() { var sub = new Subtitle(); var p1 = new Paragraph("<i>Enginie starting</i>", 0, 1000); sub.Paragraphs.Add(p1); var controller = new NetflixQualityController { Language = "en" }; var checker = new NetflixCheckItalics(); checker.Check(sub, controller); Assert.AreEqual(0, controller.Records.Count); }
public void TestNetflixCheckItalicsFix() { var sub = new Subtitle(); var p1 = new Paragraph("</i>Enginie starting</i>", 0, 1000); sub.Paragraphs.Add(p1); var controller = new NetflixQualityController(); var checker = new NetflixCheckItalics(); checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual(controller.Records[0].OriginalParagraph, p1); Assert.AreEqual(controller.Records[0].FixedParagraph.Text, "<i>Enginie starting</i>"); }
public void TestNetflixCheckGlyph() { var sub = new Subtitle(); var p1 = new Paragraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 0, 1000); sub.Paragraphs.Add(p1); var controller = new NetflixQualityController(); var checker = new NetflixCheckGlyph(); checker.Check(sub, controller); Assert.AreEqual(2, controller.Records.Count); Assert.AreEqual("or sit amet", controller.Records[0].Context); Assert.AreEqual("ur adipisci", controller.Records[1].Context); }
private void RefreshCheckBoxes(string language) { _netflixQualityController = new NetflixQualityController { Language = language, VideoFileName = _videoFileName }; checkBoxNoItalics.Checked = !_netflixQualityController.AllowItalics; checkBoxNoItalics.Enabled = !_netflixQualityController.AllowItalics; var sceneChangesExists = false; if (_netflixQualityController.VideoExists) { if (SceneChangeHelper.FromDisk(_videoFileName).Count > 0) { sceneChangesExists = true; } } checkBoxSceneChange.Checked = _netflixQualityController.VideoExists && sceneChangesExists; checkBoxSceneChange.Enabled = _netflixQualityController.VideoExists && sceneChangesExists; var checkFrameRate = _subtitleFormat.GetType() == new NetflixTimedText().GetType(); checkBoxTtmlFrameRate.Checked = checkFrameRate; checkBoxTtmlFrameRate.Enabled = checkFrameRate; var speakerStyle = _netflixQualityController.SpeakerStyle; var checkBoxSpeakerStyleText = "Dual Speakers: Use a hyphen without a space"; if (speakerStyle == DialogType.DashBothLinesWithSpace) { checkBoxSpeakerStyleText = "Dual Speakers: Use a hyphen with a space"; } else if (speakerStyle == DialogType.DashSecondLineWithSpace) { checkBoxSpeakerStyleText = "Dual Speakers: Use a hyphen with a space to denote the second speaker only"; } else if (speakerStyle == DialogType.DashSecondLineWithoutSpace) { checkBoxSpeakerStyleText = "Dual Speakers: Use a hyphen without a space to denote the second speaker only"; } checkBoxSpeakerStyle.Text = checkBoxSpeakerStyleText; checkBox17CharsPerSecond.Text = string.Format(LanguageSettings.Current.NetflixQualityCheck.MaximumXCharsPerSecond, _netflixQualityController.CharactersPerSecond); checkBoxMaxLineLength.Text = string.Format(LanguageSettings.Current.NetflixQualityCheck.MaximumLineLength, _netflixQualityController.SingleLineMaxLength); }
/// <summary> /// Two lines maximum /// </summary> public void Check(Subtitle subtitle, NetflixQualityController controller) { foreach (Paragraph p in subtitle.Paragraphs) { if (p.Text.SplitToLines().Count > 2) { var fixedParagraph = new Paragraph(p, false); fixedParagraph.Text = Utilities.AutoBreakLine(fixedParagraph.Text, controller.SingleLineMaxLength, controller.SingleLineMaxLength - 3, controller.Language); if (fixedParagraph.Text.SplitToLines().Count > 2) { fixedParagraph = null; // cannot fix text } string comment = "Two lines maximum"; controller.AddRecord(p, fixedParagraph, comment); } } }
/// <summary> /// Two frames gap minimum /// </summary> public void Check(Subtitle subtitle, NetflixQualityController controller) { for (int index = 0; index < subtitle.Paragraphs.Count; index++) { Paragraph p = subtitle.Paragraphs[index]; var next = subtitle.GetParagraphOrDefault(index + 1); double twoFramesGap = 1000.0 / controller.FrameRate * 2.0; if (next != null && p.EndTime.TotalMilliseconds + twoFramesGap > next.StartTime.TotalMilliseconds) { var fixedParagraph = new Paragraph(p, false); fixedParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - twoFramesGap; //TODO: check for min time/speed? string comment = "Mininum two frames gap"; controller.AddRecord(p, fixedParagraph, comment); } } }
public void TestNetflixCheckMinDuration() { var sub = new Subtitle(); var p1 = new Paragraph("Lorem ipsum.", 0, 832); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem ipsum.", 0, 834); sub.Paragraphs.Add(p2); var controller = new NetflixQualityController(); var checker = new NetflixCheckMinDuration(); checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual(controller.Records[0].OriginalParagraph, p1); }
public void TestNetflixCheckNumberOfLines() { var sub = new Subtitle(); var p1 = new Paragraph("Lorem ipsum." + Environment.NewLine + "Line 2." + Environment.NewLine + "Line 3", 0, 832); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem ipsum." + Environment.NewLine + "Line 2.", 0, 832); sub.Paragraphs.Add(p2); var controller = new NetflixQualityController(); var checker = new NetflixCheckNumberOfLines(); checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual(controller.Records[0].OriginalParagraph, p1); }
public void TestNetflixCheckDialogeHyphenNoSpaceItalic() { var sub = new Subtitle(); var p1 = new Paragraph("<i>- Lorem ipsum dolor sit</i>" + Environment.NewLine + "<i>- nelit focasia venlit dokalalam dilars.</i>", 0, 4000); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem - ipsum.", 0, 1000); sub.Paragraphs.Add(p2); var controller = new NetflixQualityController(); var checker = new NetflixCheckDialogHyphenSpace(); checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual(controller.Records[0].FixedParagraph.Text, "<i>-Lorem ipsum dolor sit</i>" + Environment.NewLine + "<i>-nelit focasia venlit dokalalam dilars.</i>"); }
public void TestNetflixCheckWhiteSpace() { var sub = new Subtitle(); var p1 = new Paragraph("Lorem ipsum dolor sit amet, consectetur\r\n\r\nadipiscing\n\r\nelit.", 0, 1000); sub.Paragraphs.Add(p1); var controller = new NetflixQualityController(); var checker = new NetflixCheckWhiteSpace(); checker.Check(sub, controller); Assert.AreEqual(4, controller.Records.Count); Assert.AreEqual("Lorem ipsu", controller.Records[0].Context); Assert.AreEqual(" dolor sit", controller.Records[1].Context); Assert.AreEqual("ctetur\r\n\r\nad", controller.Records[2].Context); Assert.AreEqual("iscing\n\r\neli", controller.Records[3].Context); }
public void TestNetflixCheckMaxLineLength() { var sub = new Subtitle(); var p1 = new Paragraph("Lorem ipsum dolor sit amet lasdf lajsdf ljdsf asdf asf.", 0, 8000); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem ipsum.", 0, 7000); sub.Paragraphs.Add(p2); var controller = new NetflixQualityController(); var checker = new NetflixCheckMaxLineLength(); checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual(controller.Records[0].OriginalParagraph, p1); }
public void TestNetflixCheckMaxCps() { var sub = new Subtitle(); var p1 = new Paragraph("Lorem ipsum dolor sit amet consectetur adipiscing nelit focasia venlit dokalalam dilars.", 0, 1000); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem ipsum.", 0, 1000); sub.Paragraphs.Add(p2); var controller = new NetflixQualityController(); var checker = new NetflixCheckMaxCps(); checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual(controller.Records[0].OriginalParagraph, p1); }
public void TestNetflixCheckTwoFramesGap() { var sub = new Subtitle(); var p1 = new Paragraph("(Enginie starting)", 0, 1000); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem ipsum." + Environment.NewLine + "Line 2.", 1010, 2832); sub.Paragraphs.Add(p2); var controller = new NetflixQualityController(); var checker = new NetflixCheckTwoFramesGap(); checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual(controller.Records[0].OriginalParagraph, p1); Assert.IsTrue(controller.Records[0].FixedParagraph.EndTime.TotalMilliseconds < 1000); }
public void TestNetflixCheckTextForHiUseBrackets() { var sub = new Subtitle(); var p1 = new Paragraph("(Enginie starting)", 0, 832); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem ipsum." + Environment.NewLine + "Line 2.", 0, 832); sub.Paragraphs.Add(p2); var controller = new NetflixQualityController(); var checker = new NetflixCheckTextForHiUseBrackets(); checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual(controller.Records[0].OriginalParagraph, p1); Assert.AreEqual(controller.Records[0].FixedParagraph.Text, "[Enginie starting]"); }
public void TestNetflixCheckStartNumberSpellOut() { var sub = new Subtitle(); var p1 = new Paragraph("12 is nice!", 0, 832); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem ipsum." + Environment.NewLine + "Line 2.", 0, 832); sub.Paragraphs.Add(p2); var controller = new NetflixQualityController(); var checker = new NetflixCheckStartNumberSpellOut(); checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual(controller.Records[0].OriginalParagraph, p1); Assert.AreEqual(controller.Records[0].FixedParagraph.Text, "Twelve is nice!"); }
public void TestNetflixCheckNumbersOneToTenSpellOut() { var sub = new Subtitle(); var p1 = new Paragraph("This is 1 man", 0, 832); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem ipsum." + Environment.NewLine + "Line 2.", 0, 832); sub.Paragraphs.Add(p2); var controller = new NetflixQualityController(); var checker = new NetflixCheckNumbersOneToTenSpellOut(); checker.Check(sub, controller); Assert.AreEqual(2, controller.Records.Count); Assert.AreEqual(controller.Records[0].OriginalParagraph, p1); Assert.AreEqual(controller.Records[0].FixedParagraph.Text, "This is one man"); }
/// <summary> /// Minimum duration: 5/6 second (833 ms) - also see https://github.com/SubtitleEdit/plugins/issues/129 /// </summary> public void Check(Subtitle subtitle, NetflixQualityController controller) { for (int index = 0; index < subtitle.Paragraphs.Count; index++) { Paragraph p = subtitle.Paragraphs[index]; var next = subtitle.GetParagraphOrDefault(index + 1); if (p.Duration.TotalMilliseconds < 833) { Paragraph fixedParagraph = null; if (next == null || next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + 834) { // we can fix duration fixedParagraph = new Paragraph(p, false); fixedParagraph.Duration.TotalMilliseconds = 834; } string comment = "Minimum duration: 5/6 second (833 ms)"; controller.AddRecord(p, fixedParagraph, comment); } } }
private void RefreshCheckBoxes(string language) { _netflixQualityController = new NetflixQualityController { Language = language }; checkBoxNoItalics.Checked = !_netflixQualityController.AllowItalics; checkBoxNoItalics.Enabled = !_netflixQualityController.AllowItalics; var checkFrameRate = _subtitleFormat.GetType() == new NetflixTimedText().GetType(); checkBoxTtmlFrameRate.Checked = checkFrameRate; checkBoxTtmlFrameRate.Enabled = checkFrameRate; checkBoxDialogHypenNoSpace.Checked = _netflixQualityController.DualSpeakersHasHyphenAndNoSpace; checkBoxDialogHypenNoSpace.Enabled = _netflixQualityController.DualSpeakersHasHyphenAndNoSpace; checkBox17CharsPerSecond.Text = string.Format(Configuration.Settings.Language.NetflixQualityCheck.MaximumXCharsPerSecond, _netflixQualityController.CharactersPerSecond); checkBoxMaxLineLength.Text = string.Format(Configuration.Settings.Language.NetflixQualityCheck.MaximumLineLength, _netflixQualityController.SingleLineMaxLength); }
public void TestNetflixCheckNumberOfLines() { var sub = new Subtitle(); var p1 = new Paragraph("Lorem ipsum." + Environment.NewLine + "Line 2." + Environment.NewLine + "Line 3.", 0, 832); sub.Paragraphs.Add(p1); var p2 = new Paragraph("Lorem ipsum." + Environment.NewLine + "Line 2.", 0, 832); sub.Paragraphs.Add(p2); var p3 = new Paragraph("Lorem ipsum dolor sit amet," + Environment.NewLine + "consectetur adipiscing elit", 0, 832); sub.Paragraphs.Add(p3); var controller = new NetflixQualityController(); var checker = new NetflixCheckNumberOfLines(); checker.Check(sub, controller); Assert.AreEqual(2, controller.Records.Count); Assert.AreEqual(controller.Records[0].FixedParagraph.Text, "Lorem ipsum. Line 2. Line 3."); Assert.AreEqual(controller.Records[1].FixedParagraph.Text, "Lorem ipsum. Line 2."); }
public void TestNetflixValidFrameRates() { var sub = new Subtitle(); var template = @"<?xml version='1.0' encoding='utf-8'?> <tt xml:lang='en' xmlns='http://www.w3.org/ns/ttml' xmlns:tts='http://www.w3.org/ns/ttml#styling' xmlns:ttp='http://www.w3.org/ns/ttml#parameter' xmlns:ttm='http://www.w3.org/ns/ttml#metadata' ttp:profile='http://www.netflix.com/ns/ttml/profile/nflx-tt' ttp:frameRate='[frameRate]' ttp:frameRateMultiplier='[frameRateMultiplier]' ttp:dropMode='nonDrop' ttp:timeBase='smpte'> <head> <metadata /> </head> <body> <div xml:lang='en'> <p begin='00:00:55:01' xml:id='p0' end='00:00:58:07'> <span tts:fontStyle='italic'>Enginie starting</span> </p> </div> </body> </tt>".Replace('\'', '"'); var p1 = new Paragraph("<i>Enginie starting</i>", 0, 1000); sub.Paragraphs.Add(p1); for (int frameRate = 0; frameRate < 200; frameRate++) { var controller = new NetflixQualityController(); sub.Header = template.Replace("[frameRate]", frameRate.ToString(CultureInfo.InvariantCulture)).Replace("[frameRateMultiplier]", "1 1"); //ttp:frameRate='25' ttp:frameRateMultiplier='1000 1001' var checker = new NetflixCheckTimedTextFrameRate(); if (frameRate == 24 || frameRate == 25 || frameRate == 30 || frameRate == 50 || frameRate == 60) { checker.Check(sub, controller); Assert.AreEqual(0, controller.Records.Count); } else { checker.Check(sub, controller); Assert.AreEqual(1, controller.Records.Count); Assert.AreEqual("Frame rate is invalid", controller.Records[0].Comment); } } }
/// <summary> /// Two frames gap minimum /// </summary> public void Check(Subtitle subtitle, NetflixQualityController controller) { if (controller.Language == "ja") { return; } for (int index = 0; index < subtitle.Paragraphs.Count; index++) { Paragraph p = subtitle.Paragraphs[index]; var next = subtitle.GetParagraphOrDefault(index + 1); double twoFramesGap = 1000.0 / controller.FrameRate * 2.0; if (next != null && p.EndTime.TotalMilliseconds + twoFramesGap > next.StartTime.TotalMilliseconds) { var fixedParagraph = new Paragraph(p, false) { EndTime = { TotalMilliseconds = next.StartTime.TotalMilliseconds - twoFramesGap } }; string comment = "Minimum two frames gap"; controller.AddRecord(p, fixedParagraph, comment); } } }