mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* add deco default filler trim to fit setting * implement trim to fit * update changelogpull/1802/head
16 changed files with 11760 additions and 4 deletions
@ -0,0 +1,121 @@
@@ -0,0 +1,121 @@
|
||||
using ErsatzTV.Core.Domain; |
||||
using ErsatzTV.Core.FFmpeg; |
||||
using ErsatzTV.Core.Interfaces.Metadata; |
||||
using ErsatzTV.Core.Interfaces.Repositories; |
||||
using ErsatzTV.Infrastructure.Scripting; |
||||
using FluentAssertions; |
||||
using Microsoft.Extensions.Logging; |
||||
using NSubstitute; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ErsatzTV.Core.Tests.FFmpeg; |
||||
|
||||
[TestFixture] |
||||
public class FFmpegStreamSelectorTests |
||||
{ |
||||
[TestFixture] |
||||
public class SelectAudioStream |
||||
{ |
||||
[Test] |
||||
public async Task Should_Select_Audio_Stream_With_Preferred_Language() |
||||
{ |
||||
// skip movie/episode script paths by using other video
|
||||
var mediaItem = new OtherVideo(); |
||||
var mediaVersion = new MediaVersion |
||||
{ |
||||
Streams = |
||||
[ |
||||
new MediaStream |
||||
{ |
||||
Index = 0, |
||||
MediaStreamKind = MediaStreamKind.Audio, |
||||
Channels = 2, |
||||
Language = "ja", |
||||
Title = "Some Title", |
||||
}, |
||||
new MediaStream |
||||
{ |
||||
Index = 1, |
||||
MediaStreamKind = MediaStreamKind.Audio, |
||||
Channels = 6, |
||||
Language = "eng", |
||||
Title = "Another Title", |
||||
Default = true |
||||
} |
||||
] |
||||
}; |
||||
|
||||
var audioVersion = new MediaItemAudioVersion(mediaItem, mediaVersion); |
||||
var channel = new Channel(Guid.NewGuid()) |
||||
{ |
||||
PreferredAudioLanguageCode = "eng" |
||||
}; |
||||
|
||||
ISearchRepository searchRepository = Substitute.For<ISearchRepository>(); |
||||
searchRepository.GetAllThreeLetterLanguageCodes(Arg.Any<List<string>>()) |
||||
.Returns(Task.FromResult(new List<string> { "jpn" })); |
||||
|
||||
var selector = new FFmpegStreamSelector( |
||||
new ScriptEngine(Substitute.For<ILogger<ScriptEngine>>()), |
||||
Substitute.For<IStreamSelectorRepository>(), |
||||
searchRepository, |
||||
Substitute.For<IConfigElementRepository>(), |
||||
Substitute.For<ILocalFileSystem>(), |
||||
Substitute.For<ILogger<FFmpegStreamSelector>>()); |
||||
|
||||
Option<MediaStream> selectedStream = await selector.SelectAudioStream(audioVersion, StreamingMode.TransportStream, channel, "jpn", "Whatever"); |
||||
selectedStream.IsSome.Should().BeTrue(); |
||||
foreach (MediaStream stream in selectedStream) |
||||
{ |
||||
stream.Language.Should().Be("ja"); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public async Task Should_Select_Subtitle_Stream_With_Preferred_Language() |
||||
{ |
||||
// skip movie/episode script paths by using other video
|
||||
var subtitles = new List<Subtitle> |
||||
{ |
||||
new() |
||||
{ |
||||
StreamIndex = 0, |
||||
SubtitleKind = SubtitleKind.Sidecar, |
||||
Language = "eng", |
||||
Default = true |
||||
}, |
||||
new() |
||||
{ |
||||
StreamIndex = 1, |
||||
SubtitleKind = SubtitleKind.Sidecar, |
||||
Language = "he", |
||||
}, |
||||
}; |
||||
|
||||
var channel = new Channel(Guid.NewGuid()); |
||||
|
||||
ISearchRepository searchRepository = Substitute.For<ISearchRepository>(); |
||||
searchRepository.GetAllThreeLetterLanguageCodes(Arg.Any<List<string>>()) |
||||
.Returns(Task.FromResult(new List<string> { "heb" })); |
||||
|
||||
var selector = new FFmpegStreamSelector( |
||||
new ScriptEngine(Substitute.For<ILogger<ScriptEngine>>()), |
||||
Substitute.For<IStreamSelectorRepository>(), |
||||
searchRepository, |
||||
Substitute.For<IConfigElementRepository>(), |
||||
Substitute.For<ILocalFileSystem>(), |
||||
Substitute.For<ILogger<FFmpegStreamSelector>>()); |
||||
|
||||
Option<Subtitle> selectedStream = await selector.SelectSubtitleStream( |
||||
subtitles, |
||||
channel, |
||||
"heb", |
||||
ChannelSubtitleMode.Any); |
||||
selectedStream.IsSome.Should().BeTrue(); |
||||
foreach (Subtitle stream in selectedStream) |
||||
{ |
||||
stream.Language.Should().Be("he"); |
||||
} |
||||
} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace ErsatzTV.Infrastructure.MySql.Migrations |
||||
{ |
||||
/// <inheritdoc />
|
||||
public partial class Add_Deco_DefaultFillerTrimToFit : Migration |
||||
{ |
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.AddColumn<bool>( |
||||
name: "DefaultFillerTrimToFit", |
||||
table: "Deco", |
||||
type: "tinyint(1)", |
||||
nullable: false, |
||||
defaultValue: false); |
||||
} |
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropColumn( |
||||
name: "DefaultFillerTrimToFit", |
||||
table: "Deco"); |
||||
} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace ErsatzTV.Infrastructure.Sqlite.Migrations |
||||
{ |
||||
/// <inheritdoc />
|
||||
public partial class Add_Deco_DefaultFillerTrimToFit : Migration |
||||
{ |
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.AddColumn<bool>( |
||||
name: "DefaultFillerTrimToFit", |
||||
table: "Deco", |
||||
type: "INTEGER", |
||||
nullable: false, |
||||
defaultValue: false); |
||||
} |
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropColumn( |
||||
name: "DefaultFillerTrimToFit", |
||||
table: "Deco"); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue