mirror of https://github.com/jellyfin/jellyfin.git
added keyframe setting
This commit is contained in:
parent
31e36a56e7
commit
9a0462c868
|
@ -8,6 +8,7 @@ using MediaBrowser.Controller.Session;
|
||||||
using MediaBrowser.MediaEncoding.Probing;
|
using MediaBrowser.MediaEncoding.Probing;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Model.Extensions;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
|
@ -241,14 +242,19 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
var mediaInfo = new ProbeResultNormalizer(_logger, FileSystem).GetMediaInfo(result, videoType, isAudio, primaryPath, protocol);
|
var mediaInfo = new ProbeResultNormalizer(_logger, FileSystem).GetMediaInfo(result, videoType, isAudio, primaryPath, protocol);
|
||||||
|
|
||||||
if (extractKeyFrameInterval && mediaInfo.RunTimeTicks.HasValue)
|
if (extractKeyFrameInterval && mediaInfo.RunTimeTicks.HasValue)
|
||||||
|
{
|
||||||
|
if (ConfigurationManager.Configuration.EnableVideoFrameAnalysis && mediaInfo.Size.HasValue && mediaInfo.Size.Value <= ConfigurationManager.Configuration.VideoFrameAnalysisLimitBytes)
|
||||||
{
|
{
|
||||||
foreach (var stream in mediaInfo.MediaStreams)
|
foreach (var stream in mediaInfo.MediaStreams)
|
||||||
{
|
{
|
||||||
if (stream.Type == MediaStreamType.Video && string.Equals(stream.Codec, "h264", StringComparison.OrdinalIgnoreCase) && !stream.IsInterlaced)
|
if (stream.Type == MediaStreamType.Video &&
|
||||||
|
string.Equals(stream.Codec, "h264", StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!stream.IsInterlaced &&
|
||||||
|
!(stream.IsAnamorphic ?? false))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//stream.KeyFrames = await GetKeyFrames(inputPath, stream.Index, cancellationToken).ConfigureAwait(false);
|
stream.KeyFrames = await GetKeyFrames(inputPath, stream.Index, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
@ -261,6 +267,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return mediaInfo;
|
return mediaInfo;
|
||||||
}
|
}
|
||||||
|
@ -296,7 +303,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
// Must consume both or ffmpeg may hang due to deadlocks. See comments below.
|
// Must consume both or ffmpeg may hang due to deadlocks. See comments below.
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
RedirectStandardInput = true,
|
|
||||||
FileName = FFProbePath,
|
FileName = FFProbePath,
|
||||||
Arguments = string.Format(args, inputPath, videoStreamIndex.ToString(CultureInfo.InvariantCulture)).Trim(),
|
Arguments = string.Format(args, inputPath, videoStreamIndex.ToString(CultureInfo.InvariantCulture)).Trim(),
|
||||||
|
|
||||||
|
@ -309,9 +315,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
_logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
_logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
||||||
|
|
||||||
using (var processWrapper = new ProcessWrapper(process, this, _logger))
|
using (process)
|
||||||
{
|
{
|
||||||
StartProcess(processWrapper);
|
var start = DateTime.UtcNow;
|
||||||
|
|
||||||
|
process.Start();
|
||||||
|
|
||||||
var lines = new List<int>();
|
var lines = new List<int>();
|
||||||
|
|
||||||
|
@ -328,27 +336,26 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
process.WaitForExit();
|
||||||
StopProcess(processWrapper, 100, true);
|
|
||||||
}
|
_logger.Debug("Keyframe extraction took {0} seconds", (DateTime.UtcNow - start).TotalSeconds);
|
||||||
//_logger.Debug("Found keyframes {0}", string.Join(",", lines.ToArray()));
|
//_logger.Debug("Found keyframes {0}", string.Join(",", lines.ToArray()));
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task StartReadingOutput(Stream source, List<int> lines, CancellationToken cancellationToken)
|
private async Task StartReadingOutput(Stream source, List<int> keyframes, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var reader = new StreamReader(source))
|
using (var reader = new StreamReader(source))
|
||||||
{
|
{
|
||||||
while (!reader.EndOfStream)
|
var text = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
var lines = StringHelper.RegexSplit(text, "\r\n");
|
||||||
|
foreach (var line in lines)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
|
||||||
|
|
||||||
var line = await reader.ReadLineAsync().ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(line))
|
if (string.IsNullOrWhiteSpace(line))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -368,7 +375,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
if (values.TryGetValue("pts_time", out pts_time) && double.TryParse(pts_time, NumberStyles.Any, CultureInfo.InvariantCulture, out frameSeconds))
|
if (values.TryGetValue("pts_time", out pts_time) && double.TryParse(pts_time, NumberStyles.Any, CultureInfo.InvariantCulture, out frameSeconds))
|
||||||
{
|
{
|
||||||
var ms = frameSeconds * 1000;
|
var ms = frameSeconds * 1000;
|
||||||
lines.Add(Convert.ToInt32(ms));
|
keyframes.Add(Convert.ToInt32(ms));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,11 +222,13 @@ namespace MediaBrowser.Model.Configuration
|
||||||
public bool DisableXmlSavers { get; set; }
|
public bool DisableXmlSavers { get; set; }
|
||||||
public bool EnableWindowsShortcuts { get; set; }
|
public bool EnableWindowsShortcuts { get; set; }
|
||||||
|
|
||||||
|
public bool EnableVideoFrameAnalysis { get; set; }
|
||||||
|
public long VideoFrameAnalysisLimitBytes { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ServerConfiguration()
|
public ServerConfiguration()
|
||||||
: base()
|
|
||||||
{
|
{
|
||||||
ImageSavingConvention = ImageSavingConvention.Compatible;
|
ImageSavingConvention = ImageSavingConvention.Compatible;
|
||||||
PublicPort = 8096;
|
PublicPort = 8096;
|
||||||
|
@ -271,6 +273,9 @@ namespace MediaBrowser.Model.Configuration
|
||||||
|
|
||||||
PeopleMetadataOptions = new PeopleMetadataOptions();
|
PeopleMetadataOptions = new PeopleMetadataOptions();
|
||||||
|
|
||||||
|
EnableVideoFrameAnalysis = true;
|
||||||
|
VideoFrameAnalysisLimitBytes = 600000000;
|
||||||
|
|
||||||
InsecureApps9 = new[]
|
InsecureApps9 = new[]
|
||||||
{
|
{
|
||||||
"Chromecast",
|
"Chromecast",
|
||||||
|
|
|
@ -189,7 +189,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||||
|
|
||||||
var images = results.SelectMany(i => i);
|
var images = results.SelectMany(i => i.ToList());
|
||||||
|
|
||||||
return images;
|
return images;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue