increase unification of param building

This commit is contained in:
Luke Pulverenti
2017-03-19 02:10:11 -04:00
parent 41060c9a38
commit 59ac045c6b
12 changed files with 98 additions and 130 deletions

View File

@@ -109,11 +109,13 @@ namespace MediaBrowser.Api.Playback.Hls
public Task<object> Get(GetHlsVideoSegmentLegacy request)
{
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
file = Path.Combine(_config.ApplicationPaths.TranscodingTempPath, file);
var transcodeFolderPath = _config.ApplicationPaths.TranscodingTempPath;
file = Path.Combine(transcodeFolderPath, file);
var normalizedPlaylistId = request.PlaylistId;
var playlistPath = _fileSystem.GetFilePaths(_config.ApplicationPaths.TranscodingTempPath)
var playlistPath = _fileSystem.GetFilePaths(transcodeFolderPath)
.FirstOrDefault(i => string.Equals(Path.GetExtension(i), ".m3u8", StringComparison.OrdinalIgnoreCase) && i.IndexOf(normalizedPlaylistId, StringComparison.OrdinalIgnoreCase) != -1);
return GetFileResult(file, playlistPath);

View File

@@ -15,9 +15,6 @@ using System.Globalization;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Services;
namespace MediaBrowser.Api.Playback.Progressive

View File

@@ -1,4 +1,3 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
@@ -9,12 +8,8 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Services;
@@ -116,11 +111,6 @@ namespace MediaBrowser.Api.Playback.Progressive
var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions);
var subtitleArguments = state.SubtitleStream != null &&
state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Embed
? GetSubtitleArguments(state)
: string.Empty;
return string.Format("{0} {1}{2} {3} {4} -map_metadata -1 -map_chapters -1 -threads {5} {6}{7}{8} -y \"{9}\"",
inputModifier,
EncodingHelper.GetInputArgument(state, encodingOptions),
@@ -128,30 +118,13 @@ namespace MediaBrowser.Api.Playback.Progressive
EncodingHelper.GetMapArgs(state),
GetVideoArguments(state, videoCodec),
threads,
GetAudioArguments(state),
subtitleArguments,
EncodingHelper.GetProgressiveVideoAudioArguments(state, encodingOptions),
EncodingHelper.GetSubtitleEmbedArguments(state),
format,
outputPath
).Trim();
}
private string GetSubtitleArguments(StreamState state)
{
var format = state.SupportedSubtitleCodecs.FirstOrDefault();
string codec;
if (string.IsNullOrWhiteSpace(format) || string.Equals(format, state.SubtitleStream.Codec, StringComparison.OrdinalIgnoreCase))
{
codec = "copy";
}
else
{
codec = format;
}
return " -codec:s:0 " + codec;
}
/// <summary>
/// Gets video arguments to pass to ffmpeg
/// </summary>
@@ -233,48 +206,5 @@ namespace MediaBrowser.Api.Playback.Progressive
return args;
}
/// <summary>
/// Gets audio arguments to pass to ffmpeg
/// </summary>
/// <param name="state">The state.</param>
/// <returns>System.String.</returns>
private string GetAudioArguments(StreamState state)
{
// If the video doesn't have an audio stream, return a default.
if (state.AudioStream == null && state.VideoStream != null)
{
return string.Empty;
}
// Get the output codec name
var codec = EncodingHelper.GetAudioEncoder(state);
var args = "-codec:a:0 " + codec;
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
{
return args;
}
// Add the number of audio channels
var channels = state.OutputAudioChannels;
if (channels.HasValue)
{
args += " -ac " + channels.Value;
}
var bitrate = state.OutputAudioBitrate;
if (bitrate.HasValue)
{
args += " -ab " + bitrate.Value.ToString(UsCulture);
}
args += " " + EncodingHelper.GetAudioFilterParam(state, ApiEntryPoint.Instance.GetEncodingOptions(), false);
return args;
}
}
}

View File

@@ -32,8 +32,6 @@ namespace MediaBrowser.Api.Playback
[ApiMember(Name = "AudioCodec", Description = "Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string AudioCodec { get; set; }
public string SubtitleCodec { get; set; }
[ApiMember(Name = "DeviceProfileId", Description = "Optional. The dlna device profile id to utilize.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string DeviceProfileId { get; set; }

View File

@@ -120,7 +120,6 @@ namespace MediaBrowser.Api.Playback
}
}
public List<string> SupportedSubtitleCodecs { get; set; }
public string UserAgent { get; set; }
public TranscodingJobType TranscodingType { get; set; }
@@ -129,7 +128,6 @@ namespace MediaBrowser.Api.Playback
{
_mediaSourceManager = mediaSourceManager;
_logger = logger;
SupportedSubtitleCodecs = new List<string>();
TranscodingType = transcodingType;
}
@@ -209,7 +207,6 @@ namespace MediaBrowser.Api.Playback
}
public string OutputFilePath { get; set; }
public int? OutputAudioBitrate;
public string ActualOutputVideoCodec
{