use vaapi driver settings with new transcoder logic (#635)
* add LIBVA_DRIVER_NAME env var * add vaapi device name * add FFREPORT env var * fixes
This commit is contained in:
@@ -2,12 +2,14 @@
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ErsatzTV.Core.Domain;
|
||||
using ErsatzTV.Core.Domain.Filler;
|
||||
using ErsatzTV.Core.Interfaces.FFmpeg;
|
||||
using ErsatzTV.FFmpeg;
|
||||
using ErsatzTV.FFmpeg.Environment;
|
||||
using ErsatzTV.FFmpeg.Format;
|
||||
using ErsatzTV.FFmpeg.OutputFormat;
|
||||
using LanguageExt;
|
||||
@@ -122,7 +124,10 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
|
||||
: Option<string>.None;
|
||||
|
||||
var desiredState = new FrameState(
|
||||
saveReports,
|
||||
hwAccel,
|
||||
VaapiDriverName(hwAccel, vaapiDriver),
|
||||
VaapiDeviceName(hwAccel, vaapiDevice),
|
||||
playbackSettings.RealtimeOutput,
|
||||
false,
|
||||
playbackSettings.StreamSeek,
|
||||
@@ -170,7 +175,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
|
||||
public Process ConcatChannel(string ffmpegPath, bool saveReports, Channel channel, string scheme, string host)
|
||||
{
|
||||
var resolution = new FrameSize(channel.FFmpegProfile.Resolution.Width, channel.FFmpegProfile.Resolution.Height);
|
||||
var desiredState = FrameState.Concat(channel.Name, resolution);
|
||||
var desiredState = FrameState.Concat(saveReports, channel.Name, resolution);
|
||||
|
||||
var inputFiles = new List<InputFile>
|
||||
{
|
||||
@@ -218,12 +223,13 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
|
||||
|
||||
private Process GetProcess(string ffmpegPath, IList<InputFile> inputFiles, FrameState desiredState)
|
||||
{
|
||||
var pipelineBuilder = new PipelineBuilder(inputFiles, _logger);
|
||||
var pipelineBuilder = new PipelineBuilder(inputFiles, FileSystemLayout.FFmpegReportsFolder, _logger);
|
||||
|
||||
IList<IPipelineStep> pipelineSteps = pipelineBuilder.Build(desiredState);
|
||||
|
||||
_logger.LogDebug("FFmpeg pipeline {PipelineSteps}", pipelineSteps);
|
||||
_logger.LogDebug("FFmpeg pipeline {PipelineSteps}", pipelineSteps.Map(ps => ps.GetType().Name));
|
||||
|
||||
IList<EnvironmentVariable> environmentVariables = CommandGenerator.GenerateEnvironmentVariables(pipelineSteps);
|
||||
IList<string> arguments = CommandGenerator.GenerateArguments(inputFiles, pipelineSteps);
|
||||
|
||||
var startInfo = new ProcessStartInfo
|
||||
@@ -236,6 +242,16 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
|
||||
StandardOutputEncoding = Encoding.UTF8
|
||||
};
|
||||
|
||||
if (environmentVariables.Any())
|
||||
{
|
||||
_logger.LogDebug("FFmpeg environment variables {EnvVars}", environmentVariables);
|
||||
}
|
||||
|
||||
foreach ((string key, string value) in environmentVariables)
|
||||
{
|
||||
startInfo.EnvironmentVariables[key] = value;
|
||||
}
|
||||
|
||||
foreach (string argument in arguments)
|
||||
{
|
||||
startInfo.ArgumentList.Add(argument);
|
||||
@@ -246,4 +262,27 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
|
||||
StartInfo = startInfo
|
||||
};
|
||||
}
|
||||
|
||||
private static Option<string> VaapiDriverName(HardwareAccelerationMode accelerationMode, VaapiDriver driver)
|
||||
{
|
||||
if (accelerationMode == HardwareAccelerationMode.Vaapi)
|
||||
{
|
||||
switch (driver)
|
||||
{
|
||||
case VaapiDriver.i965:
|
||||
return "i965";
|
||||
case VaapiDriver.iHD:
|
||||
return "iHD";
|
||||
case VaapiDriver.RadeonSI:
|
||||
return "radeonsi";
|
||||
}
|
||||
}
|
||||
|
||||
return Option<string>.None;
|
||||
}
|
||||
|
||||
private static Option<string> VaapiDeviceName(HardwareAccelerationMode accelerationMode, string vaapiDevice)
|
||||
{
|
||||
return accelerationMode == HardwareAccelerationMode.Vaapi ? vaapiDevice : Option<string>.None;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user