mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-15 16:33:25 -03:00
Return more precise transcoding reasons
Using the first profile's reason is somewhat arbitrary, as many clients' first profile may not be the most compatible one. For instance, browsers often set WebM as the first profile, which doesn’t support common codecs like H.264 and AAC by design. This causes `VideoCodecNotSupported` and `AudioCodecNotSupported` to be returned, even if the browser supports those codecs. Only use those reasons when all profiles indicate that the codec is not supported. Signed-off-by: gnattu <gnattuoc@me.com>
This commit is contained in:
@@ -1415,16 +1415,49 @@ namespace MediaBrowser.Model.Dlna
|
||||
return profileMatch;
|
||||
}
|
||||
|
||||
TranscodeReason inferredReason = 0;
|
||||
|
||||
var failureReasons = analyzedProfiles[false]
|
||||
.Select(analysis => analysis.Result)
|
||||
.Where(result => !containerSupported || (result.TranscodeReason & TranscodeReason.ContainerNotSupported) == 0)
|
||||
.FirstOrDefault().TranscodeReason;
|
||||
if (failureReasons == 0)
|
||||
.Select(result => result.TranscodeReason)
|
||||
.ToList();
|
||||
|
||||
if (failureReasons.FirstOrDefault() == 0)
|
||||
{
|
||||
failureReasons = TranscodeReason.DirectPlayError;
|
||||
inferredReason = TranscodeReason.DirectPlayError;
|
||||
}
|
||||
else
|
||||
{
|
||||
var videoCodecNotSupportedCount = failureReasons.Count(r => (r & TranscodeReason.VideoCodecNotSupported) != 0);
|
||||
var audioCodecNotSupportedCount = failureReasons.Count(r => (r & TranscodeReason.AudioCodecNotSupported) != 0);
|
||||
|
||||
if (!containerSupported)
|
||||
{
|
||||
inferredReason |= TranscodeReason.ContainerNotSupported;
|
||||
}
|
||||
|
||||
if (videoCodecNotSupportedCount == failureReasons.Count)
|
||||
{
|
||||
inferredReason |= TranscodeReason.VideoCodecNotSupported;
|
||||
}
|
||||
|
||||
if (audioCodecNotSupportedCount == failureReasons.Count)
|
||||
{
|
||||
inferredReason |= TranscodeReason.AudioCodecNotSupported;
|
||||
}
|
||||
|
||||
foreach (var transcodeReason in failureReasons)
|
||||
{
|
||||
var temp = transcodeReason;
|
||||
temp &= ~TranscodeReason.ContainerNotSupported;
|
||||
temp &= ~TranscodeReason.VideoCodecNotSupported;
|
||||
temp &= ~TranscodeReason.AudioCodecNotSupported;
|
||||
inferredReason |= temp;
|
||||
}
|
||||
}
|
||||
|
||||
return (Profile: null, PlayMethod: null, AudioStreamIndex: null, TranscodeReasons: failureReasons);
|
||||
return (Profile: null, PlayMethod: null, AudioStreamIndex: null, TranscodeReasons: inferredReason);
|
||||
}
|
||||
|
||||
private TranscodeReason CheckVideoAudioStreamDirectPlay(MediaOptions options, MediaSourceInfo mediaSource, string container, MediaStream audioStream)
|
||||
|
||||
Reference in New Issue
Block a user