mirror of https://github.com/jellyfin/jellyfin.git
reduce AnalyzeDurationMs for live tv
This commit is contained in:
parent
8b77a89373
commit
ce3f2bdd20
|
@ -44,7 +44,9 @@ namespace Emby.Drawing.ImageMagick
|
||||||
"cr2",
|
"cr2",
|
||||||
"crw",
|
"crw",
|
||||||
"dng",
|
"dng",
|
||||||
"nef",
|
|
||||||
|
// Remove until supported
|
||||||
|
//"nef",
|
||||||
"orf",
|
"orf",
|
||||||
"pef",
|
"pef",
|
||||||
"arw",
|
"arw",
|
||||||
|
|
|
@ -491,7 +491,7 @@ namespace Emby.Server.Implementations.Dto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(item is LiveTvProgram))
|
if (!(item is LiveTvProgram) || fields.Contains(ItemFields.PlayAccess))
|
||||||
{
|
{
|
||||||
dto.PlayAccess = item.GetPlayAccess(user);
|
dto.PlayAccess = item.GetPlayAccess(user);
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,8 +425,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
{
|
{
|
||||||
await parent.ValidateChildren(new Progress<double>(), CancellationToken.None)
|
await parent.ValidateChildren(new Progress<double>(), CancellationToken.None, new MetadataRefreshOptions(_fileSystem), false) .ConfigureAwait(false);
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (parent != null)
|
else if (parent != null)
|
||||||
|
|
|
@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.LiveTv
|
namespace Emby.Server.Implementations.LiveTv
|
||||||
|
@ -16,6 +15,8 @@ namespace Emby.Server.Implementations.LiveTv
|
||||||
private readonly IMediaEncoder _mediaEncoder;
|
private readonly IMediaEncoder _mediaEncoder;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
const int AnalyzeDurationMs = 2000;
|
||||||
|
|
||||||
public LiveStreamHelper(IMediaEncoder mediaEncoder, ILogger logger)
|
public LiveStreamHelper(IMediaEncoder mediaEncoder, ILogger logger)
|
||||||
{
|
{
|
||||||
_mediaEncoder = mediaEncoder;
|
_mediaEncoder = mediaEncoder;
|
||||||
|
@ -34,7 +35,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||||
Protocol = mediaSource.Protocol,
|
Protocol = mediaSource.Protocol,
|
||||||
MediaType = isAudio ? DlnaProfileType.Audio : DlnaProfileType.Video,
|
MediaType = isAudio ? DlnaProfileType.Audio : DlnaProfileType.Video,
|
||||||
ExtractChapters = false,
|
ExtractChapters = false,
|
||||||
AnalyzeDurationSections = 2
|
AnalyzeDurationMs = AnalyzeDurationMs
|
||||||
|
|
||||||
}, cancellationToken).ConfigureAwait(false);
|
}, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -98,6 +99,8 @@ namespace Emby.Server.Implementations.LiveTv
|
||||||
|
|
||||||
// Try to estimate this
|
// Try to estimate this
|
||||||
mediaSource.InferTotalBitrate(true);
|
mediaSource.InferTotalBitrate(true);
|
||||||
|
|
||||||
|
mediaSource.AnalyzeDurationMs = AnalyzeDurationMs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
|
||||||
|
|
||||||
_sharedBuffer.Enqueue(copy);
|
_sharedBuffer.Enqueue(copy);
|
||||||
|
|
||||||
while (_sharedBuffer.Count > 3000)
|
while (_sharedBuffer.Count > 10000)
|
||||||
{
|
{
|
||||||
byte[] bytes;
|
byte[] bytes;
|
||||||
_sharedBuffer.TryDequeue(out bytes);
|
_sharedBuffer.TryDequeue(out bytes);
|
||||||
|
|
|
@ -463,21 +463,6 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the probe size argument.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="state">The state.</param>
|
|
||||||
/// <returns>System.String.</returns>
|
|
||||||
public string GetProbeSizeArgument(EncodingJobInfo state)
|
|
||||||
{
|
|
||||||
if (state.PlayableStreamFileNames.Count > 0)
|
|
||||||
{
|
|
||||||
return _mediaEncoder.GetProbeSizeAndAnalyzeDurationArgument(state.PlayableStreamFileNames.ToArray(), state.InputProtocol);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _mediaEncoder.GetProbeSizeAndAnalyzeDurationArgument(new[] { state.MediaPath }, state.InputProtocol);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the text subtitle param.
|
/// Gets the text subtitle param.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1452,12 +1437,43 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetProbeSizeArgument(int numInputFiles)
|
||||||
|
{
|
||||||
|
return numInputFiles > 1 ? "-probesize 1G" : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetAnalyzeDurationArgument(int numInputFiles)
|
||||||
|
{
|
||||||
|
return numInputFiles > 1 ? "-analyzeduration 200M" : "";
|
||||||
|
}
|
||||||
|
|
||||||
public string GetInputModifier(EncodingJobInfo state, EncodingOptions encodingOptions)
|
public string GetInputModifier(EncodingJobInfo state, EncodingOptions encodingOptions)
|
||||||
{
|
{
|
||||||
var inputModifier = string.Empty;
|
var inputModifier = string.Empty;
|
||||||
|
|
||||||
var probeSize = GetProbeSizeArgument(state);
|
var numInputFiles = state.PlayableStreamFileNames.Count > 0 ? state.PlayableStreamFileNames.Count : 1;
|
||||||
inputModifier += " " + probeSize;
|
var probeSizeArgument = GetProbeSizeArgument(numInputFiles);
|
||||||
|
|
||||||
|
string analyzeDurationArgument;
|
||||||
|
if (state.MediaSource.AnalyzeDurationMs.HasValue)
|
||||||
|
{
|
||||||
|
analyzeDurationArgument = "-analyzeduration " + (state.MediaSource.AnalyzeDurationMs.Value * 1000).ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
analyzeDurationArgument = GetAnalyzeDurationArgument(numInputFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(probeSizeArgument))
|
||||||
|
{
|
||||||
|
inputModifier += " " + probeSizeArgument;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(analyzeDurationArgument))
|
||||||
|
{
|
||||||
|
inputModifier += " " + analyzeDurationArgument;
|
||||||
|
}
|
||||||
|
|
||||||
inputModifier = inputModifier.Trim();
|
inputModifier = inputModifier.Trim();
|
||||||
|
|
||||||
var userAgentParam = GetUserAgentParam(state);
|
var userAgentParam = GetUserAgentParam(state);
|
||||||
|
|
|
@ -78,14 +78,6 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task<MediaInfo> GetMediaInfo(MediaInfoRequest request, CancellationToken cancellationToken);
|
Task<MediaInfo> GetMediaInfo(MediaInfoRequest request, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the probe size argument.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inputFiles">The input files.</param>
|
|
||||||
/// <param name="protocol">The protocol.</param>
|
|
||||||
/// <returns>System.String.</returns>
|
|
||||||
string GetProbeSizeAndAnalyzeDurationArgument(string[] inputFiles, MediaProtocol protocol);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the input argument.
|
/// Gets the input argument.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
public IIsoMount MountedIso { get; set; }
|
public IIsoMount MountedIso { get; set; }
|
||||||
public VideoType VideoType { get; set; }
|
public VideoType VideoType { get; set; }
|
||||||
public List<string> PlayableStreamFileNames { get; set; }
|
public List<string> PlayableStreamFileNames { get; set; }
|
||||||
public int AnalyzeDurationSections { get; set; }
|
public int AnalyzeDurationMs { get; set; }
|
||||||
|
|
||||||
public MediaInfoRequest()
|
public MediaInfoRequest()
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,15 +61,5 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
// Quotes are valid path characters in linux and they need to be escaped here with a leading \
|
// Quotes are valid path characters in linux and they need to be escaped here with a leading \
|
||||||
return path.Replace("\"", "\\\"");
|
return path.Replace("\"", "\\\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetProbeSizeArgument(int numInputFiles)
|
|
||||||
{
|
|
||||||
return numInputFiles > 1 ? "-probesize 1G" : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetAnalyzeDurationArgument(int numInputFiles)
|
|
||||||
{
|
|
||||||
return numInputFiles > 1 ? "-analyzeduration 200M" : "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,17 +523,17 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
var inputFiles = MediaEncoderHelpers.GetInputArgument(FileSystem, request.InputPath, request.Protocol, request.MountedIso, request.PlayableStreamFileNames);
|
var inputFiles = MediaEncoderHelpers.GetInputArgument(FileSystem, request.InputPath, request.Protocol, request.MountedIso, request.PlayableStreamFileNames);
|
||||||
|
|
||||||
var probeSize = EncodingUtils.GetProbeSizeArgument(inputFiles.Length);
|
var probeSize = EncodingHelper.GetProbeSizeArgument(inputFiles.Length);
|
||||||
string analyzeDuration;
|
string analyzeDuration;
|
||||||
|
|
||||||
if (request.AnalyzeDurationSections > 0)
|
if (request.AnalyzeDurationMs > 0)
|
||||||
{
|
{
|
||||||
analyzeDuration = "-analyzeduration " +
|
analyzeDuration = "-analyzeduration " +
|
||||||
(request.AnalyzeDurationSections * 1000000).ToString(CultureInfo.InvariantCulture);
|
(request.AnalyzeDurationMs * 1000).ToString(CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
analyzeDuration = EncodingUtils.GetAnalyzeDurationArgument(inputFiles.Length);
|
analyzeDuration = EncodingHelper.GetAnalyzeDurationArgument(inputFiles.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
probeSize = probeSize + " " + analyzeDuration;
|
probeSize = probeSize + " " + analyzeDuration;
|
||||||
|
@ -557,31 +557,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
return EncodingUtils.GetInputArgument(inputFiles.ToList(), protocol);
|
return EncodingUtils.GetInputArgument(inputFiles.ToList(), protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the probe size argument.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inputFiles">The input files.</param>
|
|
||||||
/// <param name="protocol">The protocol.</param>
|
|
||||||
/// <returns>System.String.</returns>
|
|
||||||
public string GetProbeSizeAndAnalyzeDurationArgument(string[] inputFiles, MediaProtocol protocol)
|
|
||||||
{
|
|
||||||
var results = new List<string>();
|
|
||||||
|
|
||||||
var probeSize = EncodingUtils.GetProbeSizeArgument(inputFiles.Length);
|
|
||||||
var analyzeDuration = EncodingUtils.GetAnalyzeDurationArgument(inputFiles.Length);
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(probeSize))
|
|
||||||
{
|
|
||||||
results.Add(probeSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(analyzeDuration))
|
|
||||||
{
|
|
||||||
results.Add(analyzeDuration);
|
|
||||||
}
|
|
||||||
return string.Join(" ", results.ToArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the media info internal.
|
/// Gets the media info internal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -984,11 +959,17 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
var args = useIFrame ? string.Format("-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}{4}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, thumbnail) :
|
var args = useIFrame ? string.Format("-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}{4}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg, thumbnail) :
|
||||||
string.Format("-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg);
|
string.Format("-i {0}{3} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, tempExtractPath, vf, mapArg);
|
||||||
|
|
||||||
var probeSize = GetProbeSizeAndAnalyzeDurationArgument(new[] { inputPath }, protocol);
|
var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1);
|
||||||
|
var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(probeSize))
|
if (!string.IsNullOrWhiteSpace(probeSizeArgument))
|
||||||
{
|
{
|
||||||
args = probeSize + " " + args;
|
args = probeSizeArgument + " " + args;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(analyzeDurationArgument))
|
||||||
|
{
|
||||||
|
args = analyzeDurationArgument + " " + args;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset.HasValue)
|
if (offset.HasValue)
|
||||||
|
@ -1092,11 +1073,17 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
var args = string.Format("-i {0} -threads 0 -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument, outputPath, vf);
|
var args = string.Format("-i {0} -threads 0 -v quiet -vf \"{2}\" -f image2 \"{1}\"", inputArgument, outputPath, vf);
|
||||||
|
|
||||||
var probeSize = GetProbeSizeAndAnalyzeDurationArgument(new[] { inputArgument }, protocol);
|
var probeSizeArgument = EncodingHelper.GetProbeSizeArgument(1);
|
||||||
|
var analyzeDurationArgument = EncodingHelper.GetAnalyzeDurationArgument(1);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(probeSize))
|
if (!string.IsNullOrWhiteSpace(probeSizeArgument))
|
||||||
{
|
{
|
||||||
args = probeSize + " " + args;
|
args = probeSizeArgument + " " + args;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(analyzeDurationArgument))
|
||||||
|
{
|
||||||
|
args = analyzeDurationArgument + " " + args;
|
||||||
}
|
}
|
||||||
|
|
||||||
var process = _processFactory.Create(new ProcessOptions
|
var process = _processFactory.Create(new ProcessOptions
|
||||||
|
|
|
@ -60,6 +60,8 @@ namespace MediaBrowser.Model.Dto
|
||||||
public string TranscodingSubProtocol { get; set; }
|
public string TranscodingSubProtocol { get; set; }
|
||||||
public string TranscodingContainer { get; set; }
|
public string TranscodingContainer { get; set; }
|
||||||
|
|
||||||
|
public int? AnalyzeDurationMs { get; set; }
|
||||||
|
|
||||||
public MediaSourceInfo()
|
public MediaSourceInfo()
|
||||||
{
|
{
|
||||||
Formats = new List<string>();
|
Formats = new List<string>();
|
||||||
|
|
Loading…
Reference in New Issue