mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 02:18:54 -07:00
pass around encoding options
This commit is contained in:
parent
4aaf3499bd
commit
d500998d78
@ -22,6 +22,7 @@ using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Diagnostics;
|
||||
|
||||
namespace MediaBrowser.Api.Playback
|
||||
@ -100,11 +101,7 @@ namespace MediaBrowser.Api.Playback
|
||||
/// <summary>
|
||||
/// Gets the command line arguments.
|
||||
/// </summary>
|
||||
/// <param name="outputPath">The output path.</param>
|
||||
/// <param name="state">The state.</param>
|
||||
/// <param name="isEncoding">if set to <c>true</c> [is encoding].</param>
|
||||
/// <returns>System.String.</returns>
|
||||
protected abstract string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding);
|
||||
protected abstract string GetCommandLineArguments(string outputPath, EncodingOptions encodingOptions, StreamState state, bool isEncoding);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the transcoding job.
|
||||
@ -125,11 +122,11 @@ namespace MediaBrowser.Api.Playback
|
||||
/// <summary>
|
||||
/// Gets the output file path.
|
||||
/// </summary>
|
||||
private string GetOutputFilePath(StreamState state, string outputFileExtension)
|
||||
private string GetOutputFilePath(StreamState state, EncodingOptions encodingOptions, string outputFileExtension)
|
||||
{
|
||||
var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath;
|
||||
|
||||
var data = GetCommandLineArguments("dummy\\dummy", state, false);
|
||||
var data = GetCommandLineArguments("dummy\\dummy", encodingOptions, state, false);
|
||||
|
||||
data += "-" + (state.Request.DeviceId ?? string.Empty);
|
||||
data += "-" + (state.Request.PlaySessionId ?? string.Empty);
|
||||
@ -217,8 +214,10 @@ namespace MediaBrowser.Api.Playback
|
||||
}
|
||||
}
|
||||
|
||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
||||
|
||||
var transcodingId = Guid.NewGuid().ToString("N");
|
||||
var commandLineArgs = GetCommandLineArguments(outputPath, state, true);
|
||||
var commandLineArgs = GetCommandLineArguments(outputPath, encodingOptions, state, true);
|
||||
|
||||
var process = ApiEntryPoint.Instance.ProcessFactory.Create(new ProcessOptions
|
||||
{
|
||||
@ -826,7 +825,10 @@ namespace MediaBrowser.Api.Playback
|
||||
var ext = string.IsNullOrWhiteSpace(state.OutputContainer)
|
||||
? GetOutputFileExtension(state)
|
||||
: ("." + state.OutputContainer);
|
||||
state.OutputFilePath = GetOutputFilePath(state, ext);
|
||||
|
||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
||||
|
||||
state.OutputFilePath = GetOutputFilePath(state, encodingOptions, ext);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
|
||||
namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
@ -25,15 +26,12 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
/// <summary>
|
||||
/// Gets the audio arguments.
|
||||
/// </summary>
|
||||
/// <param name="state">The state.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
protected abstract string GetAudioArguments(StreamState state);
|
||||
protected abstract string GetAudioArguments(StreamState state, EncodingOptions encodingOptions);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the video arguments.
|
||||
/// </summary>
|
||||
/// <param name="state">The state.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
protected abstract string GetVideoArguments(StreamState state);
|
||||
protected abstract string GetVideoArguments(StreamState state, EncodingOptions encodingOptions);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the segment file extension.
|
||||
@ -242,10 +240,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding)
|
||||
protected override string GetCommandLineArguments(string outputPath, EncodingOptions encodingOptions, StreamState state, bool isEncoding)
|
||||
{
|
||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
||||
|
||||
var itsOffsetMs = 0;
|
||||
|
||||
var itsOffset = itsOffsetMs == 0 ? string.Empty : string.Format("-itsoffset {0} ", TimeSpan.FromMilliseconds(itsOffsetMs).TotalSeconds.ToString(UsCulture));
|
||||
@ -285,8 +281,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
EncodingHelper.GetInputArgument(state, encodingOptions),
|
||||
threads,
|
||||
EncodingHelper.GetMapArgs(state),
|
||||
GetVideoArguments(state),
|
||||
GetAudioArguments(state),
|
||||
GetVideoArguments(state, encodingOptions),
|
||||
GetAudioArguments(state, encodingOptions),
|
||||
state.SegmentLength.ToString(UsCulture),
|
||||
startNumberParam,
|
||||
outputPath,
|
||||
@ -306,8 +302,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
EncodingHelper.GetInputArgument(state, encodingOptions),
|
||||
threads,
|
||||
EncodingHelper.GetMapArgs(state),
|
||||
GetVideoArguments(state),
|
||||
GetAudioArguments(state),
|
||||
GetVideoArguments(state, encodingOptions),
|
||||
GetAudioArguments(state, encodingOptions),
|
||||
state.SegmentLength.ToString(UsCulture),
|
||||
startNumberParam,
|
||||
state.HlsListSize.ToString(UsCulture),
|
||||
|
@ -18,6 +18,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Services;
|
||||
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||
|
||||
@ -777,7 +778,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||
}
|
||||
|
||||
protected override string GetAudioArguments(StreamState state)
|
||||
protected override string GetAudioArguments(StreamState state, EncodingOptions encodingOptions)
|
||||
{
|
||||
var audioCodec = EncodingHelper.GetAudioEncoder(state);
|
||||
|
||||
@ -813,7 +814,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
if (string.Equals(audioCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var videoCodec = EncodingHelper.GetVideoEncoder(state, ApiEntryPoint.Instance.GetEncodingOptions());
|
||||
var videoCodec = EncodingHelper.GetVideoEncoder(state, encodingOptions);
|
||||
|
||||
if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase) && state.EnableBreakOnNonKeyFrames(videoCodec))
|
||||
{
|
||||
@ -844,19 +845,19 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
args += " -ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture);
|
||||
}
|
||||
|
||||
args += " " + EncodingHelper.GetAudioFilterParam(state, ApiEntryPoint.Instance.GetEncodingOptions(), true);
|
||||
args += " " + EncodingHelper.GetAudioFilterParam(state, encodingOptions, true);
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
protected override string GetVideoArguments(StreamState state)
|
||||
protected override string GetVideoArguments(StreamState state, EncodingOptions encodingOptions)
|
||||
{
|
||||
if (!state.IsOutputVideo)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var codec = EncodingHelper.GetVideoEncoder(state, ApiEntryPoint.Instance.GetEncodingOptions());
|
||||
var codec = EncodingHelper.GetVideoEncoder(state, encodingOptions);
|
||||
|
||||
var args = "-codec:v:0 " + codec;
|
||||
|
||||
@ -882,8 +883,6 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
|
||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
||||
|
||||
args += " " + EncodingHelper.GetVideoQualityParam(state, codec, encodingOptions, GetDefaultH264Preset()) + keyFrameArg;
|
||||
|
||||
//args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0";
|
||||
@ -918,9 +917,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
return args;
|
||||
}
|
||||
|
||||
protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding)
|
||||
protected override string GetCommandLineArguments(string outputPath, EncodingOptions encodingOptions, StreamState state, bool isEncoding)
|
||||
{
|
||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
||||
var threads = EncodingHelper.GetNumberOfThreads(state, encodingOptions, false);
|
||||
|
||||
var inputModifier = EncodingHelper.GetInputModifier(state, encodingOptions);
|
||||
@ -947,7 +945,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
segmentFormat = "mpegts";
|
||||
}
|
||||
|
||||
var videoCodec = EncodingHelper.GetVideoEncoder(state, ApiEntryPoint.Instance.GetEncodingOptions());
|
||||
var videoCodec = EncodingHelper.GetVideoEncoder(state, encodingOptions);
|
||||
var breakOnNonKeyFrames = state.EnableBreakOnNonKeyFrames(videoCodec);
|
||||
|
||||
var breakOnNonKeyFramesArg = breakOnNonKeyFrames ? " -break_non_keyframes 1" : "";
|
||||
@ -957,8 +955,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
EncodingHelper.GetInputArgument(state, encodingOptions),
|
||||
threads,
|
||||
mapArgs,
|
||||
GetVideoArguments(state),
|
||||
GetAudioArguments(state),
|
||||
GetVideoArguments(state, encodingOptions),
|
||||
GetAudioArguments(state, encodingOptions),
|
||||
state.SegmentLength.ToString(UsCulture),
|
||||
startNumberParam,
|
||||
outputPath,
|
||||
|
@ -7,6 +7,7 @@ using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Services;
|
||||
|
||||
@ -31,9 +32,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
/// <summary>
|
||||
/// Gets the audio arguments.
|
||||
/// </summary>
|
||||
/// <param name="state">The state.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
protected override string GetAudioArguments(StreamState state)
|
||||
protected override string GetAudioArguments(StreamState state, EncodingOptions encodingOptions)
|
||||
{
|
||||
var codec = EncodingHelper.GetAudioEncoder(state);
|
||||
|
||||
@ -63,7 +62,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
args += " -ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture);
|
||||
}
|
||||
|
||||
args += " " + EncodingHelper.GetAudioFilterParam(state, ApiEntryPoint.Instance.GetEncodingOptions(), true);
|
||||
args += " " + EncodingHelper.GetAudioFilterParam(state, encodingOptions, true);
|
||||
|
||||
return args;
|
||||
}
|
||||
@ -71,16 +70,14 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
/// <summary>
|
||||
/// Gets the video arguments.
|
||||
/// </summary>
|
||||
/// <param name="state">The state.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
protected override string GetVideoArguments(StreamState state)
|
||||
protected override string GetVideoArguments(StreamState state, EncodingOptions encodingOptions)
|
||||
{
|
||||
if (!state.IsOutputVideo)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var codec = EncodingHelper.GetVideoEncoder(state, ApiEntryPoint.Instance.GetEncodingOptions());
|
||||
var codec = EncodingHelper.GetVideoEncoder(state, encodingOptions);
|
||||
|
||||
var args = "-codec:v:0 " + codec;
|
||||
|
||||
@ -106,7 +103,6 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
|
||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
||||
args += " " + EncodingHelper.GetVideoQualityParam(state, codec, encodingOptions, GetDefaultH264Preset()) + keyFrameArg;
|
||||
|
||||
// Add resolution params, if specified
|
||||
|
@ -10,6 +10,7 @@ using MediaBrowser.Model.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Services;
|
||||
using MediaBrowser.Model.System;
|
||||
@ -58,10 +59,8 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
return ProcessRequest(request, true);
|
||||
}
|
||||
|
||||
protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding)
|
||||
protected override string GetCommandLineArguments(string outputPath, EncodingOptions encodingOptions, StreamState state, bool isEncoding)
|
||||
{
|
||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
||||
|
||||
return EncodingHelper.GetProgressiveAudioFullCommandLine(state, encodingOptions, outputPath);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Services;
|
||||
using MediaBrowser.Model.System;
|
||||
|
||||
@ -91,10 +92,8 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
return ProcessRequest(request, true);
|
||||
}
|
||||
|
||||
protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding)
|
||||
protected override string GetCommandLineArguments(string outputPath, EncodingOptions encodingOptions, StreamState state, bool isEncoding)
|
||||
{
|
||||
var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
|
||||
|
||||
return EncodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, outputPath, GetDefaultH264Preset());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user