mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-02-23 13:02:26 +00:00
Fixes
This commit is contained in:
@@ -32,25 +32,38 @@ namespace Jellyfin.MediaEncoding.Keyframes
|
||||
/// <returns>An instance of <see cref="KeyframeData"/>.</returns>
|
||||
public KeyframeData GetKeyframeData(string filePath, string ffProbePath, string ffToolPath)
|
||||
{
|
||||
var extension = Path.GetExtension(filePath);
|
||||
if (string.Equals(extension, ".mkv", StringComparison.OrdinalIgnoreCase))
|
||||
var extension = Path.GetExtension(filePath.AsSpan());
|
||||
if (extension.Equals(".mkv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
try
|
||||
{
|
||||
return MatroskaKeyframeExtractor.GetKeyframeData(filePath);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{MatroskaKeyframeExtractor} failed to extract keyframes", nameof(MatroskaKeyframeExtractor));
|
||||
_logger.LogError(ex, "{ExtractorType} failed to extract keyframes", nameof(MatroskaKeyframeExtractor));
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(ffToolPath))
|
||||
try
|
||||
{
|
||||
return FfToolKeyframeExtractor.GetKeyframeData(ffToolPath, filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{ExtractorType} failed to extract keyframes", nameof(FfToolKeyframeExtractor));
|
||||
}
|
||||
|
||||
return FfProbeKeyframeExtractor.GetKeyframeData(ffProbePath, filePath);
|
||||
try
|
||||
{
|
||||
return FfProbeKeyframeExtractor.GetKeyframeData(ffProbePath, filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{ExtractorType} failed to extract keyframes", nameof(FfProbeKeyframeExtractor));
|
||||
}
|
||||
|
||||
return new KeyframeData(0, Array.Empty<long>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Jellyfin.MediaEncoding.Keyframes.Matroska
|
||||
|
||||
if (trackNumber == videoTrackNumber)
|
||||
{
|
||||
keyframes.Add(ScaleToNanoseconds(cueTime, info.TimestampScale));
|
||||
keyframes.Add(ScaleToTicks(cueTime, info.TimestampScale));
|
||||
}
|
||||
|
||||
reader.LeaveContainer();
|
||||
@@ -57,17 +57,17 @@ namespace Jellyfin.MediaEncoding.Keyframes.Matroska
|
||||
|
||||
reader.LeaveContainer();
|
||||
|
||||
var result = new KeyframeData(ScaleToNanoseconds(info.Duration ?? 0, info.TimestampScale), keyframes);
|
||||
var result = new KeyframeData(ScaleToTicks(info.Duration ?? 0, info.TimestampScale), keyframes);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static long ScaleToNanoseconds(ulong unscaledValue, long timestampScale)
|
||||
private static long ScaleToTicks(ulong unscaledValue, long timestampScale)
|
||||
{
|
||||
// TimestampScale is in nanoseconds, scale it to get the value in ticks, 1 tick == 100 ns
|
||||
return (long)unscaledValue * timestampScale / 100;
|
||||
}
|
||||
|
||||
private static long ScaleToNanoseconds(double unscaledValue, long timestampScale)
|
||||
private static long ScaleToTicks(double unscaledValue, long timestampScale)
|
||||
{
|
||||
// TimestampScale is in nanoseconds, scale it to get the value in ticks, 1 tick == 100 ns
|
||||
return Convert.ToInt64(unscaledValue * timestampScale / 100);
|
||||
|
||||
Reference in New Issue
Block a user