Merge pull request #7911 from cvium/fix_keyframe_transcode
(cherry picked from commit 07b39655ebe2e96388ffbbecebeebb5284c26baf) Signed-off-by: crobibero <cody@robibe.ro>
This commit is contained in:
parent
e4b095a766
commit
b6a0fe3378
|
@ -1414,7 +1414,8 @@ namespace Jellyfin.Api.Controllers
|
||||||
state.RunTimeTicks ?? 0,
|
state.RunTimeTicks ?? 0,
|
||||||
state.Request.SegmentContainer ?? string.Empty,
|
state.Request.SegmentContainer ?? string.Empty,
|
||||||
"hls1/main/",
|
"hls1/main/",
|
||||||
Request.QueryString.ToString());
|
Request.QueryString.ToString(),
|
||||||
|
EncodingHelper.IsCopyCodec(state.OutputVideoCodec));
|
||||||
var playlist = _dynamicHlsPlaylistGenerator.CreateMainPlaylist(request);
|
var playlist = _dynamicHlsPlaylistGenerator.CreateMainPlaylist(request);
|
||||||
|
|
||||||
return new FileContentResult(Encoding.UTF8.GetBytes(playlist), MimeTypes.GetMimeType("playlist.m3u8"));
|
return new FileContentResult(Encoding.UTF8.GetBytes(playlist), MimeTypes.GetMimeType("playlist.m3u8"));
|
||||||
|
|
|
@ -14,7 +14,8 @@ public class CreateMainPlaylistRequest
|
||||||
/// <param name="segmentContainer">The desired segment container eg. "ts".</param>
|
/// <param name="segmentContainer">The desired segment container eg. "ts".</param>
|
||||||
/// <param name="endpointPrefix">The URI prefix for the relative URL in the playlist.</param>
|
/// <param name="endpointPrefix">The URI prefix for the relative URL in the playlist.</param>
|
||||||
/// <param name="queryString">The desired query string to append (must start with ?).</param>
|
/// <param name="queryString">The desired query string to append (must start with ?).</param>
|
||||||
public CreateMainPlaylistRequest(string filePath, int desiredSegmentLengthMs, long totalRuntimeTicks, string segmentContainer, string endpointPrefix, string queryString)
|
/// <param name="isRemuxingVideo">Whether the video is being remuxed.</param>
|
||||||
|
public CreateMainPlaylistRequest(string filePath, int desiredSegmentLengthMs, long totalRuntimeTicks, string segmentContainer, string endpointPrefix, string queryString, bool isRemuxingVideo)
|
||||||
{
|
{
|
||||||
FilePath = filePath;
|
FilePath = filePath;
|
||||||
DesiredSegmentLengthMs = desiredSegmentLengthMs;
|
DesiredSegmentLengthMs = desiredSegmentLengthMs;
|
||||||
|
@ -22,6 +23,7 @@ public class CreateMainPlaylistRequest
|
||||||
SegmentContainer = segmentContainer;
|
SegmentContainer = segmentContainer;
|
||||||
EndpointPrefix = endpointPrefix;
|
EndpointPrefix = endpointPrefix;
|
||||||
QueryString = queryString;
|
QueryString = queryString;
|
||||||
|
IsRemuxingVideo = isRemuxingVideo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -53,4 +55,9 @@ public class CreateMainPlaylistRequest
|
||||||
/// Gets the query string.
|
/// Gets the query string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string QueryString { get; }
|
public string QueryString { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the video is being remuxed.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRemuxingVideo { get; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ public class DynamicHlsPlaylistGenerator : IDynamicHlsPlaylistGenerator
|
||||||
public string CreateMainPlaylist(CreateMainPlaylistRequest request)
|
public string CreateMainPlaylist(CreateMainPlaylistRequest request)
|
||||||
{
|
{
|
||||||
IReadOnlyList<double> segments;
|
IReadOnlyList<double> segments;
|
||||||
if (TryExtractKeyframes(request.FilePath, out var keyframeData))
|
// For video transcodes it is sufficient with equal length segments as ffmpeg will create new keyframes
|
||||||
|
if (request.IsRemuxingVideo && TryExtractKeyframes(request.FilePath, out var keyframeData))
|
||||||
{
|
{
|
||||||
segments = ComputeSegments(keyframeData, request.DesiredSegmentLengthMs);
|
segments = ComputeSegments(keyframeData, request.DesiredSegmentLengthMs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user