mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-08 02:34:19 -04:00
Enforce HLS codec restrictions
This commit is contained in:
parent
233e079e58
commit
060097703b
@ -770,6 +770,14 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
{
|
{
|
||||||
// Prefer matching video codecs
|
// Prefer matching video codecs
|
||||||
var videoCodecs = ContainerProfile.SplitValue(videoCodec);
|
var videoCodecs = ContainerProfile.SplitValue(videoCodec);
|
||||||
|
|
||||||
|
// Enforce HLS video codec restrictions
|
||||||
|
if (string.Equals(playlistItem.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var supportedHlsVideoCodecs = new List<string> { "h264", "hevc" };
|
||||||
|
videoCodecs = videoCodecs.Where(codec => supportedHlsVideoCodecs.Contains(codec)).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
var directVideoCodec = ContainerProfile.ContainsContainer(videoCodecs, videoStream?.Codec) ? videoStream?.Codec : null;
|
var directVideoCodec = ContainerProfile.ContainsContainer(videoCodecs, videoStream?.Codec) ? videoStream?.Codec : null;
|
||||||
if (directVideoCodec != null)
|
if (directVideoCodec != null)
|
||||||
{
|
{
|
||||||
@ -805,6 +813,22 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
|
|
||||||
// Prefer matching audio codecs, could do better here
|
// Prefer matching audio codecs, could do better here
|
||||||
var audioCodecs = ContainerProfile.SplitValue(audioCodec);
|
var audioCodecs = ContainerProfile.SplitValue(audioCodec);
|
||||||
|
|
||||||
|
// Enforce HLS audio codec restrictions
|
||||||
|
if (string.Equals(playlistItem.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var supportedHlsAudioCodecs = new List<string> { "aac", "ac3", "eac3", "mp3" };
|
||||||
|
if (string.Equals(playlistItem.Container, "mp4", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// fMP4 supports more codecs than TS
|
||||||
|
supportedHlsAudioCodecs.Add("alac");
|
||||||
|
supportedHlsAudioCodecs.Add("flac");
|
||||||
|
supportedHlsAudioCodecs.Add("opus");
|
||||||
|
}
|
||||||
|
|
||||||
|
audioCodecs = audioCodecs.Where(codec => supportedHlsAudioCodecs.Contains(codec)).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
var directAudioStream = candidateAudioStreams.FirstOrDefault(stream => ContainerProfile.ContainsContainer(audioCodecs, stream.Codec));
|
var directAudioStream = candidateAudioStreams.FirstOrDefault(stream => ContainerProfile.ContainsContainer(audioCodecs, stream.Codec));
|
||||||
playlistItem.AudioCodecs = audioCodecs;
|
playlistItem.AudioCodecs = audioCodecs;
|
||||||
if (directAudioStream != null)
|
if (directAudioStream != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user