Fix more codec names

This commit is contained in:
Bond_009 2024-07-20 19:50:14 +02:00
parent 1e7aca8a3d
commit 406320cb98

View File

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using BDInfo;
using Jellyfin.Extensions;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo;
@ -104,7 +106,7 @@ public class BdInfoExaminer : IBlurayExaminer
BitRate = Convert.ToInt32(videoStream.BitRate),
Width = videoStream.Width,
Height = videoStream.Height,
Codec = videoStream.CodecShortName,
Codec = GetNormalizedCodec(videoStream),
IsInterlaced = videoStream.IsInterlaced,
Type = MediaStreamType.Video,
Index = index
@ -131,9 +133,10 @@ public class BdInfoExaminer : IBlurayExaminer
{
var stream = new MediaStream
{
Codec = audioStream.CodecShortName,
Codec = GetNormalizedCodec(audioStream),
Language = audioStream.LanguageCode,
Channels = audioStream.ChannelCount,
ChannelLayout = string.Format(CultureInfo.InvariantCulture, "{0:D}.{1:D}", audioStream.ChannelCount, audioStream.LFE),
Channels = audioStream.ChannelCount + audioStream.LFE,
SampleRate = audioStream.SampleRate,
Type = MediaStreamType.Audio,
Index = index
@ -146,11 +149,6 @@ public class BdInfoExaminer : IBlurayExaminer
stream.BitRate = bitrate;
}
if (audioStream.LFE > 0)
{
stream.Channels = audioStream.ChannelCount + 1;
}
streams.Add(stream);
}
@ -159,24 +157,26 @@ public class BdInfoExaminer : IBlurayExaminer
/// </summary>
/// <param name="streams">The streams.</param>
/// <param name="index">The stream index.</param>
/// <param name="textStream">The stream.</param>
private void AddSubtitleStream(List<MediaStream> streams, int index, TSStream textStream)
/// <param name="stream">The stream.</param>
private void AddSubtitleStream(List<MediaStream> streams, int index, TSStream stream)
{
streams.Add(new MediaStream
{
Language = textStream.LanguageCode,
Codec = NormalizeSubtitleCodec(textStream.StreamType),
Language = stream.LanguageCode,
Codec = GetNormalizedCodec(stream),
Type = MediaStreamType.Subtitle,
Index = index
});
}
private string NormalizeSubtitleCodec(TSStreamType codec)
=> codec switch
private string GetNormalizedCodec(TSStream stream)
=> stream.StreamType switch
{
TSStreamType.INTERACTIVE_GRAPHICS => "igs",
TSStreamType.MPEG1_VIDEO => "mpeg1video",
TSStreamType.MPEG2_VIDEO => "mpeg2video",
TSStreamType.VC1_VIDEO => "vc1",
TSStreamType.AC3_PLUS_AUDIO | TSStreamType.AC3_PLUS_SECONDARY_AUDIO => "eac3",
TSStreamType.PRESENTATION_GRAPHICS => "pgssub",
TSStreamType.SUBTITLE => "sub",
_ => throw new ArgumentOutOfRangeException(nameof(codec), $"Invalid stream type for subtitle: {codec}")
_ => stream.CodecShortName
};
}