ProbeResultNormalizerTests.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.IO;
  2. using System.Text.Json;
  3. using MediaBrowser.Common.Json;
  4. using MediaBrowser.MediaEncoding.Probing;
  5. using MediaBrowser.Model.Entities;
  6. using MediaBrowser.Model.MediaInfo;
  7. using Microsoft.Extensions.Logging.Abstractions;
  8. using Xunit;
  9. namespace Jellyfin.MediaEncoding.Tests.Probing
  10. {
  11. public class ProbeResultNormalizerTests
  12. {
  13. private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
  14. private readonly ProbeResultNormalizer _probeResultNormalizer = new ProbeResultNormalizer(new NullLogger<EncoderValidatorTests>(), null);
  15. [Fact]
  16. public void GetMediaInfo_MetaData_Success()
  17. {
  18. var bytes = File.ReadAllBytes("Test Data/Probing/some_matadata.json");
  19. var internalMediaInfoResult = JsonSerializer.Deserialize<InternalMediaInfoResult>(bytes, _jsonOptions);
  20. MediaInfo res = _probeResultNormalizer.GetMediaInfo(internalMediaInfoResult, VideoType.VideoFile, false, "Test Data/Probing/some_matadata.mkv", MediaProtocol.File);
  21. Assert.Single(res.MediaStreams);
  22. Assert.NotNull(res.VideoStream);
  23. Assert.Equal("4:3", res.VideoStream.AspectRatio);
  24. Assert.Equal(25f, res.VideoStream.AverageFrameRate);
  25. Assert.Equal(8, res.VideoStream.BitDepth);
  26. Assert.Equal(69432, res.VideoStream.BitRate);
  27. Assert.Equal("h264", res.VideoStream.Codec);
  28. Assert.Equal("1/50", res.VideoStream.CodecTimeBase);
  29. Assert.Equal(240, res.VideoStream.Height);
  30. Assert.Equal(320, res.VideoStream.Width);
  31. Assert.Equal(0, res.VideoStream.Index);
  32. Assert.False(res.VideoStream.IsAnamorphic);
  33. Assert.True(res.VideoStream.IsAVC);
  34. Assert.True(res.VideoStream.IsDefault);
  35. Assert.False(res.VideoStream.IsExternal);
  36. Assert.False(res.VideoStream.IsForced);
  37. Assert.False(res.VideoStream.IsInterlaced);
  38. Assert.False(res.VideoStream.IsTextSubtitleStream);
  39. Assert.Equal(13d, res.VideoStream.Level);
  40. Assert.Equal("4", res.VideoStream.NalLengthSize);
  41. Assert.Equal("yuv444p", res.VideoStream.PixelFormat);
  42. Assert.Equal("High 4:4:4 Predictive", res.VideoStream.Profile);
  43. Assert.Equal(25f, res.VideoStream.RealFrameRate);
  44. Assert.Equal(1, res.VideoStream.RefFrames);
  45. Assert.Equal("1/1000", res.VideoStream.TimeBase);
  46. Assert.Equal(MediaStreamType.Video, res.VideoStream.Type);
  47. Assert.Empty(res.Chapters);
  48. Assert.Equal("Just color bars", res.Overview);
  49. }
  50. }
  51. }