FF-273 - added auto crop image node

fixed issue with mp4 image based subtitles
This commit is contained in:
John Andrews
2022-08-09 11:24:07 +12:00
parent 1131d6be72
commit e6813b8e23
10 changed files with 215 additions and 39 deletions

View File

@@ -25,7 +25,14 @@
break;
case "mp4":
{
results.Add("mov_text");
if (Helpers.SubtitleHelper.IsImageSubtitle(Stream.Codec))
{
results.Add("copy");
}
else
{
results.Add("mov_text");
}
}
break;
default:

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileFlows.VideoNodes.Helpers;
/// <summary>
/// Helper for Subtitles
/// </summary>
internal class SubtitleHelper
{
/// <summary>
/// Tests if a subtitle is an image based subtitle
/// </summary>
/// <param name="codec">the subtitle codec</param>
/// <returns>true if the subtitle is an image based subtitle</returns>
internal static bool IsImageSubtitle(string codec)
=> Regex.IsMatch(codec.Replace("_", ""), "dvbsub|dvdsub|pgs|xsub", RegexOptions.IgnoreCase);
}

View File

@@ -277,7 +277,9 @@ namespace FileFlows.VideoNodes
audio.Title = "";
// this isnt type index, this is overall index
audio.TypeIndex = int.Parse(Regex.Match(line, @"#([\d]+):([\d]+)").Groups[2].Value) - 1;
audio.Codec = parts[0].Substring(parts[0].IndexOf("Audio: ") + "Audio: ".Length).Trim().Split(' ').First().ToLower() ?? "";
audio.Codec = parts[0].Substring(parts[0].IndexOf("Audio: ") + "Audio: ".Length).Trim().Split(' ').First().ToLower() ?? string.Empty;
if (audio.Codec.EndsWith(","))
audio.Codec = audio.Codec[..^1].Trim();
audio.Language = GetLanguage(line);
if (info.IndexOf("0 channels") >= 0)
@@ -336,6 +338,8 @@ namespace FileFlows.VideoNodes
SubtitleStream sub = new SubtitleStream();
sub.TypeIndex = int.Parse(Regex.Match(line, @"#([\d]+):([\d]+)").Groups[2].Value);
sub.Codec = line.Substring(line.IndexOf("Subtitle: ") + "Subtitle: ".Length).Trim().Split(' ').First().ToLower();
if (sub.Codec.EndsWith(","))
sub.Codec = sub.Codec[..^1].Trim();
sub.Language = GetLanguage(line);
if (rgxTitle.IsMatch(info))