WithCustomArgument

This commit is contained in:
Mike Phares 2022-03-23 11:35:14 -07:00
parent f3f78b1d90
commit fe1c4762d2

View File

@ -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());
}
}