new hls params
This commit is contained in:
parent
dbfe22412a
commit
8b0c235675
|
@ -102,7 +102,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="state">The state.</param>
|
/// <param name="state">The state.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
protected string GetOutputFilePath(StreamState state)
|
protected virtual string GetOutputFilePath(StreamState state)
|
||||||
{
|
{
|
||||||
var folder = ApplicationPaths.EncodedMediaCachePath;
|
var folder = ApplicationPaths.EncodedMediaCachePath;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.Extensions;
|
||||||
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.MediaInfo;
|
using MediaBrowser.Common.MediaInfo;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
@ -6,7 +7,6 @@ using MediaBrowser.Controller.Library;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Playback.Hls
|
namespace MediaBrowser.Api.Playback.Hls
|
||||||
|
@ -19,7 +19,16 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The segment file prefix
|
/// The segment file prefix
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string SegmentFilePrefix = "segment-";
|
public const string SegmentFilePrefix = "hls-";
|
||||||
|
|
||||||
|
protected override string GetOutputFilePath(StreamState state)
|
||||||
|
{
|
||||||
|
var folder = ApplicationPaths.EncodedMediaCachePath;
|
||||||
|
|
||||||
|
var outputFileExtension = GetOutputFileExtension(state);
|
||||||
|
|
||||||
|
return Path.Combine(folder, SegmentFilePrefix + GetCommandLineArguments("dummy\\dummy", state, false).GetMD5() + (outputFileExtension ?? string.Empty).ToLower());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
|
/// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
|
||||||
|
@ -139,22 +148,13 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
await Task.Delay(25).ConfigureAwait(false);
|
await Task.Delay(25).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The segement paths within the playlist are phsyical, so strip that out to make it relative
|
|
||||||
fileText = fileText.Replace(Path.GetDirectoryName(playlist) + Path.DirectorySeparatorChar, string.Empty);
|
|
||||||
|
|
||||||
fileText = fileText.Replace(SegmentFilePrefix, "segments/").Replace(".ts", "/stream.ts").Replace(".aac", "/stream.aac").Replace(".mp3", "/stream.mp3");
|
fileText = fileText.Replace(SegmentFilePrefix, "segments/").Replace(".ts", "/stream.ts").Replace(".aac", "/stream.aac").Replace(".mp3", "/stream.mp3");
|
||||||
|
|
||||||
// It's considered live while still encoding (EVENT). Once the encoding has finished, it's video on demand (VOD).
|
// It's considered live while still encoding (EVENT). Once the encoding has finished, it's video on demand (VOD).
|
||||||
var playlistType = fileText.IndexOf("#EXT-X-ENDLIST", StringComparison.OrdinalIgnoreCase) == -1 ? "EVENT" : "VOD";
|
var playlistType = fileText.IndexOf("#EXT-X-ENDLIST", StringComparison.OrdinalIgnoreCase) == -1 ? "EVENT" : "VOD";
|
||||||
|
|
||||||
const string allowCacheAttributeName = "#EXT-X-ALLOW-CACHE";
|
|
||||||
|
|
||||||
// fix this to make the media stream validator happy
|
|
||||||
// https://ffmpeg.org/trac/ffmpeg/ticket/2228
|
|
||||||
fileText = fileText.Replace("#EXT-X-ALLOWCACHE", allowCacheAttributeName);
|
|
||||||
|
|
||||||
// Add event type at the top
|
// Add event type at the top
|
||||||
fileText = fileText.Replace(allowCacheAttributeName, "#EXT-X-PLAYLIST-TYPE:" + playlistType + Environment.NewLine + allowCacheAttributeName);
|
//fileText = fileText.Replace(allowCacheAttributeName, "#EXT-X-PLAYLIST-TYPE:" + playlistType + Environment.NewLine + allowCacheAttributeName);
|
||||||
|
|
||||||
return fileText;
|
return fileText;
|
||||||
}
|
}
|
||||||
|
@ -187,14 +187,9 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
protected override string GetCommandLineArguments(string outputPath, StreamState state, bool performSubtitleConversions)
|
protected override string GetCommandLineArguments(string outputPath, StreamState state, bool performSubtitleConversions)
|
||||||
{
|
{
|
||||||
var segmentOutputPath = Path.GetDirectoryName(outputPath);
|
|
||||||
var segmentOutputName = SegmentFilePrefix + Path.GetFileNameWithoutExtension(outputPath);
|
|
||||||
|
|
||||||
segmentOutputPath = Path.Combine(segmentOutputPath, segmentOutputName + "%03d." + GetSegmentFileExtension(state).TrimStart('.'));
|
|
||||||
|
|
||||||
var probeSize = GetProbeSizeArgument(state.Item);
|
var probeSize = GetProbeSizeArgument(state.Item);
|
||||||
|
|
||||||
return string.Format("{0} {1} {2} -i {3}{4} -threads 0 {5} {6} {7} -f ssegment -segment_list_flags +live -segment_time 10 -segment_list \"{8}\" \"{9}\"",
|
return string.Format("{0} {1} {2} -i {3}{4} -threads 0 {5} {6} {7} -hls_time 10 -start_number 0 -hls_list_size 1440 \"{8}\"",
|
||||||
probeSize,
|
probeSize,
|
||||||
GetUserAgentParam(state.Item),
|
GetUserAgentParam(state.Item),
|
||||||
GetFastSeekCommandLineParameter(state.Request),
|
GetFastSeekCommandLineParameter(state.Request),
|
||||||
|
@ -203,8 +198,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
GetMapArgs(state),
|
GetMapArgs(state),
|
||||||
GetVideoArguments(state, performSubtitleConversions),
|
GetVideoArguments(state, performSubtitleConversions),
|
||||||
GetAudioArguments(state),
|
GetAudioArguments(state),
|
||||||
outputPath,
|
outputPath
|
||||||
segmentOutputPath
|
|
||||||
).Trim();
|
).Trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user