|
|
|
@ -199,8 +199,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
|
|
|
|
|
await _ffProbeResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
var processWrapper = new ProcessWrapper(process, this);
|
|
|
|
|
|
|
|
|
|
using (var processWrapper = new ProcessWrapper(process, this))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
StartProcess(processWrapper);
|
|
|
|
@ -276,6 +276,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
{
|
|
|
|
|
_ffProbeResourcePool.Release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ApplicationException(string.Format("FFProbe failed for {0}", inputPath));
|
|
|
|
|
}
|
|
|
|
@ -307,8 +308,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
|
|
|
|
|
_logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
|
|
|
|
|
|
|
|
|
var processWrapper = new ProcessWrapper(process, this);
|
|
|
|
|
|
|
|
|
|
using (var processWrapper = new ProcessWrapper(process, this))
|
|
|
|
|
{
|
|
|
|
|
StartProcess(processWrapper);
|
|
|
|
|
|
|
|
|
|
var lines = new List<int>();
|
|
|
|
@ -333,6 +334,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
|
|
|
|
|
return lines;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task StartReadingOutput(Stream source, List<int> lines, int timeoutMs, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
@ -490,7 +492,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
|
|
|
|
|
await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
var processWrapper = new ProcessWrapper(process, this);
|
|
|
|
|
using (var processWrapper = new ProcessWrapper(process, this))
|
|
|
|
|
{
|
|
|
|
|
bool ranToCompletion;
|
|
|
|
|
|
|
|
|
|
var memoryStream = new MemoryStream();
|
|
|
|
@ -536,6 +539,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
memoryStream.Position = 0;
|
|
|
|
|
return memoryStream;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetTimeParameter(long ticks)
|
|
|
|
|
{
|
|
|
|
@ -603,8 +607,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
|
|
|
|
|
bool ranToCompletion = false;
|
|
|
|
|
|
|
|
|
|
var processWrapper = new ProcessWrapper(process, this);
|
|
|
|
|
|
|
|
|
|
using (var processWrapper = new ProcessWrapper(process, this))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
StartProcess(processWrapper);
|
|
|
|
@ -654,6 +658,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
throw new ApplicationException(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<string> EncodeAudio(EncodingJobOptions options,
|
|
|
|
|
IProgress<double> progress,
|
|
|
|
@ -781,7 +786,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class ProcessWrapper
|
|
|
|
|
private class ProcessWrapper : IDisposable
|
|
|
|
|
{
|
|
|
|
|
public readonly Process Process;
|
|
|
|
|
public bool HasExited;
|
|
|
|
@ -810,6 +815,25 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
|
|
|
|
|
process.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool _disposed;
|
|
|
|
|
private readonly object _syncLock = new object();
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
lock (_syncLock)
|
|
|
|
|
{
|
|
|
|
|
if (!_disposed)
|
|
|
|
|
{
|
|
|
|
|
if (Process != null)
|
|
|
|
|
{
|
|
|
|
|
Process.Exited -= Process_Exited;
|
|
|
|
|
Process.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_disposed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|