Support for specyfying process working directory through FFOptions (#272)

Former-commit-id: c2d28055c1
This commit is contained in:
Malte Rosenbjerg 2021-11-01 18:13:23 +01:00
parent 8012594a81
commit 079760d044
3 changed files with 13 additions and 6 deletions

View file

@ -145,17 +145,18 @@ private bool HandleCompletion(bool throwOnError, int exitCode, IReadOnlyList<str
return exitCode == 0;
}
private Instance PrepareInstance(FFOptions ffMpegOptions,
private Instance PrepareInstance(FFOptions ffOptions,
out CancellationTokenSource cancellationTokenSource)
{
FFMpegHelper.RootExceptionCheck();
FFMpegHelper.VerifyFFMpegExists(ffMpegOptions);
FFMpegHelper.VerifyFFMpegExists(ffOptions);
var startInfo = new ProcessStartInfo
{
FileName = GlobalFFOptions.GetFFMpegBinaryPath(ffMpegOptions),
FileName = GlobalFFOptions.GetFFMpegBinaryPath(ffOptions),
Arguments = _ffMpegArguments.Text,
StandardOutputEncoding = ffMpegOptions.Encoding,
StandardErrorEncoding = ffMpegOptions.Encoding,
StandardOutputEncoding = ffOptions.Encoding,
StandardErrorEncoding = ffOptions.Encoding,
WorkingDirectory = ffOptions.WorkingDirectory
};
var instance = new Instance(startInfo);
cancellationTokenSource = new CancellationTokenSource();

View file

@ -6,6 +6,11 @@ namespace FFMpegCore
{
public class FFOptions
{
/// <summary>
/// Working directory for the ffmpeg/ffprobe instance
/// </summary>
public string WorkingDirectory { get; set; } = string.Empty;
/// <summary>
/// Folder container ffmpeg and ffprobe binaries. Leave empty if ffmpeg and ffprobe are present in PATH
/// </summary>

View file

@ -165,7 +165,8 @@ private static Instance PrepareInstance(string arguments, int outputCapacity, FF
var startInfo = new ProcessStartInfo(GlobalFFOptions.GetFFProbeBinaryPath(), arguments)
{
StandardOutputEncoding = ffOptions.Encoding,
StandardErrorEncoding = ffOptions.Encoding
StandardErrorEncoding = ffOptions.Encoding,
WorkingDirectory = ffOptions.WorkingDirectory
};
var instance = new Instance(startInfo) { DataBufferCapacity = outputCapacity };
return instance;