From fe1c4762d214811e5f778a3cb1b9d1b9d2427b8f Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Wed, 23 Mar 2022 11:35:14 -0700 Subject: [PATCH] WithCustomArgument --- .../FileHandlers/DownloadJpegFile/FileRead.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Adaptation/FileHandlers/DownloadJpegFile/FileRead.cs b/Adaptation/FileHandlers/DownloadJpegFile/FileRead.cs index 43e0dc3..ec08683 100644 --- a/Adaptation/FileHandlers/DownloadJpegFile/FileRead.cs +++ b/Adaptation/FileHandlers/DownloadJpegFile/FileRead.cs @@ -131,16 +131,18 @@ public class FileRead : Shared.FileRead, IFileRead string fileName = $"{_CellInstanceName}_{DateTime.Now.Ticks}{_FileConnectorConfiguration.TargetFileName}"; string destFileName = Path.Combine(_FileConnectorConfiguration.TargetFileLocation, fileName); string sourceFileName = Path.Combine(_FileConnectorConfiguration.SourceFileLocation, fileName); + Uri uri = new(string.Concat("rtsp://", _StaticFileServer, '/', _FileConnectorConfiguration.SourceDirectoryCloaking)); if (!File.Exists(_FFmpegFileName)) File.WriteAllText(Path.ChangeExtension(destFileName, ".err"), $"<{_FFmpegFileName}> doesn't exits!"); else { - Uri uri = new(string.Concat("rtsp://", _StaticFileServer, '/', _FileConnectorConfiguration.SourceDirectoryCloaking)); - _ = FFMpegArguments - .FromUrlInput(uri, arg => arg.WithCustomArgument("-stimeout 3000")) - .OutputToFile(sourceFileName) - .ProcessSynchronously(throwOnError: false); - File.Move(sourceFileName, destFileName); + FFMpegArguments fFMpegArguments = FFMpegArguments.FromUrlInput(uri, arg => arg.WithCustomArgument("-timeout 1")); + FFMpegArgumentProcessor fFMpegArgumentProcessor = fFMpegArguments.OutputToFile(sourceFileName, true, arg => arg.WithCustomArgument("-frames:v 1")); + bool check = fFMpegArgumentProcessor.ProcessSynchronously(throwOnError: true); + if (check) + File.Move(sourceFileName, destFileName); + else + File.WriteAllText(Path.ChangeExtension(destFileName, ".err"), check.ToString()); } }