2016-03-27 23:11:27 +02:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2015-01-20 00:19:13 -05:00
|
|
|
|
using MediaBrowser.Controller.Devices;
|
2014-03-25 01:25:03 -04:00
|
|
|
|
using MediaBrowser.Controller.Dlna;
|
2013-02-27 18:33:40 -05:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2014-02-20 11:37:41 -05:00
|
|
|
|
using MediaBrowser.Controller.MediaEncoding;
|
2015-01-20 00:19:13 -05:00
|
|
|
|
using MediaBrowser.Model.Extensions;
|
2013-08-28 18:05:00 -04:00
|
|
|
|
using MediaBrowser.Model.IO;
|
2015-01-20 00:19:13 -05:00
|
|
|
|
using MediaBrowser.Model.Net;
|
2015-05-22 11:59:17 -04:00
|
|
|
|
using MediaBrowser.Model.Serialization;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
using System;
|
2013-04-07 16:55:05 -04:00
|
|
|
|
using System.Collections.Generic;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
using System.IO;
|
2013-08-28 18:05:00 -04:00
|
|
|
|
using System.Text;
|
2013-12-21 13:37:34 -05:00
|
|
|
|
using System.Threading;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
using System.Threading.Tasks;
|
2016-10-25 15:02:04 -04:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
|
using MediaBrowser.Controller.IO;
|
2016-11-10 09:41:24 -05:00
|
|
|
|
using MediaBrowser.Controller.Net;
|
2016-10-25 15:02:04 -04:00
|
|
|
|
using MediaBrowser.Model.IO;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2013-02-27 18:33:40 -05:00
|
|
|
|
namespace MediaBrowser.Api.Playback.Hls
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
2013-04-29 12:01:23 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Class BaseHlsService
|
|
|
|
|
|
/// </summary>
|
2013-02-27 18:33:40 -05:00
|
|
|
|
public abstract class BaseHlsService : BaseStreamingService
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the audio arguments.
|
|
|
|
|
|
/// </summary>
|
2013-04-29 12:01:23 -04:00
|
|
|
|
/// <param name="state">The state.</param>
|
2013-02-20 20:33:05 -05:00
|
|
|
|
/// <returns>System.String.</returns>
|
2013-02-27 18:33:40 -05:00
|
|
|
|
protected abstract string GetAudioArguments(StreamState state);
|
2013-02-20 20:33:05 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the video arguments.
|
|
|
|
|
|
/// </summary>
|
2013-04-29 12:01:23 -04:00
|
|
|
|
/// <param name="state">The state.</param>
|
2013-02-20 20:33:05 -05:00
|
|
|
|
/// <returns>System.String.</returns>
|
2014-06-10 13:36:06 -04:00
|
|
|
|
protected abstract string GetVideoArguments(StreamState state);
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2013-02-27 18:33:40 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the segment file extension.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="state">The state.</param>
|
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
|
protected abstract string GetSegmentFileExtension(StreamState state);
|
2013-04-29 12:01:23 -04:00
|
|
|
|
|
2013-02-20 20:33:05 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the type of the transcoding job.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value>The type of the transcoding job.</value>
|
|
|
|
|
|
protected override TranscodingJobType TranscodingJobType
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return TranscodingJobType.Hls; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-02-27 18:33:40 -05:00
|
|
|
|
/// Processes the request.
|
2013-02-20 20:33:05 -05:00
|
|
|
|
/// </summary>
|
2013-04-29 12:01:23 -04:00
|
|
|
|
/// <param name="request">The request.</param>
|
2014-07-01 17:13:32 -04:00
|
|
|
|
/// <param name="isLive">if set to <c>true</c> [is live].</param>
|
2013-02-27 18:33:40 -05:00
|
|
|
|
/// <returns>System.Object.</returns>
|
2016-06-19 02:18:29 -04:00
|
|
|
|
protected async Task<object> ProcessRequest(StreamRequest request, bool isLive)
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
2016-06-19 02:18:29 -04:00
|
|
|
|
return await ProcessRequestAsync(request, isLive).ConfigureAwait(false);
|
2013-02-20 20:33:05 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-02-27 18:33:40 -05:00
|
|
|
|
/// Processes the request async.
|
2013-02-20 20:33:05 -05:00
|
|
|
|
/// </summary>
|
2014-01-12 16:32:13 -05:00
|
|
|
|
/// <param name="request">The request.</param>
|
2014-07-01 17:13:32 -04:00
|
|
|
|
/// <param name="isLive">if set to <c>true</c> [is live].</param>
|
2013-02-27 18:33:40 -05:00
|
|
|
|
/// <returns>Task{System.Object}.</returns>
|
2014-07-01 17:13:32 -04:00
|
|
|
|
/// <exception cref="ArgumentException">A video bitrate is required
|
2014-01-12 16:32:13 -05:00
|
|
|
|
/// or
|
2014-07-01 17:13:32 -04:00
|
|
|
|
/// An audio bitrate is required</exception>
|
|
|
|
|
|
private async Task<object> ProcessRequestAsync(StreamRequest request, bool isLive)
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
2014-06-02 15:32:41 -04:00
|
|
|
|
var cancellationTokenSource = new CancellationTokenSource();
|
|
|
|
|
|
|
2014-06-20 00:50:30 -04:00
|
|
|
|
var state = await GetState(request, cancellationTokenSource.Token).ConfigureAwait(false);
|
2014-01-12 16:32:13 -05:00
|
|
|
|
|
2015-04-13 12:21:10 -04:00
|
|
|
|
TranscodingJob job = null;
|
2014-06-05 20:39:02 -04:00
|
|
|
|
var playlist = state.OutputFilePath;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2015-09-20 13:56:26 -04:00
|
|
|
|
if (!FileSystem.FileExists(playlist))
|
2014-04-14 23:54:52 -04:00
|
|
|
|
{
|
2016-09-25 14:39:13 -04:00
|
|
|
|
var transcodingLock = ApiEntryPoint.Instance.GetTranscodingLock(playlist);
|
|
|
|
|
|
await transcodingLock.WaitAsync(cancellationTokenSource.Token).ConfigureAwait(false);
|
2014-04-05 11:02:50 -04:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2015-09-20 13:56:26 -04:00
|
|
|
|
if (!FileSystem.FileExists(playlist))
|
2014-04-14 23:54:52 -04:00
|
|
|
|
{
|
|
|
|
|
|
// If the playlist doesn't already exist, startup ffmpeg
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2015-04-13 12:21:10 -04:00
|
|
|
|
job = await StartFfMpeg(state, playlist, cancellationTokenSource).ConfigureAwait(false);
|
2015-05-22 11:59:17 -04:00
|
|
|
|
job.IsLiveOutput = isLive;
|
2014-04-14 23:54:52 -04:00
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
state.Dispose();
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-03 15:52:56 -05:00
|
|
|
|
var waitForSegments = state.SegmentLength >= 10 ? 2 : 3;
|
2015-12-29 11:13:43 -05:00
|
|
|
|
await WaitForMinimumSegmentCount(playlist, waitForSegments, cancellationTokenSource.Token).ConfigureAwait(false);
|
2014-06-02 15:32:41 -04:00
|
|
|
|
}
|
2014-04-05 11:02:50 -04:00
|
|
|
|
}
|
2014-04-14 23:54:52 -04:00
|
|
|
|
finally
|
2014-04-05 11:02:50 -04:00
|
|
|
|
{
|
2016-09-25 14:39:13 -04:00
|
|
|
|
transcodingLock.Release();
|
2014-04-05 11:02:50 -04:00
|
|
|
|
}
|
2013-02-20 20:33:05 -05:00
|
|
|
|
}
|
2013-08-28 18:05:00 -04:00
|
|
|
|
|
2014-07-01 17:13:32 -04:00
|
|
|
|
if (isLive)
|
|
|
|
|
|
{
|
2015-04-13 12:21:10 -04:00
|
|
|
|
job = job ?? ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlist, TranscodingJobType);
|
|
|
|
|
|
|
|
|
|
|
|
if (job != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
ApiEntryPoint.Instance.OnTranscodeEndRequest(job);
|
|
|
|
|
|
}
|
2014-12-18 23:20:07 -05:00
|
|
|
|
return ResultFactory.GetResult(GetLivePlaylistText(playlist, state.SegmentLength), MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
2014-07-01 17:13:32 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-06-30 13:40:46 -04:00
|
|
|
|
var audioBitrate = state.OutputAudioBitrate ?? 0;
|
|
|
|
|
|
var videoBitrate = state.OutputVideoBitrate ?? 0;
|
2013-08-29 22:13:58 -04:00
|
|
|
|
|
2013-09-06 13:27:06 -04:00
|
|
|
|
var baselineStreamBitrate = 64000;
|
|
|
|
|
|
|
2016-09-18 16:38:38 -04:00
|
|
|
|
var playlistText = GetMasterPlaylistFileText(playlist, videoBitrate + audioBitrate, baselineStreamBitrate);
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2015-04-13 12:21:10 -04:00
|
|
|
|
job = job ?? ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlist, TranscodingJobType);
|
|
|
|
|
|
|
|
|
|
|
|
if (job != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
ApiEntryPoint.Instance.OnTranscodeEndRequest(job);
|
|
|
|
|
|
}
|
2015-09-20 13:56:26 -04:00
|
|
|
|
|
2014-09-18 00:50:21 -04:00
|
|
|
|
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
2013-02-20 20:33:05 -05:00
|
|
|
|
}
|
2013-10-07 14:22:21 -04:00
|
|
|
|
|
2014-12-18 23:20:07 -05:00
|
|
|
|
private string GetLivePlaylistText(string path, int segmentLength)
|
|
|
|
|
|
{
|
2016-10-25 15:02:04 -04:00
|
|
|
|
using (var stream = FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite))
|
2014-12-18 23:20:07 -05:00
|
|
|
|
{
|
|
|
|
|
|
using (var reader = new StreamReader(stream))
|
|
|
|
|
|
{
|
|
|
|
|
|
var text = reader.ReadToEnd();
|
|
|
|
|
|
|
2016-09-19 11:41:35 -04:00
|
|
|
|
text = text.Replace("#EXTM3U", "#EXTM3U\n#EXT-X-PLAYLIST-TYPE:EVENT");
|
|
|
|
|
|
|
2015-04-27 13:55:57 -04:00
|
|
|
|
var newDuration = "#EXT-X-TARGETDURATION:" + segmentLength.ToString(UsCulture);
|
2014-12-18 23:20:07 -05:00
|
|
|
|
|
2016-11-28 00:38:41 -05:00
|
|
|
|
text = text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength - 1).ToString(UsCulture), newDuration, StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
|
//text = text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength + 1).ToString(UsCulture), newDuration, StringComparison.OrdinalIgnoreCase);
|
2015-04-27 13:55:57 -04:00
|
|
|
|
|
|
|
|
|
|
return text;
|
2014-12-18 23:20:07 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-18 16:38:38 -04:00
|
|
|
|
private string GetMasterPlaylistFileText(string firstPlaylist, int bitrate, int baselineStreamBitrate)
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
2013-08-28 18:05:00 -04:00
|
|
|
|
var builder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
builder.AppendLine("#EXTM3U");
|
|
|
|
|
|
|
2013-09-03 10:37:15 -04:00
|
|
|
|
// Pad a little to satisfy the apple hls validator
|
2014-03-27 15:30:21 -04:00
|
|
|
|
var paddedBitrate = Convert.ToInt32(bitrate * 1.15);
|
2013-09-03 10:37:15 -04:00
|
|
|
|
|
2013-08-28 18:05:00 -04:00
|
|
|
|
// Main stream
|
2013-09-03 10:37:15 -04:00
|
|
|
|
builder.AppendLine("#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=" + paddedBitrate.ToString(UsCulture));
|
2013-08-28 18:05:00 -04:00
|
|
|
|
var playlistUrl = "hls/" + Path.GetFileName(firstPlaylist).Replace(".m3u8", "/stream.m3u8");
|
|
|
|
|
|
builder.AppendLine(playlistUrl);
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2013-08-28 18:05:00 -04:00
|
|
|
|
return builder.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-03-10 00:33:51 -04:00
|
|
|
|
protected virtual async Task WaitForMinimumSegmentCount(string playlist, int segmentCount, CancellationToken cancellationToken)
|
2013-08-28 18:05:00 -04:00
|
|
|
|
{
|
2014-07-01 17:13:32 -04:00
|
|
|
|
Logger.Debug("Waiting for {0} segments in {1}", segmentCount, playlist);
|
2013-08-28 18:05:00 -04:00
|
|
|
|
|
2016-09-25 14:39:13 -04:00
|
|
|
|
while (!cancellationToken.IsCancellationRequested)
|
2014-06-26 13:04:11 -04:00
|
|
|
|
{
|
2016-09-25 14:39:13 -04:00
|
|
|
|
try
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
2016-10-25 15:02:04 -04:00
|
|
|
|
// Need to use FileShareMode.ReadWrite because we're reading the file at the same time it's being written
|
2016-09-25 14:39:13 -04:00
|
|
|
|
using (var fileStream = GetPlaylistFileStream(playlist))
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
2016-09-25 14:39:13 -04:00
|
|
|
|
using (var reader = new StreamReader(fileStream))
|
2014-06-26 13:04:11 -04:00
|
|
|
|
{
|
2016-09-25 14:39:13 -04:00
|
|
|
|
var count = 0;
|
2014-06-26 13:04:11 -04:00
|
|
|
|
|
2016-09-25 14:39:13 -04:00
|
|
|
|
while (!reader.EndOfStream)
|
2014-06-26 13:04:11 -04:00
|
|
|
|
{
|
2016-09-25 14:39:13 -04:00
|
|
|
|
var line = await reader.ReadLineAsync().ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (line.IndexOf("#EXTINF:", StringComparison.OrdinalIgnoreCase) != -1)
|
2014-06-26 13:04:11 -04:00
|
|
|
|
{
|
2016-09-25 14:39:13 -04:00
|
|
|
|
count++;
|
|
|
|
|
|
if (count >= segmentCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.Debug("Finished waiting for {0} segments in {1}", segmentCount, playlist);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2014-06-26 13:04:11 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-09-25 14:39:13 -04:00
|
|
|
|
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
|
2014-06-26 13:04:11 -04:00
|
|
|
|
}
|
2013-02-20 20:33:05 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-09-25 14:39:13 -04:00
|
|
|
|
catch (IOException)
|
|
|
|
|
|
{
|
|
|
|
|
|
// May get an error if the file is locked
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await Task.Delay(50, cancellationToken).ConfigureAwait(false);
|
2013-02-20 20:33:05 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-04-29 12:01:23 -04:00
|
|
|
|
|
2015-04-02 12:26:42 -04:00
|
|
|
|
protected Stream GetPlaylistFileStream(string path)
|
|
|
|
|
|
{
|
|
|
|
|
|
var tmpPath = path + ".tmp";
|
2016-12-29 14:27:14 -05:00
|
|
|
|
tmpPath = path;
|
2015-04-02 12:26:42 -04:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2016-10-25 15:02:04 -04:00
|
|
|
|
return FileSystem.GetFileStream(tmpPath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true);
|
2015-04-02 12:26:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
catch (IOException)
|
|
|
|
|
|
{
|
2016-10-25 15:02:04 -04:00
|
|
|
|
return FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true);
|
2015-04-02 12:26:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-03-28 16:22:27 -04:00
|
|
|
|
protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding)
|
2013-02-20 20:33:05 -05:00
|
|
|
|
{
|
2017-02-02 11:02:01 -05:00
|
|
|
|
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
|
|
|
|
|
|
2016-04-04 01:07:10 -04:00
|
|
|
|
var itsOffsetMs = 0;
|
2013-09-19 16:03:14 -04:00
|
|
|
|
|
2014-03-30 21:00:47 -04:00
|
|
|
|
var itsOffset = itsOffsetMs == 0 ? string.Empty : string.Format("-itsoffset {0} ", TimeSpan.FromMilliseconds(itsOffsetMs).TotalSeconds.ToString(UsCulture));
|
2013-09-19 16:03:14 -04:00
|
|
|
|
|
2017-02-02 11:02:01 -05:00
|
|
|
|
var threads = EncodingHelper.GetNumberOfThreads(state, encodingOptions, false);
|
2013-12-15 14:39:21 -05:00
|
|
|
|
|
2017-02-02 11:02:01 -05:00
|
|
|
|
var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions);
|
2014-01-23 13:05:41 -05:00
|
|
|
|
|
2014-06-19 11:41:58 -04:00
|
|
|
|
// If isEncoding is true we're actually starting ffmpeg
|
2014-06-10 13:36:06 -04:00
|
|
|
|
var startNumberParam = isEncoding ? GetStartNumber(state).ToString(UsCulture) : "0";
|
2014-04-14 23:54:52 -04:00
|
|
|
|
|
2014-07-01 17:13:32 -04:00
|
|
|
|
var baseUrlParam = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
if (state.Request is GetLiveHlsStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
baseUrlParam = string.Format(" -hls_base_url \"{0}/\"",
|
|
|
|
|
|
"hls/" + Path.GetFileNameWithoutExtension(outputPath));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-06 15:09:17 -05:00
|
|
|
|
var useGenericSegmenter = false;
|
|
|
|
|
|
if (useGenericSegmenter)
|
|
|
|
|
|
{
|
|
|
|
|
|
var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state);
|
|
|
|
|
|
|
|
|
|
|
|
var timeDeltaParam = String.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
return string.Format("{0} {1} -map_metadata -1 -map_chapters -1 -threads {2} {3} {4} {5} -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time {6} {10} -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"",
|
|
|
|
|
|
inputModifier,
|
2017-02-02 11:02:01 -05:00
|
|
|
|
EncodingHelper.GetInputArgument(state, encodingOptions),
|
2017-01-06 15:09:17 -05:00
|
|
|
|
threads,
|
2017-02-02 11:02:01 -05:00
|
|
|
|
EncodingHelper.GetMapArgs(state),
|
2017-01-06 15:09:17 -05:00
|
|
|
|
GetVideoArguments(state),
|
|
|
|
|
|
GetAudioArguments(state),
|
|
|
|
|
|
state.SegmentLength.ToString(UsCulture),
|
|
|
|
|
|
startNumberParam,
|
|
|
|
|
|
outputPath,
|
|
|
|
|
|
outputTsArg,
|
|
|
|
|
|
timeDeltaParam
|
|
|
|
|
|
).Trim();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-11-17 02:05:54 -05:00
|
|
|
|
// add when stream copying?
|
|
|
|
|
|
// -avoid_negative_ts make_zero -fflags +genpts
|
|
|
|
|
|
|
2017-01-06 15:09:17 -05:00
|
|
|
|
var args = string.Format("{0} {1} {2} -map_metadata -1 -map_chapters -1 -threads {3} {4} {5} -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero {6} -hls_time {7} -individual_header_trailer 0 -start_number {8} -hls_list_size {9}{10} -y \"{11}\"",
|
2013-09-19 16:03:14 -04:00
|
|
|
|
itsOffset,
|
2014-01-21 20:37:01 -05:00
|
|
|
|
inputModifier,
|
2017-02-02 11:02:01 -05:00
|
|
|
|
EncodingHelper.GetInputArgument(state, encodingOptions),
|
2013-12-15 14:39:21 -05:00
|
|
|
|
threads,
|
2017-02-02 11:02:01 -05:00
|
|
|
|
EncodingHelper.GetMapArgs(state),
|
2014-06-10 13:36:06 -04:00
|
|
|
|
GetVideoArguments(state),
|
2013-02-27 18:33:40 -05:00
|
|
|
|
GetAudioArguments(state),
|
2014-01-12 16:32:13 -05:00
|
|
|
|
state.SegmentLength.ToString(UsCulture),
|
2014-01-23 13:05:41 -05:00
|
|
|
|
startNumberParam,
|
2014-03-03 23:58:19 -05:00
|
|
|
|
state.HlsListSize.ToString(UsCulture),
|
2014-07-01 17:13:32 -04:00
|
|
|
|
baseUrlParam,
|
2013-08-28 18:05:00 -04:00
|
|
|
|
outputPath
|
2013-02-20 20:33:05 -05:00
|
|
|
|
).Trim();
|
2013-08-28 18:05:00 -04:00
|
|
|
|
|
|
|
|
|
|
return args;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
}
|
2014-01-23 13:05:41 -05:00
|
|
|
|
|
2016-10-22 15:21:50 -04:00
|
|
|
|
protected override string GetDefaultH264Preset()
|
|
|
|
|
|
{
|
|
|
|
|
|
return "veryfast";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-01-23 13:05:41 -05:00
|
|
|
|
protected virtual int GetStartNumber(StreamState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2015-08-27 11:58:07 -04:00
|
|
|
|
|
2016-11-10 09:41:24 -05:00
|
|
|
|
public BaseHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2013-02-20 20:33:05 -05:00
|
|
|
|
}
|
2015-09-20 13:56:26 -04:00
|
|
|
|
}
|