mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-11 20:56:32 +00:00
improve support for compressed xmltv
This commit is contained in:
@@ -691,22 +691,26 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
param += string.Format(" -r {0}", framerate.Value.ToString(_usCulture));
|
||||
}
|
||||
|
||||
var request = state.BaseRequest;
|
||||
var targetVideoCodec = state.ActualOutputVideoCodec;
|
||||
|
||||
if (!string.IsNullOrEmpty(request.Profile))
|
||||
var request = state.BaseRequest;
|
||||
var profile = state.GetRequestedProfiles(targetVideoCodec).FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(profile))
|
||||
{
|
||||
if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// not supported by h264_omx
|
||||
param += " -profile:v " + request.Profile;
|
||||
param += " -profile:v " + profile;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(request.Level))
|
||||
var level = state.GetRequestedLevel(targetVideoCodec);
|
||||
|
||||
if (!string.IsNullOrEmpty(level))
|
||||
{
|
||||
var level = NormalizeTranscodingLevel(state.OutputVideoCodec, request.Level);
|
||||
level = NormalizeTranscodingLevel(state.OutputVideoCodec, level);
|
||||
|
||||
// h264_qsv and h264_nvenc expect levels to be expressed as a decimal. libx264 supports decimal and non-decimal format
|
||||
// also needed for libx264 due to https://trac.ffmpeg.org/ticket/3307
|
||||
@@ -756,7 +760,6 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
param += " -level " + level;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (string.Equals(videoEncoder, "libx264", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -834,18 +837,21 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
return false;
|
||||
}
|
||||
|
||||
var requestedProfiles = state.GetRequestedProfiles(videoStream.Codec);
|
||||
|
||||
// If client is requesting a specific video profile, it must match the source
|
||||
if (!string.IsNullOrEmpty(request.Profile))
|
||||
if (requestedProfiles.Length > 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(videoStream.Profile))
|
||||
{
|
||||
//return false;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(videoStream.Profile) && !string.Equals(request.Profile, videoStream.Profile, StringComparison.OrdinalIgnoreCase))
|
||||
var requestedProfile = requestedProfiles[0];
|
||||
if (!string.IsNullOrEmpty(videoStream.Profile) && !string.Equals(requestedProfile, videoStream.Profile, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var currentScore = GetVideoProfileScore(videoStream.Profile);
|
||||
var requestedScore = GetVideoProfileScore(request.Profile);
|
||||
var requestedScore = GetVideoProfileScore(requestedProfile);
|
||||
|
||||
if (currentScore == -1 || currentScore > requestedScore)
|
||||
{
|
||||
@@ -910,11 +916,12 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
}
|
||||
|
||||
// If a specific level was requested, the source must match or be less than
|
||||
if (!string.IsNullOrEmpty(request.Level))
|
||||
var level = state.GetRequestedLevel(videoStream.Codec);
|
||||
if (!string.IsNullOrEmpty(level))
|
||||
{
|
||||
double requestLevel;
|
||||
|
||||
if (double.TryParse(request.Level, NumberStyles.Any, _usCulture, out requestLevel))
|
||||
if (double.TryParse(level, NumberStyles.Any, _usCulture, out requestLevel))
|
||||
{
|
||||
if (!videoStream.Level.HasValue)
|
||||
{
|
||||
|
||||
@@ -180,6 +180,61 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
return false;
|
||||
}
|
||||
|
||||
public string[] GetRequestedProfiles(string codec)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(BaseRequest.Profile))
|
||||
{
|
||||
return BaseRequest.Profile.Split(new[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(codec))
|
||||
{
|
||||
var profile = BaseRequest.GetOption(codec, "profile");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(profile))
|
||||
{
|
||||
return profile.Split(new[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
}
|
||||
|
||||
return new string[] { };
|
||||
}
|
||||
|
||||
public string GetRequestedLevel(string codec)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(BaseRequest.Level))
|
||||
{
|
||||
return BaseRequest.Level;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(codec))
|
||||
{
|
||||
return BaseRequest.GetOption(codec, "level");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int? GetRequestedMaxRefFrames(string codec)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(BaseRequest.Level))
|
||||
{
|
||||
return BaseRequest.MaxRefFrames;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(codec))
|
||||
{
|
||||
var value = BaseRequest.GetOption(codec, "maxrefframes");
|
||||
int result;
|
||||
if (!string.IsNullOrWhiteSpace(value) && int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsVideoRequest { get; set; }
|
||||
public TranscodingJobType TranscodingType { get; set; }
|
||||
|
||||
@@ -188,7 +243,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
_logger = logger;
|
||||
TranscodingType = jobType;
|
||||
RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
PlayableStreamFileNames = new string[]{};
|
||||
PlayableStreamFileNames = new string[] { };
|
||||
SupportedAudioCodecs = new List<string>();
|
||||
SupportedVideoCodecs = new List<string>();
|
||||
SupportedSubtitleCodecs = new List<string>();
|
||||
@@ -338,12 +393,19 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
get
|
||||
{
|
||||
var stream = VideoStream;
|
||||
var request = BaseRequest;
|
||||
if (BaseRequest.Static)
|
||||
{
|
||||
return VideoStream == null ? null : VideoStream.Level;
|
||||
}
|
||||
|
||||
return !string.IsNullOrEmpty(request.Level) && !request.Static
|
||||
? double.Parse(request.Level, CultureInfo.InvariantCulture)
|
||||
: stream == null ? null : stream.Level;
|
||||
var level = GetRequestedLevel(ActualOutputVideoCodec);
|
||||
double result;
|
||||
if (!string.IsNullOrWhiteSpace(level) && double.TryParse(level, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,8 +429,12 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
get
|
||||
{
|
||||
var stream = VideoStream;
|
||||
return stream == null || !BaseRequest.Static ? null : stream.RefFrames;
|
||||
if (BaseRequest.Static)
|
||||
{
|
||||
return VideoStream == null ? null : VideoStream.RefFrames;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,10 +489,18 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
get
|
||||
{
|
||||
var stream = VideoStream;
|
||||
return !string.IsNullOrEmpty(BaseRequest.Profile) && !BaseRequest.Static
|
||||
? BaseRequest.Profile
|
||||
: stream == null ? null : stream.Profile;
|
||||
if (BaseRequest.Static)
|
||||
{
|
||||
return VideoStream == null ? null : VideoStream.Profile;
|
||||
}
|
||||
|
||||
var requestedProfile = GetRequestedProfiles(ActualOutputVideoCodec).FirstOrDefault();
|
||||
if (!string.IsNullOrWhiteSpace(requestedProfile))
|
||||
{
|
||||
return requestedProfile;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Services;
|
||||
|
||||
@@ -39,18 +40,16 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
MaxWidth = info.MaxWidth;
|
||||
MaxHeight = info.MaxHeight;
|
||||
MaxFramerate = info.MaxFramerate;
|
||||
Profile = info.VideoProfile;
|
||||
ItemId = info.ItemId;
|
||||
MediaSourceId = info.MediaSourceId;
|
||||
AudioCodec = info.TargetAudioCodec;
|
||||
AudioCodec = info.TargetAudioCodec.FirstOrDefault();
|
||||
MaxAudioChannels = info.MaxAudioChannels;
|
||||
AudioBitRate = info.AudioBitrate;
|
||||
AudioSampleRate = info.TargetAudioSampleRate;
|
||||
DeviceProfile = deviceProfile;
|
||||
VideoCodec = info.TargetVideoCodec;
|
||||
VideoCodec = info.TargetVideoCodec.FirstOrDefault();
|
||||
VideoBitRate = info.VideoBitrate;
|
||||
AudioStreamIndex = info.AudioStreamIndex;
|
||||
MaxRefFrames = info.MaxRefFrames;
|
||||
MaxVideoBitDepth = info.MaxVideoBitDepth;
|
||||
SubtitleMethod = info.SubtitleDeliveryMethod;
|
||||
Context = info.Context;
|
||||
@@ -60,11 +59,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
SubtitleStreamIndex = info.SubtitleStreamIndex;
|
||||
}
|
||||
|
||||
if (info.VideoLevel.HasValue)
|
||||
{
|
||||
Level = info.VideoLevel.Value.ToString(_usCulture);
|
||||
}
|
||||
StreamOptions = info.StreamOptions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +226,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
SetOption(qualifier + "-" + name, value);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> StreamOptions { get; private set; }
|
||||
public Dictionary<string, string> StreamOptions { get; set; }
|
||||
|
||||
public void SetOption(string name, string value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user