added HDR to SDR

This commit is contained in:
John Andrews
2022-04-14 21:33:15 +12:00
parent 6d883b857a
commit dd49773430
6 changed files with 70 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
namespace FileFlows.VideoNodes.FfmpegBuilderNodes
{
public class FfmpegBuilderHdrToSdr : FfmpegBuilderNode
{
public override int Outputs => 2;
public override int Execute(NodeParameters args)
{
base.Init(args);
var videoInfo = GetVideoInfo(args);
if (videoInfo == null || videoInfo.VideoStreams?.Any() != true)
return -1;
var vidStream = Model.VideoStreams?.Where(x => x.Deleted == false && x.Stream?.HDR == true).FirstOrDefault();
if (vidStream == null)
{
args.Logger.ILog("No HDR video stream found");
return 2;
}
vidStream.Filter.Add("zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p");
return 1;
}
}
}

View File

@@ -702,6 +702,32 @@ namespace FileFlows.VideoNodes.Tests.FfmpegBuilderTests
string log = logger.ToString();
Assert.AreEqual(1, result);
}
[TestMethod]
public void FfmpegBuilder_HdrToSdr()
{
const string file = @"D:\videos\unprocessed\hdr.mkv";
var logger = new TestLogger();
const string ffmpeg = @"C:\utils\ffmpeg\ffmpeg.exe";
var vi = new VideoInfoHelper(ffmpeg, logger);
var vii = vi.Read(file);
var args = new NodeParameters(file, logger, false, string.Empty);
args.GetToolPathActual = (string tool) => ffmpeg;
args.TempPath = @"D:\videos\temp";
args.Parameters.Add("VideoInfo", vii);
FfmpegBuilderStart ffStart = new();
Assert.AreEqual(1, ffStart.Execute(args));
FfmpegBuilderHdrToSdr ffHdrToSdr= new();
Assert.AreEqual(1, ffHdrToSdr.Execute(args));
FfmpegBuilderExecutor ffExecutor = new();
int result = ffExecutor.Execute(args);
string log = logger.ToString();
Assert.AreEqual(1, result);
}
}
}

View File

@@ -40,6 +40,11 @@ namespace FileFlows.VideoNodes
public string Codec { get; set; } = "";
public string IndexString { get; set; }
/// <summary>
/// Gets or sets if the stream is HDR
/// </summary>
public bool HDR { get; set; }
}
public class VideoStream : VideoFileStream

View File

@@ -223,6 +223,8 @@ namespace FileFlows.VideoNodes
logger?.ILog("Failed to read duration for VideoStream: " + info);
}
vs.HDR = info.Contains("bt2020nc") && info.Contains("smpte2084");
return vs;
}

View File

@@ -286,6 +286,14 @@
"2": "No commercials detected"
}
},
"FfmpegBuilderHdrToSdr": {
"Label": "FFMPEG Builder: HDR to SDR",
"Description": "Checks if a video stream is HDR and if it is updates the FFMPEG Builder to convert it to SDR",
"Outputs": {
"1": "HDR stream detected and updated FFMPEG Builder to convert",
"2": "No HDR stream found"
}
},
"FfmpegBuilderSubtitleFormatRemover": {
"Label": "FFMPEG Builder: Subtitle Format Remover",
"Description": "Removes subtitles from a video file if found.",

View File

@@ -65,4 +65,6 @@ doesn''t
%
eng
remux
Scaler
Scaler
SDR
HDR