mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-21 12:49:35 -06:00
FF-1387 - added error message for moov missing
This commit is contained in:
@@ -16,6 +16,11 @@
|
||||
<Description>Plex plugin that lets you update Plex with any changes</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="i18n\*.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug'">
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.1" />
|
||||
|
||||
@@ -59,14 +59,24 @@ public class VideoFile : VideoNode
|
||||
var file = args.FileService.GetLocalPath(args.WorkingFile);
|
||||
if (file.IsFailed)
|
||||
{
|
||||
args.Logger?.ELog("Failed getting local file: " + file.Error);
|
||||
args.FailureReason = "Failed getting local file: " + file.Error;
|
||||
args.Logger?.ELog(args.FailureReason);
|
||||
return -1;
|
||||
}
|
||||
|
||||
var videoInfo = new VideoInfoHelper(FFMPEG, args.Logger).Read(file);
|
||||
var videoInfoResult = new VideoInfoHelper(FFMPEG, args.Logger).Read(file);
|
||||
if (videoInfoResult.Failed(out string error))
|
||||
{
|
||||
args.FailureReason = error;
|
||||
args.Logger?.ELog(args.FailureReason);
|
||||
return -1;
|
||||
}
|
||||
|
||||
var videoInfo = videoInfoResult.Value;
|
||||
if (videoInfo.VideoStreams.Any() == false)
|
||||
{
|
||||
args.Logger.ELog("No video streams detected.");
|
||||
args.FailureReason = "No video streams detected.";
|
||||
args.Logger?.ELog(args.FailureReason);
|
||||
return -1;
|
||||
}
|
||||
foreach (var vs in videoInfo.VideoStreams)
|
||||
|
||||
@@ -12,5 +12,5 @@ public class StaticMethods
|
||||
/// <param name="filename">the name of the file to read</param>
|
||||
/// <returns>the video info</returns>
|
||||
public static VideoInfo GetVideoInfo(NodeParameters args, string filename)
|
||||
=> VideoInfoHelper.ReadStatic(args.Logger, args.GetToolPath("FFMpeg"), filename);
|
||||
=> VideoInfoHelper.ReadStatic(args.Logger, args.GetToolPath("FFMpeg"), filename).ValueOrDefault;
|
||||
}
|
||||
@@ -40,27 +40,19 @@ public class VideoInfoHelper
|
||||
|
||||
public static string GetFFMpegPath(NodeParameters args) => args.GetToolPath("FFMpeg");
|
||||
|
||||
public VideoInfo Read(string filename)
|
||||
public Result<VideoInfo> Read(string filename)
|
||||
=> ReadStatic(Logger, ffMpegExe, filename);
|
||||
|
||||
internal static VideoInfo ReadStatic(ILogger logger, string ffMpegExe, string filename)
|
||||
internal static Result<VideoInfo> ReadStatic(ILogger logger, string ffMpegExe, string filename)
|
||||
{
|
||||
#if(DEBUG) // UNIT TESTING
|
||||
filename = filename.Replace("~/", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/");
|
||||
#endif
|
||||
|
||||
var vi = new VideoInfo();
|
||||
vi.FileName = filename;
|
||||
if (System.IO.File.Exists(filename) == false)
|
||||
{
|
||||
logger.ELog("File not found: " + filename);
|
||||
return vi;
|
||||
}
|
||||
return Result<VideoInfo>.Fail("File not found: " + filename);
|
||||
if (string.IsNullOrEmpty(ffMpegExe) || System.IO.File.Exists(ffMpegExe) == false)
|
||||
{
|
||||
logger.ELog("FFmpeg not found: " + (ffMpegExe ?? "not passed in"));
|
||||
return vi;
|
||||
}
|
||||
return Result<VideoInfo>.Fail("FFmpeg not found: " + (ffMpegExe ?? "not passed in"));
|
||||
|
||||
try
|
||||
{
|
||||
@@ -89,21 +81,27 @@ public class VideoInfoHelper
|
||||
process.WaitForExit();
|
||||
|
||||
if (string.IsNullOrEmpty(error) == false && error != "At least one output file must be specified")
|
||||
{
|
||||
logger.ELog("Failed reading ffmpeg info: " + error);
|
||||
return vi;
|
||||
}
|
||||
return Result<VideoInfo>.Fail("Failed reading ffmpeg info: " + error);
|
||||
|
||||
logger.ILog("Video Information:" + Environment.NewLine + output);
|
||||
vi = ParseOutput(logger, output);
|
||||
|
||||
if (process.ExitCode != 0)
|
||||
{
|
||||
if (output.Contains("moov atom not found"))
|
||||
return Result<VideoInfo>.Fail(
|
||||
"The video file appears to be corrupted or incomplete. (moov atom not found)");
|
||||
}
|
||||
|
||||
var vi = ParseOutput(logger, output);
|
||||
vi.FileName = filename;
|
||||
return vi;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.ELog(ex.Message, ex.StackTrace);
|
||||
return Result<VideoInfo>.Fail("Failed reading video information: " + ex.Message);
|
||||
}
|
||||
vi.FileName = filename;
|
||||
return vi;
|
||||
}
|
||||
|
||||
public static VideoInfo ParseOutput(ILogger logger, string output)
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace FileFlows.VideoNodes
|
||||
args.SetWorkingFile(outputFile);
|
||||
|
||||
// get the new video info
|
||||
var videoInfo = new VideoInfoHelper(ffmpegExe, args.Logger).Read(outputFile);
|
||||
var videoInfo = new VideoInfoHelper(ffmpegExe, args.Logger).Read(outputFile).ValueOrDefault;
|
||||
SetVideoInfo(args, videoInfo, this.Variables ?? new Dictionary<string, object>());
|
||||
}
|
||||
else if (success.successs == false)
|
||||
|
||||
@@ -42,12 +42,20 @@ namespace FileFlows.VideoNodes
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var videoInfo = new VideoInfoHelper(FFMPEG, args.Logger).Read(args.WorkingFile);
|
||||
var videoInfoResult = new VideoInfoHelper(FFMPEG, args.Logger).Read(args.WorkingFile);
|
||||
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.");
|
||||
|
||||
@@ -201,7 +201,14 @@ namespace FileFlows.VideoNodes
|
||||
return null;
|
||||
}
|
||||
|
||||
vi = new VideoInfoHelper(FFMPEG, args.Logger).Read(local);
|
||||
var viResult = new VideoInfoHelper(FFMPEG, args.Logger).Read(local);
|
||||
if (viResult.Failed(out string error))
|
||||
{
|
||||
args.Logger?.ELog(error);
|
||||
return null;
|
||||
}
|
||||
|
||||
vi = viResult.Value;
|
||||
SetVideoInfo(args, vi, Variables);
|
||||
return vi;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user