add b-frames option to ffmpeg profile (#1726)

* add b-frames option to ffmpeg profile

* update dependencies

* cleanup
This commit is contained in:
Jason Dove
2024-05-24 08:50:11 -05:00
committed by GitHub
parent 6dc526a817
commit 242a7ae382
28 changed files with 11497 additions and 16 deletions
+1
View File
@@ -61,6 +61,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add two new environment variables to customize config and transcode folder locations - Add two new environment variables to customize config and transcode folder locations
- `ETV_CONFIG_FOLDER` - `ETV_CONFIG_FOLDER`
- `ETV_TRANSCODE_FOLDER` - `ETV_TRANSCODE_FOLDER`
- Add checkbox to allow use of B-frames in FFmpeg Profile (disabled by default)
### Fixed ### Fixed
- Fix some cases of 404s from Plex when files were replaced and scanning the library from ETV didn't help - Fix some cases of 404s from Plex when files were replaced and scanning the library from ETV didn't help
@@ -16,6 +16,7 @@ public record CreateFFmpegProfile(
FFmpegProfileVideoFormat VideoFormat, FFmpegProfileVideoFormat VideoFormat,
string VideoProfile, string VideoProfile,
string VideoPreset, string VideoPreset,
bool AllowBFrames,
FFmpegProfileBitDepth BitDepth, FFmpegProfileBitDepth BitDepth,
int VideoBitrate, int VideoBitrate,
int VideoBufferSize, int VideoBufferSize,
@@ -56,6 +56,7 @@ public class CreateFFmpegProfileHandler :
VideoFormat = request.VideoFormat, VideoFormat = request.VideoFormat,
VideoProfile = request.VideoProfile, VideoProfile = request.VideoProfile,
VideoPreset = request.VideoPreset, VideoPreset = request.VideoPreset,
AllowBFrames = request.AllowBFrames,
BitDepth = request.BitDepth, BitDepth = request.BitDepth,
VideoBitrate = request.VideoBitrate, VideoBitrate = request.VideoBitrate,
VideoBufferSize = request.VideoBufferSize, VideoBufferSize = request.VideoBufferSize,
@@ -17,6 +17,7 @@ public record UpdateFFmpegProfile(
FFmpegProfileVideoFormat VideoFormat, FFmpegProfileVideoFormat VideoFormat,
string VideoProfile, string VideoProfile,
string VideoPreset, string VideoPreset,
bool AllowBFrames,
FFmpegProfileBitDepth BitDepth, FFmpegProfileBitDepth BitDepth,
int VideoBitrate, int VideoBitrate,
int VideoBufferSize, int VideoBufferSize,
@@ -44,6 +44,7 @@ public class
p.VideoFormat = update.VideoFormat; p.VideoFormat = update.VideoFormat;
p.VideoProfile = update.VideoProfile; p.VideoProfile = update.VideoProfile;
p.VideoPreset = update.VideoPreset; p.VideoPreset = update.VideoPreset;
p.AllowBFrames = update.AllowBFrames;
// mpeg2video only supports 8-bit content // mpeg2video only supports 8-bit content
p.BitDepth = update.VideoFormat == FFmpegProfileVideoFormat.Mpeg2Video p.BitDepth = update.VideoFormat == FFmpegProfileVideoFormat.Mpeg2Video
@@ -17,6 +17,7 @@ public record FFmpegProfileViewModel(
FFmpegProfileVideoFormat VideoFormat, FFmpegProfileVideoFormat VideoFormat,
string VideoProfile, string VideoProfile,
string VideoPreset, string VideoPreset,
bool AllowBFrames,
FFmpegProfileBitDepth BitDepth, FFmpegProfileBitDepth BitDepth,
int VideoBitrate, int VideoBitrate,
int VideoBufferSize, int VideoBufferSize,
@@ -19,6 +19,7 @@ internal static class Mapper
profile.VideoFormat, profile.VideoFormat,
profile.VideoProfile, profile.VideoProfile,
profile.VideoPreset ?? string.Empty, profile.VideoPreset ?? string.Empty,
profile.AllowBFrames,
profile.BitDepth, profile.BitDepth,
profile.VideoBitrate, profile.VideoBitrate,
profile.VideoBufferSize, profile.VideoBufferSize,
@@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48"> <PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+2
View File
@@ -17,6 +17,7 @@ public record FFmpegProfile
public FFmpegProfileVideoFormat VideoFormat { get; set; } public FFmpegProfileVideoFormat VideoFormat { get; set; }
public string VideoProfile { get; set; } public string VideoProfile { get; set; }
public string VideoPreset { get; set; } public string VideoPreset { get; set; }
public bool AllowBFrames { get; set; }
public FFmpegProfileBitDepth BitDepth { get; set; } public FFmpegProfileBitDepth BitDepth { get; set; }
public int VideoBitrate { get; set; } public int VideoBitrate { get; set; }
public int VideoBufferSize { get; set; } public int VideoBufferSize { get; set; }
@@ -39,6 +40,7 @@ public record FFmpegProfile
VideoFormat = FFmpegProfileVideoFormat.H264, VideoFormat = FFmpegProfileVideoFormat.H264,
VideoProfile = "high", VideoProfile = "high",
VideoPreset = ErsatzTV.FFmpeg.Preset.VideoPreset.Unset, VideoPreset = ErsatzTV.FFmpeg.Preset.VideoPreset.Unset,
AllowBFrames = false,
AudioFormat = FFmpegProfileAudioFormat.Aac, AudioFormat = FFmpegProfileAudioFormat.Aac,
VideoBitrate = 2000, VideoBitrate = 2000,
VideoBufferSize = 4000, VideoBufferSize = 4000,
@@ -348,6 +348,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
videoFormat, videoFormat,
maybeVideoProfile, maybeVideoProfile,
maybeVideoPreset, maybeVideoPreset,
channel.FFmpegProfile.AllowBFrames,
Optional(playbackSettings.PixelFormat), Optional(playbackSettings.PixelFormat),
scaledSize, scaledSize,
paddedSize, paddedSize,
@@ -456,6 +457,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
videoFormat, videoFormat,
GetVideoProfile(videoFormat, channel.FFmpegProfile.VideoProfile), GetVideoProfile(videoFormat, channel.FFmpegProfile.VideoProfile),
VideoPreset.Unset, VideoPreset.Unset,
channel.FFmpegProfile.AllowBFrames,
new PixelFormatYuv420P(), new PixelFormatYuv420P(),
new FrameSize(desiredResolution.Width, desiredResolution.Height), new FrameSize(desiredResolution.Width, desiredResolution.Height),
new FrameSize(desiredResolution.Width, desiredResolution.Height), new FrameSize(desiredResolution.Width, desiredResolution.Height),
@@ -682,6 +684,7 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
videoFormat, videoFormat,
maybeVideoProfile, maybeVideoProfile,
maybeVideoPreset, maybeVideoPreset,
channel.FFmpegProfile.AllowBFrames,
Optional(playbackSettings.PixelFormat), Optional(playbackSettings.PixelFormat),
resolution, resolution,
resolution, resolution,
@@ -10,7 +10,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" /> <PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="4.1.0" /> <PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" /> <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
@@ -60,6 +60,7 @@ public class PipelineBuilderBaseTests
VideoFormat.Hevc, VideoFormat.Hevc,
VideoProfile.Main, VideoProfile.Main,
VideoPreset.Unset, VideoPreset.Unset,
false,
new PixelFormatYuv420P(), new PixelFormatYuv420P(),
new FrameSize(1920, 1080), new FrameSize(1920, 1080),
new FrameSize(1920, 1080), new FrameSize(1920, 1080),
@@ -151,6 +152,7 @@ public class PipelineBuilderBaseTests
VideoFormat.Hevc, VideoFormat.Hevc,
VideoProfile.Main, VideoProfile.Main,
VideoPreset.Unset, VideoPreset.Unset,
false,
new PixelFormatYuv420P(), new PixelFormatYuv420P(),
new FrameSize(1920, 1080), new FrameSize(1920, 1080),
new FrameSize(1920, 1080), new FrameSize(1920, 1080),
@@ -298,6 +300,7 @@ public class PipelineBuilderBaseTests
VideoFormat.Copy, VideoFormat.Copy,
VideoProfile.Main, VideoProfile.Main,
VideoPreset.Unset, VideoPreset.Unset,
false,
Option<IPixelFormat>.None, Option<IPixelFormat>.None,
new FrameSize(1920, 1080), new FrameSize(1920, 1080),
new FrameSize(1920, 1080), new FrameSize(1920, 1080),
@@ -383,6 +386,7 @@ public class PipelineBuilderBaseTests
VideoFormat.Copy, VideoFormat.Copy,
VideoProfile.Main, VideoProfile.Main,
VideoPreset.Unset, VideoPreset.Unset,
false,
new PixelFormatYuv420P(), new PixelFormatYuv420P(),
new FrameSize(1920, 1080), new FrameSize(1920, 1080),
new FrameSize(1920, 1080), new FrameSize(1920, 1080),
+1
View File
@@ -8,6 +8,7 @@ public record FrameState(
string VideoFormat, string VideoFormat,
Option<string> VideoProfile, Option<string> VideoProfile,
Option<string> VideoPreset, Option<string> VideoPreset,
bool AllowBFrames,
Option<IPixelFormat> PixelFormat, Option<IPixelFormat> PixelFormat,
FrameSize ScaledSize, FrameSize ScaledSize,
FrameSize PaddedSize, FrameSize PaddedSize,
@@ -174,7 +174,7 @@ public abstract class PipelineBuilderBase : IPipelineBuilder
new ClosedGopOutputOption() new ClosedGopOutputOption()
}; };
if (desiredState.VideoFormat != VideoFormat.Copy) if (desiredState.VideoFormat != VideoFormat.Copy && !desiredState.AllowBFrames)
{ {
pipelineSteps.Add(new NoBFramesOutputOption()); pipelineSteps.Add(new NoBFramesOutputOption());
} }
@@ -16,7 +16,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.5" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
</ItemGroup> </ItemGroup>
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.MySql.Migrations
{
/// <inheritdoc />
public partial class Add_FFmpegProfile_AllowBFrames : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "AllowBFrames",
table: "FFmpegProfile",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AllowBFrames",
table: "FFmpegProfile");
}
}
}
@@ -579,6 +579,9 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id")); MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("AllowBFrames")
.HasColumnType("tinyint(1)");
b.Property<int>("AudioBitrate") b.Property<int>("AudioBitrate")
.HasColumnType("int"); .HasColumnType("int");
@@ -13,8 +13,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" /> <PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.5" />
</ItemGroup> </ItemGroup>
@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Sqlite.Migrations
{
/// <inheritdoc />
public partial class Add_FFmpegProfile_AllowBFrames : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "AllowBFrames",
table: "FFmpegProfile",
type: "INTEGER",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AllowBFrames",
table: "FFmpegProfile");
}
}
}
@@ -548,6 +548,9 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
b.Property<bool>("AllowBFrames")
.HasColumnType("INTEGER");
b.Property<int>("AudioBitrate") b.Property<int>("AudioBitrate")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@@ -10,7 +10,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" /> <PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="4.1.0" /> <PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" /> <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
@@ -18,12 +18,12 @@
<PackageReference Include="Lucene.Net" Version="4.8.0-beta00016" /> <PackageReference Include="Lucene.Net" Version="4.8.0-beta00016" />
<PackageReference Include="Lucene.Net.Analysis.Common" Version="4.8.0-beta00016" /> <PackageReference Include="Lucene.Net.Analysis.Common" Version="4.8.0-beta00016" />
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" /> <PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.5">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.5" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48"> <PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -11,7 +11,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" /> <PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="LanguageExt.Core" Version="4.4.8" /> <PackageReference Include="LanguageExt.Core" Version="4.4.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" /> <PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="4.1.0" /> <PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" /> <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
+5 -5
View File
@@ -25,11 +25,11 @@
<PackageReference Include="LanguageExt.Core" Version="4.4.8" /> <PackageReference Include="LanguageExt.Core" Version="4.4.8" />
<PackageReference Include="Markdig" Version="0.37.0" /> <PackageReference Include="Markdig" Version="0.37.0" />
<PackageReference Include="MediatR.Courier.DependencyInjection" Version="5.0.0" /> <PackageReference Include="MediatR.Courier.DependencyInjection" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.4" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.4" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.4" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.5">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
+3
View File
@@ -84,6 +84,9 @@
} }
} }
</MudSelect> </MudSelect>
<MudElement HtmlTag="div" Class="mt-3">
<MudCheckBox Label="Allow B-Frames" @bind-Value="@_model.AllowBFrames" For="@(() => _model.AllowBFrames)"/>
</MudElement>
<MudSelect Label="Bit Depth" @bind-Value="_model.BitDepth" For="@(() => _model.BitDepth)"> <MudSelect Label="Bit Depth" @bind-Value="_model.BitDepth" For="@(() => _model.BitDepth)">
<MudSelectItem Value="@FFmpegProfileBitDepth.EightBit">8-bit</MudSelectItem> <MudSelectItem Value="@FFmpegProfileBitDepth.EightBit">8-bit</MudSelectItem>
<MudSelectItem Value="@FFmpegProfileBitDepth.TenBit">10-bit</MudSelectItem> <MudSelectItem Value="@FFmpegProfileBitDepth.TenBit">10-bit</MudSelectItem>
@@ -35,6 +35,7 @@ public class FFmpegProfileEditViewModel
VideoFormat = viewModel.VideoFormat; VideoFormat = viewModel.VideoFormat;
VideoProfile = viewModel.VideoProfile; VideoProfile = viewModel.VideoProfile;
VideoPreset = viewModel.VideoPreset; VideoPreset = viewModel.VideoPreset;
AllowBFrames = viewModel.AllowBFrames;
BitDepth = viewModel.BitDepth; BitDepth = viewModel.BitDepth;
} }
@@ -60,6 +61,7 @@ public class FFmpegProfileEditViewModel
public FFmpegProfileVideoFormat VideoFormat { get; set; } public FFmpegProfileVideoFormat VideoFormat { get; set; }
public string VideoProfile { get; set; } public string VideoProfile { get; set; }
public string VideoPreset { get; set; } public string VideoPreset { get; set; }
public bool AllowBFrames { get; set; }
public FFmpegProfileBitDepth BitDepth { get; set; } public FFmpegProfileBitDepth BitDepth { get; set; }
public CreateFFmpegProfile ToCreate() => public CreateFFmpegProfile ToCreate() =>
@@ -75,6 +77,7 @@ public class FFmpegProfileEditViewModel
VideoFormat, VideoFormat,
VideoProfile, VideoProfile,
VideoPreset, VideoPreset,
AllowBFrames,
BitDepth, BitDepth,
VideoBitrate, VideoBitrate,
VideoBufferSize, VideoBufferSize,
@@ -102,6 +105,7 @@ public class FFmpegProfileEditViewModel
VideoFormat, VideoFormat,
VideoProfile, VideoProfile,
VideoPreset, VideoPreset,
AllowBFrames,
BitDepth, BitDepth,
VideoBitrate, VideoBitrate,
VideoBufferSize, VideoBufferSize,