mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update mpeg dash
This commit is contained in:
parent
e8161cf8ac
commit
caa223e1db
@ -43,7 +43,7 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
builder.Append("<AdaptationSet id=\"video\" segmentAlignment=\"true\" bitstreamSwitching=\"true\">");
|
builder.Append("<AdaptationSet id=\"video\" segmentAlignment=\"true\" bitstreamSwitching=\"true\">");
|
||||||
builder.Append(GetVideoRepresentationOpenElement(state));
|
builder.Append(GetVideoRepresentationOpenElement(state));
|
||||||
|
|
||||||
AppendSegmentList(state, builder, "video", playlistUrl);
|
AppendSegmentList(state, builder, "0", playlistUrl);
|
||||||
|
|
||||||
builder.Append("</Representation>");
|
builder.Append("</Representation>");
|
||||||
builder.Append("</AdaptationSet>");
|
builder.Append("</AdaptationSet>");
|
||||||
@ -60,7 +60,7 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
|
|
||||||
builder.Append("<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"6\" />");
|
builder.Append("<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"6\" />");
|
||||||
|
|
||||||
AppendSegmentList(state, builder, "audio", playlistUrl);
|
AppendSegmentList(state, builder, "1", playlistUrl);
|
||||||
|
|
||||||
builder.Append("</Representation>");
|
builder.Append("</Representation>");
|
||||||
builder.Append("</AdaptationSet>");
|
builder.Append("</AdaptationSet>");
|
||||||
|
@ -37,7 +37,7 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/Videos/{Id}/dash/{SegmentType}/{SegmentId}.m4s", "GET")]
|
[Route("/Videos/{Id}/dash/{RepresentationId}/{SegmentId}.m4s", "GET")]
|
||||||
public class GetDashSegment : VideoStreamRequest
|
public class GetDashSegment : VideoStreamRequest
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -47,10 +47,10 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
public string SegmentId { get; set; }
|
public string SegmentId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the type of the segment.
|
/// Gets or sets the representation identifier.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The type of the segment.</value>
|
/// <value>The representation identifier.</value>
|
||||||
public string SegmentType { get; set; }
|
public string RepresentationId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MpegDashService : BaseHlsService
|
public class MpegDashService : BaseHlsService
|
||||||
@ -106,10 +106,10 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
|
|
||||||
public object Get(GetDashSegment request)
|
public object Get(GetDashSegment request)
|
||||||
{
|
{
|
||||||
return GetDynamicSegment(request, request.SegmentId, request.SegmentType).Result;
|
return GetDynamicSegment(request, request.SegmentId, request.RepresentationId).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<object> GetDynamicSegment(VideoStreamRequest request, string segmentId, string segmentType)
|
private async Task<object> GetDynamicSegment(VideoStreamRequest request, string segmentId, string representationId)
|
||||||
{
|
{
|
||||||
if ((request.StartTimeTicks ?? 0) > 0)
|
if ((request.StartTimeTicks ?? 0) > 0)
|
||||||
{
|
{
|
||||||
@ -127,7 +127,7 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
|
|
||||||
var segmentExtension = GetSegmentFileExtension(state);
|
var segmentExtension = GetSegmentFileExtension(state);
|
||||||
|
|
||||||
var segmentPath = GetSegmentPath(playlistPath, segmentType, segmentExtension, index);
|
var segmentPath = GetSegmentPath(playlistPath, representationId, segmentExtension, index);
|
||||||
var segmentLength = state.SegmentLength;
|
var segmentLength = state.SegmentLength;
|
||||||
|
|
||||||
TranscodingJob job = null;
|
TranscodingJob job = null;
|
||||||
@ -248,7 +248,7 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// If all transcoding has completed, just return immediately
|
// If all transcoding has completed, just return immediately
|
||||||
if (!IsTranscoding(playlistPath))
|
if (transcodingJob != null && transcodingJob.HasExited)
|
||||||
{
|
{
|
||||||
return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob);
|
return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob);
|
||||||
}
|
}
|
||||||
@ -327,13 +327,6 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsTranscoding(string playlistPath)
|
|
||||||
{
|
|
||||||
var job = ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
|
||||||
|
|
||||||
return job != null && !job.HasExited;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int? GetCurrentTranscodingIndex(string playlist, string segmentExtension)
|
public int? GetCurrentTranscodingIndex(string playlist, string segmentExtension)
|
||||||
{
|
{
|
||||||
var file = GetLastTranscodingFile(playlist, segmentExtension, FileSystem);
|
var file = GetLastTranscodingFile(playlist, segmentExtension, FileSystem);
|
||||||
@ -397,25 +390,12 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetSegmentPath(string playlist, string segmentType, string segmentExtension, int index)
|
private string GetSegmentPath(string playlist, string representationId, string segmentExtension, int index)
|
||||||
{
|
{
|
||||||
var folder = Path.GetDirectoryName(playlist);
|
var folder = Path.GetDirectoryName(playlist);
|
||||||
|
|
||||||
var id = string.Equals(segmentType, "video", StringComparison.OrdinalIgnoreCase)
|
|
||||||
? "0"
|
|
||||||
: "1";
|
|
||||||
|
|
||||||
string filename;
|
|
||||||
|
|
||||||
if (index == 0)
|
|
||||||
{
|
|
||||||
filename = "init-stream" + id + segmentExtension;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var number = index.ToString("00000", CultureInfo.InvariantCulture);
|
var number = index.ToString("00000", CultureInfo.InvariantCulture);
|
||||||
filename = "chunk-stream" + id + "-" + number + segmentExtension;
|
var filename = "chunk-stream" + representationId + "-" + number + segmentExtension;
|
||||||
}
|
|
||||||
|
|
||||||
return Path.Combine(folder, filename);
|
return Path.Combine(folder, filename);
|
||||||
}
|
}
|
||||||
@ -500,7 +480,7 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
|
|
||||||
var inputModifier = GetInputModifier(state);
|
var inputModifier = GetInputModifier(state);
|
||||||
|
|
||||||
var args = string.Format("{0} {1} -map_metadata -1 -threads {2} {3} {4} -copyts {5} -f dash -use_template 0 -min_seg_duration {6} -y \"{7}\"",
|
var args = string.Format("{0} {1} -map_metadata -1 -threads {2} {3} {4} -copyts {5} -f dash -init_seg_name \"chunk-stream$RepresentationID$-00000.m4s\" -use_template 0 -min_seg_duration {6} -y \"{7}\"",
|
||||||
inputModifier,
|
inputModifier,
|
||||||
GetInputArgument(transcodingJobId, state),
|
GetInputArgument(transcodingJobId, state),
|
||||||
threads,
|
threads,
|
||||||
@ -514,20 +494,23 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private string GetCurrentTranscodingIndex(string outputPath)
|
protected override int GetStartNumber(StreamState state)
|
||||||
//{
|
{
|
||||||
|
return GetStartNumber(state.VideoRequest);
|
||||||
|
}
|
||||||
|
|
||||||
//}
|
private int GetStartNumber(VideoStreamRequest request)
|
||||||
|
{
|
||||||
|
var segmentId = "0";
|
||||||
|
|
||||||
//private string GetNextTranscodingIndex(string outputPath)
|
var segmentRequest = request as GetDashSegment;
|
||||||
//{
|
if (segmentRequest != null)
|
||||||
|
{
|
||||||
|
segmentId = segmentRequest.SegmentId;
|
||||||
|
}
|
||||||
|
|
||||||
//}
|
return int.Parse(segmentId, NumberStyles.Integer, UsCulture);
|
||||||
|
}
|
||||||
//private string GetActualPlaylistPath(string outputPath, string transcodingIndex)
|
|
||||||
//{
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the segment file extension.
|
/// Gets the segment file extension.
|
||||||
|
@ -279,7 +279,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// If all transcoding has completed, just return immediately
|
// If all transcoding has completed, just return immediately
|
||||||
if (!IsTranscoding(playlistPath))
|
if (transcodingJob != null && transcodingJob.HasExited)
|
||||||
{
|
{
|
||||||
return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob);
|
return GetSegmentResult(segmentPath, segmentIndex, segmentLength, transcodingJob);
|
||||||
}
|
}
|
||||||
@ -358,13 +358,6 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsTranscoding(string playlistPath)
|
|
||||||
{
|
|
||||||
var job = ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
|
||||||
|
|
||||||
return job != null && !job.HasExited;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<object> GetAsync(GetMasterHlsVideoStream request, string method)
|
private async Task<object> GetAsync(GetMasterHlsVideoStream request, string method)
|
||||||
{
|
{
|
||||||
var state = await GetState(request, CancellationToken.None).ConfigureAwait(false);
|
var state = await GetState(request, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user