FF-2024: forcing encode if remux is needed

This commit is contained in:
John Andrews
2025-02-01 09:03:26 +13:00
parent f5e80f4474
commit 1067a8ad28
6 changed files with 46 additions and 14 deletions

View File

@@ -135,17 +135,15 @@
Codec = item.stream.Codec
});
}
if(info.FileName.ToLower().EndsWith(".mp4"))
model.Extension = info.FileName[(info.FileName.LastIndexOf(".", StringComparison.Ordinal) + 1)..];
else if (info.FileName.ToLower().EndsWith(".mkv"))
model.Extension = info.FileName[(info.FileName.LastIndexOf(".", StringComparison.Ordinal) + 1)..];
else if (info.FileName.ToLower().EndsWith(".mov"))
model.Extension = info.FileName[(info.FileName.LastIndexOf(".", StringComparison.Ordinal) + 1)..];
else if (info.FileName.ToLower().EndsWith(".mxf"))
model.Extension = info.FileName[(info.FileName.LastIndexOf(".", StringComparison.Ordinal) + 1)..];
else if (info.FileName.ToLower().EndsWith(".webm"))
model.Extension = info.FileName[(info.FileName.LastIndexOf(".", StringComparison.Ordinal) + 1)..];
foreach (var ext in new[] { "mp4", "mkv", "mov", "mxf", "webm" })
{
if (info.FileName.EndsWith("." + ext, StringComparison.OrdinalIgnoreCase))
{
model.Extension = ext;
break;
}
}
return model;
}

View File

@@ -5,9 +5,7 @@
/// </summary>
public class FfmpegBuilderRemuxToMP4: FfmpegBuilderNode
{
/// <summary>
/// Gets the help URL for this flow element
/// </summary>
/// <inheritdoc />
public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/ffmpeg-builder/remux-to-mp4";
/// <summary>
@@ -22,8 +20,15 @@ public class FfmpegBuilderRemuxToMP4: FfmpegBuilderNode
/// </summary>
[Boolean(1)] public bool UseHvc1 { get; set; }
/// <inheritdoc />
public override int Execute(NodeParameters args)
{
if (this.Model.Extension?.ToLowerInvariant() != "mp4")
{
args.Logger?.ILog($"Needs remuxing from '{this.Model.Extension}' to 'mp4', forcing encode");
this.Model.ForceEncode = true;
}
this.Model.Extension = "mp4";
if (UseHvc1)
{

View File

@@ -4,10 +4,18 @@ public class FfmpegBuilderRemuxToMkv : FfmpegBuilderNode
{
/// <inheritdoc />
public override string Icon => "svg:mkv";
/// <inheritdoc />
public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/ffmpeg-builder/remux-to-mkv";
/// <inheritdoc />
public override int Execute(NodeParameters args)
{
if (this.Model.Extension?.ToLowerInvariant() != "mkv")
{
args.Logger?.ILog($"Needs remuxing from '{this.Model.Extension}' to 'mkv', forcing encode");
this.Model.ForceEncode = true;
}
this.Model.Extension = "mkv";
return 1;
}

View File

@@ -7,8 +7,14 @@ public class FfmpegBuilderRemuxToMov : FfmpegBuilderNode
/// <inheritdoc />
public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/ffmpeg-builder/remux-to-mov";
/// <inheritdoc />
public override int Execute(NodeParameters args)
{
if (this.Model.Extension?.ToLowerInvariant() != "mov")
{
args.Logger?.ILog($"Needs remuxing from '{this.Model.Extension}' to 'mov', forcing encode");
this.Model.ForceEncode = true;
}
this.Model.Extension = "mov";
return 1;
}

View File

@@ -21,6 +21,11 @@ public class FfmpegBuilderRemuxToMxf : FfmpegBuilderNode
/// <inheritdoc />
public override int Execute(NodeParameters args)
{
if (this.Model.Extension?.ToLowerInvariant() != "mxf")
{
args.Logger?.ILog($"Needs remuxing from '{this.Model.Extension}' to 'mxf', forcing encode");
this.Model.ForceEncode = true;
}
this.Model.Extension = "mxf";
return 1;
}

View File

@@ -1,13 +1,23 @@
namespace FileFlows.VideoNodes.FfmpegBuilderNodes;
/// <summary>
/// Remuxes a file to webm
/// </summary>
public class FfmpegBuilderRemuxToWebm : FfmpegBuilderNode
{
/// <inheritdoc />
public override string Icon => "svg:webm";
/// <inheritdoc />
public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/ffmpeg-builder/remux-to-webm";
/// <inheritdoc />
public override int Execute(NodeParameters args)
{
if (this.Model.Extension?.ToLowerInvariant() != "webm")
{
args.Logger?.ILog($"Needs remuxing from '{this.Model.Extension}' to 'webm', forcing encode");
this.Model.ForceEncode = true;
}
this.Model.Extension = "webm";
return 1;
}