ffmpeg tweaks (#121)

* save reports from ffmpeg concat process

* let ffmpeg determine thread count by default

* disable stdin for ffmpeg processes
This commit is contained in:
Jason Dove
2021-03-31 01:08:57 +00:00
committed by GitHub
parent fc33c5cd05
commit 90f775aab4
11 changed files with 1878 additions and 20 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
new()
{
Name = name,
ThreadCount = 4,
ThreadCount = 0,
Transcode = true,
ResolutionId = resolution.Id,
Resolution = resolution,
+7 -3
View File
@@ -42,6 +42,7 @@ namespace ErsatzTV.Core.FFmpeg
private readonly string _ffmpegPath;
private readonly bool _saveReports;
private FFmpegComplexFilterBuilder _complexFilterBuilder = new();
private bool _isConcat;
public FFmpegProcessBuilder(string ffmpegPath, bool saveReports)
{
@@ -186,6 +187,8 @@ namespace ErsatzTV.Core.FFmpeg
public FFmpegProcessBuilder WithConcat(string concatPlaylist)
{
_isConcat = true;
var arguments = new List<string>
{
"-f", "concat",
@@ -193,8 +196,6 @@ namespace ErsatzTV.Core.FFmpeg
"-protocol_whitelist", "file,http,tcp,https,tcp,tls",
"-probesize", "32",
"-i", concatPlaylist,
"-map", "0:v",
"-map", "0:a",
"-c", "copy",
"-muxdelay", "0",
"-muxpreload", "0"
@@ -373,10 +374,13 @@ namespace ErsatzTV.Core.FFmpeg
if (_saveReports)
{
string fileName = Path.Combine(FileSystemLayout.FFmpegReportsFolder, "%p-%t.log");
string fileName = _isConcat
? Path.Combine(FileSystemLayout.FFmpegReportsFolder, "ffmpeg-%t-concat.log")
: Path.Combine(FileSystemLayout.FFmpegReportsFolder, "ffmpeg-%t-transcode.log");
startInfo.EnvironmentVariables.Add("FFREPORT", $"file={fileName}:level=32");
}
startInfo.ArgumentList.Add("-nostdin");
foreach (string argument in _arguments)
{
startInfo.ArgumentList.Add(argument);
+2 -2
View File
@@ -124,11 +124,11 @@ namespace ErsatzTV.Core.FFmpeg
return builder.WithPipe().Build();
}
public Process ConcatChannel(string ffmpegPath, Channel channel, string scheme, string host)
public Process ConcatChannel(string ffmpegPath, bool saveReports, Channel channel, string scheme, string host)
{
FFmpegPlaybackSettings playbackSettings = _playbackSettingsCalculator.ConcatSettings;
return new FFmpegProcessBuilder(ffmpegPath, false)
return new FFmpegProcessBuilder(ffmpegPath, saveReports)
.WithThreads(1)
.WithQuiet()
.WithFormatFlags(playbackSettings.FormatFlags)