Skip to content

Commit

Permalink
Fix for ffprobe and HDR10 - thx warrentc3 :)
Browse files Browse the repository at this point in the history
Fix #9097
  • Loading branch information
niksedk committed Dec 17, 2024
1 parent 557ce35 commit 8a34674
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/ui/Logic/TimeCodesGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Nikse.SubtitleEdit.Core.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
Expand Down Expand Up @@ -47,7 +46,7 @@ public Process GetProcess(string videoFileName)
StartInfo =
{
FileName = ffProbePath,
Arguments = $"-select_streams v -show_frames -show_entries frame=pkt_dts_time -of csv -threads 0 \"{videoFileName}\"",
Arguments = $"-select_streams v -show_frames -show_entries frame=pkt_dts_time -of csv \"{videoFileName}\"",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
Expand All @@ -71,19 +70,14 @@ private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
return;
}

if (!line.StartsWith("frame,") || line.Contains("N/A"))
var arr = line.Split(',');
if (arr.Length < 2 || arr[0] != "frame")
{
return;
}

var timeString = line.Replace("frame,", "").Trim();
if (timeString.Contains("side_data"))
{
timeString = timeString.Substring(0, timeString.IndexOf("side_data", StringComparison.Ordinal)).TrimEnd(',');
}

var timeCode = timeString.Replace(",", ".").Replace("٫", ".").Replace("⠨", ".");
if (double.TryParse(timeCode, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var seconds))
var timeString = arr[1].Trim().Replace("⠨", ".");
if (double.TryParse(timeString, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var seconds))
{
lock (TimeCodesLock)
{
Expand Down

0 comments on commit 8a34674

Please sign in to comment.