mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-23 21:47:14 -04:00
Add SUPPLEMENTAL-CODECS for Dolby Vision video with fallbacks (#12605)
This commit is contained in:
parent
5a8a19e07b
commit
ced2d21f7b
1 changed files with 44 additions and 0 deletions
|
@ -304,6 +304,8 @@ public class DynamicHlsHelper
|
|||
|
||||
AppendPlaylistCodecsField(playlistBuilder, state);
|
||||
|
||||
AppendPlaylistSupplementalCodecsField(playlistBuilder, state);
|
||||
|
||||
AppendPlaylistResolutionField(playlistBuilder, state);
|
||||
|
||||
AppendPlaylistFramerateField(playlistBuilder, state);
|
||||
|
@ -406,6 +408,48 @@ public class DynamicHlsHelper
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends a SUPPLEMENTAL-CODECS field containing formatted strings of
|
||||
/// the active streams output Dolby Vision Videos.
|
||||
/// </summary>
|
||||
/// <seealso cref="AppendPlaylist(StringBuilder, StreamState, string, int, string)"/>
|
||||
/// <seealso cref="GetPlaylistVideoCodecs(StreamState, string, int)"/>
|
||||
/// <param name="builder">StringBuilder to append the field to.</param>
|
||||
/// <param name="state">StreamState of the current stream.</param>
|
||||
private void AppendPlaylistSupplementalCodecsField(StringBuilder builder, StreamState state)
|
||||
{
|
||||
// Dolby Vision currently cannot exist when transcoding
|
||||
if (!EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dvProfile = state.VideoStream.DvProfile;
|
||||
var dvLevel = state.VideoStream.DvLevel;
|
||||
var dvRangeString = state.VideoStream.VideoRangeType switch
|
||||
{
|
||||
VideoRangeType.DOVIWithHDR10 => "db1p",
|
||||
VideoRangeType.DOVIWithHLG => "db4h",
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
if (dvProfile is null || dvLevel is null || string.IsNullOrEmpty(dvRangeString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dvFourCc = string.Equals(state.ActualOutputVideoCodec, "av1", StringComparison.OrdinalIgnoreCase) ? "dav1" : "dvh1";
|
||||
builder.Append(",SUPPLEMENTAL-CODECS=\"")
|
||||
.Append(dvFourCc)
|
||||
.Append('.')
|
||||
.Append(dvProfile.Value.ToString("D2", CultureInfo.InvariantCulture))
|
||||
.Append('.')
|
||||
.Append(dvLevel.Value.ToString("D2", CultureInfo.InvariantCulture))
|
||||
.Append('/')
|
||||
.Append(dvRangeString)
|
||||
.Append('"');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends a RESOLUTION field containing the resolution of the output stream.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue