mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-20 13:49:44 -06:00
FF-1752: Set track title now sets video titles
This commit is contained in:
@@ -194,6 +194,11 @@ public class FfmpegBuilderSetTrackTitles: FfmpegBuilderNode
|
||||
resolution: track.Stream == null ? null : ResolutionHelper.GetResolution(track.Stream.Width, track.Stream.Height),
|
||||
dimensions: track.Stream == null ? null : track.Stream.Width + "x" + track.Stream.Height
|
||||
);
|
||||
if (originalTitle == track.Title)
|
||||
continue;
|
||||
args.Logger?.ILog($"Title changed from '{(originalTitle ?? string.Empty)}' to '{track.Title}'");
|
||||
track.ForcedChange = true;
|
||||
++changes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,10 +81,10 @@ public class FfmpegVideoStream : FfmpegStream
|
||||
{
|
||||
results.Add("-c:v:{index}");
|
||||
results.Add("copy");
|
||||
if (Title == REMOVED)
|
||||
if (string.IsNullOrWhiteSpace(Title) == false)
|
||||
{
|
||||
results.Add($"-metadata:s:v:{args.OutputTypeIndex}");
|
||||
results.Add($"title=");
|
||||
results.Add($"title={(Title == REMOVED ? "" : Title)}");
|
||||
ForcedChange = true;
|
||||
}
|
||||
return results.ToArray();
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
using FileFlows.VideoNodes.FfmpegBuilderNodes;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using VideoNodes.Tests;
|
||||
|
||||
namespace FileFlows.VideoNodes.Tests.FfmpegBuilderTests;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for track reorders
|
||||
/// Tests the set track titltes
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class FFmpegBuilder_SetTrackTtitlesTests
|
||||
public class FFmpegBuilder_SetTrackTitlesTests : VideoTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void FormatTitle_DefaultCase_Success()
|
||||
@@ -460,6 +461,62 @@ public class FFmpegBuilder_SetTrackTtitlesTests
|
||||
// Assert
|
||||
Assert.AreEqual("Track: English / HEVC / 24fps", result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FormatTitle_Custom_Variable()
|
||||
{
|
||||
// Arrange
|
||||
string formatter = "Track: lang / HDR / codec";
|
||||
string separator = " / ";
|
||||
string language = "English";
|
||||
string codec = "HEVC";
|
||||
|
||||
float fps = 23.9999997f;
|
||||
|
||||
// Act
|
||||
string result = FfmpegBuilderSetTrackTitles.FormatTitle(formatter, separator, language, codec,
|
||||
fps: fps);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Track: English / HDR / HEVC", result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests setting a track video title and actually processes the file
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void SetVideoTitle_Process()
|
||||
{
|
||||
var args = GetVideoNodeParameters(VideoMkv);
|
||||
|
||||
var vf = new VideoFile();
|
||||
vf.PreExecute(args);
|
||||
Assert.AreEqual(1, vf.Execute(args));
|
||||
|
||||
var ffStart = new FfmpegBuilderStart();
|
||||
ffStart.PreExecute(args);
|
||||
Assert.AreEqual(1, ffStart.Execute(args));
|
||||
|
||||
var ffSetTrackTitle = new FfmpegBuilderSetTrackTitles();
|
||||
ffSetTrackTitle.Format = "lang / codec / resolution / fps";
|
||||
ffSetTrackTitle.Separator = " / ";
|
||||
ffSetTrackTitle.StreamType = "Video";
|
||||
ffSetTrackTitle.PreExecute(args);
|
||||
Assert.AreEqual(1, ffSetTrackTitle.Execute(args));
|
||||
|
||||
var ffExecutor = new FfmpegBuilderExecutor();
|
||||
ffExecutor.PreExecute(args);
|
||||
Assert.AreEqual(1, ffExecutor.Execute(args));
|
||||
|
||||
Logger.ILog("Working File: " + args.WorkingFile);
|
||||
|
||||
var readVideoInfo = new ReadVideoInfo();
|
||||
readVideoInfo.PreExecute(args);
|
||||
Assert.AreEqual(1, readVideoInfo.Execute(args));
|
||||
|
||||
var videoInfo = (VideoInfo)args.Parameters["VideoInfo"];
|
||||
Assert.AreEqual("H264 / 24FPS", videoInfo.VideoStreams[0].Title);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -261,6 +261,8 @@ public class VideoInfoHelper
|
||||
vs.Codec = line.Substring(line.IndexOf("Video: ") + "Video: ".Length).Replace(",", "").Trim().Split(' ').First().ToLower();
|
||||
vs.PixelFormat = GetDecoderPixelFormat(line);
|
||||
vs.Bits = GetBitDepthFromStreamInfo(logger, info);
|
||||
if (rgxTitle.IsMatch(info))
|
||||
vs.Title = rgxTitle.Match(info).Value.Trim();
|
||||
|
||||
var dimensions = Regex.Match(line, @"([\d]{3,})x([\d]{3,})");
|
||||
if (int.TryParse(dimensions.Groups[1].Value, out int width))
|
||||
|
||||
Reference in New Issue
Block a user