Co-authored-by: Dmitry Lyzo <56478732+dmitrylyzo@users.noreply.github.com>
Co-authored-by: Nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
gnattu 2024-09-08 01:21:14 +08:00 committed by GitHub
parent 5d4f71eb9a
commit df00909b85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 8 deletions

View File

@ -1914,7 +1914,26 @@ namespace MediaBrowser.Controller.MediaEncoding
}
var profile = state.GetRequestedProfiles(targetVideoCodec).FirstOrDefault() ?? string.Empty;
profile = WhiteSpaceRegex().Replace(profile, string.Empty);
profile = WhiteSpaceRegex().Replace(profile, string.Empty).ToLowerInvariant();
var videoProfiles = Array.Empty<string>();
if (string.Equals("h264", targetVideoCodec, StringComparison.OrdinalIgnoreCase))
{
videoProfiles = _videoProfilesH264;
}
else if (string.Equals("hevc", targetVideoCodec, StringComparison.OrdinalIgnoreCase))
{
videoProfiles = _videoProfilesH265;
}
else if (string.Equals("av1", targetVideoCodec, StringComparison.OrdinalIgnoreCase))
{
videoProfiles = _videoProfilesAv1;
}
if (!videoProfiles.Contains(profile, StringComparison.OrdinalIgnoreCase))
{
profile = string.Empty;
}
// We only transcode to HEVC 8-bit for now, force Main Profile.
if (profile.Contains("main10", StringComparison.OrdinalIgnoreCase)

View File

@ -925,7 +925,7 @@ namespace MediaBrowser.Model.Dlna
{
audioStream = directAudioStream;
playlistItem.AudioStreamIndex = audioStream.Index;
playlistItem.AudioCodecs = new[] { audioStream.Codec };
playlistItem.AudioCodecs = audioCodecs = new[] { audioStream.Codec };
// Copy matching audio codec options
playlistItem.AudioSampleRate = audioStream.SampleRate;
@ -966,15 +966,14 @@ namespace MediaBrowser.Model.Dlna
var appliedVideoConditions = options.Profile.CodecProfiles
.Where(i => i.Type == CodecType.Video &&
i.ContainsAnyCodec(videoStream?.Codec, container, useSubContainer) &&
i.ContainsAnyCodec(videoCodecs, container, useSubContainer) &&
i.ApplyConditions.All(applyCondition => ConditionProcessor.IsVideoConditionSatisfied(applyCondition, width, height, bitDepth, videoBitrate, videoProfile, videoRangeType, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isInterlaced, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc)))
// Reverse codec profiles for backward compatibility - first codec profile has higher priority
.Reverse();
foreach (var i in appliedVideoConditions)
{
var transcodingVideoCodecs = ContainerProfile.SplitValue(videoCodec);
foreach (var transcodingVideoCodec in transcodingVideoCodecs)
foreach (var transcodingVideoCodec in videoCodecs)
{
if (i.ContainsAnyCodec(transcodingVideoCodec, container, useSubContainer))
{
@ -999,15 +998,14 @@ namespace MediaBrowser.Model.Dlna
var appliedAudioConditions = options.Profile.CodecProfiles
.Where(i => i.Type == CodecType.VideoAudio &&
i.ContainsAnyCodec(audioStream?.Codec, container) &&
i.ContainsAnyCodec(audioCodecs, container) &&
i.ApplyConditions.All(applyCondition => ConditionProcessor.IsVideoAudioConditionSatisfied(applyCondition, audioChannels, inputAudioBitrate, inputAudioSampleRate, inputAudioBitDepth, audioProfile, isSecondaryAudio)))
// Reverse codec profiles for backward compatibility - first codec profile has higher priority
.Reverse();
foreach (var codecProfile in appliedAudioConditions)
{
var transcodingAudioCodecs = ContainerProfile.SplitValue(audioCodec);
foreach (var transcodingAudioCodec in transcodingAudioCodecs)
foreach (var transcodingAudioCodec in audioCodecs)
{
if (codecProfile.ContainsAnyCodec(transcodingAudioCodec, container))
{