mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-15 15:48:03 +00:00
Improve ffprobe json parsing and don't log error for Codec Type attachment
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using MediaBrowser.MediaEncoding.Probing;
|
||||
using MediaBrowser.Model.IO;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.MediaEncoding.Tests
|
||||
{
|
||||
public class FFprobeParserTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("ffprobe1.json")]
|
||||
public async Task Test(string fileName)
|
||||
{
|
||||
var path = Path.Join("Test Data", fileName);
|
||||
await using (var stream = AsyncFile.OpenRead(path))
|
||||
{
|
||||
var res = await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>(stream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
Assert.NotNull(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using Jellyfin.Extensions.Json.Converters;
|
||||
using MediaBrowser.MediaEncoding.Probing;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
@@ -15,9 +16,15 @@ namespace Jellyfin.MediaEncoding.Tests.Probing
|
||||
{
|
||||
public class ProbeResultNormalizerTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
|
||||
private readonly JsonSerializerOptions _jsonOptions;
|
||||
private readonly ProbeResultNormalizer _probeResultNormalizer = new ProbeResultNormalizer(new NullLogger<EncoderValidatorTests>(), null);
|
||||
|
||||
public ProbeResultNormalizerTests()
|
||||
{
|
||||
_jsonOptions = new JsonSerializerOptions(JsonDefaults.Options);
|
||||
_jsonOptions.Converters.Add(new JsonBoolStringConverter());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("2997/125", 23.976f)]
|
||||
[InlineData("1/50", 0.02f)]
|
||||
@@ -148,6 +155,19 @@ namespace Jellyfin.MediaEncoding.Tests.Probing
|
||||
Assert.False(res.MediaStreams[5].IsHearingImpaired);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMediaInfo_TS_Success()
|
||||
{
|
||||
var bytes = File.ReadAllBytes("Test Data/Probing/video_ts.json");
|
||||
var internalMediaInfoResult = JsonSerializer.Deserialize<InternalMediaInfoResult>(bytes, _jsonOptions);
|
||||
|
||||
MediaInfo res = _probeResultNormalizer.GetMediaInfo(internalMediaInfoResult, VideoType.VideoFile, false, "Test Data/Probing/video_metadata.mkv", MediaProtocol.File);
|
||||
|
||||
Assert.Equal(2, res.MediaStreams.Count);
|
||||
|
||||
Assert.False(res.MediaStreams[0].IsAVC);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMediaInfo_ProgressiveVideoNoFieldOrder_Success()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user