diff --git a/VideoNodes/VideoNodes/ReadVideoInfo.cs b/VideoNodes/VideoNodes/ReadVideoInfo.cs index 22b30b22..647cb156 100644 --- a/VideoNodes/VideoNodes/ReadVideoInfo.cs +++ b/VideoNodes/VideoNodes/ReadVideoInfo.cs @@ -1,93 +1,104 @@ -namespace FileFlows.VideoNodes +namespace FileFlows.VideoNodes; + +/// +/// A flow element that reads the video information for the current working file +/// +public class ReadVideoInfo: EncodingNode { - using FileFlows.Plugin; + /// + public override string Icon => "fas fa-video"; + /// + public override int Outputs => 2; + /// + public override FlowElementType Type => FlowElementType.Logic; + /// + public override string HelpUrl => "https://fileflows.com/docs/plugins/video-nodes/read-video-info"; - public class ReadVideoInfo: EncodingNode + private Dictionary _Variables; + /// + public override Dictionary Variables => _Variables; + + + + /// + /// Constructs and instance of the flow element + /// + public ReadVideoInfo() { - public override string Icon => "fas fa-video"; - public override int Outputs => 2; - - public override FlowElementType Type => FlowElementType.Logic; - - private Dictionary _Variables; - public override Dictionary Variables => _Variables; - public ReadVideoInfo() + _Variables = new Dictionary() { - _Variables = new Dictionary() - { - { "vi.Video.Codec", "hevc" }, - { "vi.Audio.Codec", "ac3" }, - { "vi.Audio.Codecs", "ac3,aac"}, - { "vi.Audio.Language", "eng" }, - { "vi.Audio.Languages", "eng, mao" }, - { "vi.Resolution", "1080p" }, - { "vi.Duration", 1800 }, - { "vi.VideoInfo", new VideoInfo() + { "vi.Video.Codec", "hevc" }, + { "vi.Audio.Codec", "ac3" }, + { "vi.Audio.Codecs", "ac3,aac"}, + { "vi.Audio.Language", "eng" }, + { "vi.Audio.Languages", "eng, mao" }, + { "vi.Resolution", "1080p" }, + { "vi.Duration", 1800 }, + { "vi.VideoInfo", new VideoInfo() + { + Bitrate = 10_000_000, + VideoStreams = new List { + new VideoStream { } + }, + AudioStreams = new List { + new AudioStream { } + }, + SubtitleStreams = new List { - Bitrate = 10_000_000, - VideoStreams = new List { - new VideoStream { } - }, - AudioStreams = new List { - new AudioStream { } - }, - SubtitleStreams = new List - { - new SubtitleStream { } - } + new SubtitleStream { } } - }, - { "vi.Width", 1920 }, - { "vi.Height", 1080 }, - }; - } + } + }, + { "vi.Width", 1920 }, + { "vi.Height", 1080 }, + }; + } - /// - public override int Execute(NodeParameters args) + /// + public override int Execute(NodeParameters args) + { + try { - try + var localFileResult = args.FileService.GetLocalPath(args.WorkingFile); + if (localFileResult.Failed(out string lfError)) { - var localFileResult = args.FileService.GetLocalPath(args.WorkingFile); - if (localFileResult.Failed(out string lfError)) - { - args.FailureReason = "Failed getting local file: " + lfError; - args.Logger.ILog(args.FailureReason); - return -1; - } - - var videoInfoResult = new VideoInfoHelper(FFMPEG, args.Logger).Read(localFileResult.Value); - if (videoInfoResult.Failed(out string error)) - { - args.Logger.ELog(error); - return 2; - } - - var videoInfo = videoInfoResult.Value; - if (videoInfo.VideoStreams.Any() == false) - { - args.Logger.ILog("No video streams detected."); - return 2; - } - foreach (var vs in videoInfo.VideoStreams) - { - args.Logger.ILog($"Video stream '{vs.Codec}' '{vs.Index}'"); - } - - - foreach (var vs in videoInfo.AudioStreams) - { - args.Logger.ILog($"Audio stream '{vs.Codec}' '{vs.Index}' 'Language: {vs.Language}' 'Channels: {vs.Channels}'"); - } - - SetVideoInfo(args, videoInfo, Variables); - - return 1; + args.FailureReason = "Failed getting local file: " + lfError; + args.Logger.ILog(args.FailureReason); + return -1; } - catch (Exception ex) + + var videoInfoResult = new VideoInfoHelper(FFMPEG, args.Logger).Read(localFileResult.Value); + if (videoInfoResult.Failed(out string error)) { - args.Logger.WLog("Failed processing VideoFile: " + ex.Message); + args.Logger.ELog(error); return 2; } + + var videoInfo = videoInfoResult.Value; + if (videoInfo.VideoStreams.Any() == false) + { + args.Logger.ILog("No video streams detected."); + return 2; + } + foreach (var vs in videoInfo.VideoStreams) + { + args.Logger.ILog($"Video stream '{vs.Codec}' '{vs.Index}'"); + } + + + foreach (var vs in videoInfo.AudioStreams) + { + args.Logger.ILog($"Audio stream '{vs.Codec}' '{vs.Index}' 'Language: {vs.Language}' 'Channels: {vs.Channels}'"); + } + + SetVideoInfo(args, videoInfo, Variables); + + return 1; + } + catch (Exception ex) + { + args.Logger.WLog("Failed processing VideoFile: " + ex.Message); + return 2; } } } \ No newline at end of file