[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #12562 and #12521 #12602

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,26 @@ public string GetVideoQualityParam(EncodingJobInfo state, string videoEncoder, E
}

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)
Expand Down
12 changes: 5 additions & 7 deletions MediaBrowser.Model/Dlna/StreamBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ private void BuildStreamVideoItem(
{
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;
Expand Down Expand Up @@ -966,15 +966,14 @@ private void BuildStreamVideoItem(

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))
{
Expand All @@ -999,15 +998,14 @@ private void BuildStreamVideoItem(

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))
{
Expand Down
Loading