mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-18 20:24:20 +01:00
Refactor copy codec checks
This commit is contained in:
@@ -284,8 +284,8 @@ namespace MediaBrowser.Api
|
||||
Width = state.OutputWidth,
|
||||
Height = state.OutputHeight,
|
||||
AudioChannels = state.OutputAudioChannels,
|
||||
IsAudioDirect = string.Equals(state.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase),
|
||||
IsVideoDirect = string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase),
|
||||
IsAudioDirect = EncodingHelper.IsCopyCodec(state.OutputAudioCodec),
|
||||
IsVideoDirect = EncodingHelper.IsCopyCodec(state.OutputVideoCodec),
|
||||
TranscodeReasons = state.TranscodeReasons
|
||||
});
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
await AcquireResources(state, cancellationTokenSource).ConfigureAwait(false);
|
||||
|
||||
if (state.VideoRequest != null && !string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
if (state.VideoRequest != null && !EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
|
||||
{
|
||||
var auth = AuthorizationContext.GetAuthorizationInfo(Request);
|
||||
if (auth.User != null && !auth.User.Policy.EnableVideoPlaybackTranscoding)
|
||||
@@ -243,9 +243,9 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
var logFilePrefix = "ffmpeg-transcode";
|
||||
if (state.VideoRequest != null
|
||||
&& string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
&& EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
|
||||
{
|
||||
logFilePrefix = string.Equals(state.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase)
|
||||
logFilePrefix = EncodingHelper.IsCopyCodec(state.OutputAudioCodec)
|
||||
? "ffmpeg-remux" : "ffmpeg-directstream";
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace MediaBrowser.Api.Playback
|
||||
state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks &&
|
||||
state.IsInputVideo &&
|
||||
state.VideoType == VideoType.VideoFile &&
|
||||
!string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase);
|
||||
!EncodingHelper.IsCopyCodec(state.OutputVideoCodec);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -791,7 +791,7 @@ namespace MediaBrowser.Api.Playback
|
||||
EncodingHelper.TryStreamCopy(state);
|
||||
}
|
||||
|
||||
if (state.OutputVideoBitrate.HasValue && !string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
if (state.OutputVideoBitrate.HasValue && !EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
|
||||
{
|
||||
var resolution = ResolutionNormalizer.Normalize(
|
||||
state.VideoStream?.BitRate,
|
||||
|
||||
@@ -700,12 +700,12 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.Equals(state.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
if (EncodingHelper.IsCopyCodec(state.OutputAudioCodec))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -728,7 +728,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
private int? GetOutputVideoCodecLevel(StreamState state)
|
||||
{
|
||||
string levelString;
|
||||
if (string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase)
|
||||
if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
|
||||
&& state.VideoStream.Level.HasValue)
|
||||
{
|
||||
levelString = state.VideoStream?.Level.ToString();
|
||||
@@ -1008,7 +1008,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
if (!state.IsOutputVideo)
|
||||
{
|
||||
if (string.Equals(audioCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
if (EncodingHelper.IsCopyCodec(audioCodec))
|
||||
{
|
||||
return "-acodec copy";
|
||||
}
|
||||
@@ -1036,11 +1036,11 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
return string.Join(" ", audioTranscodeParams.ToArray());
|
||||
}
|
||||
|
||||
if (string.Equals(audioCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
if (EncodingHelper.IsCopyCodec(audioCodec))
|
||||
{
|
||||
var videoCodec = EncodingHelper.GetVideoEncoder(state, encodingOptions);
|
||||
|
||||
if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase) && state.EnableBreakOnNonKeyFrames(videoCodec))
|
||||
if (EncodingHelper.IsCopyCodec(videoCodec) && state.EnableBreakOnNonKeyFrames(videoCodec))
|
||||
{
|
||||
return "-codec:a:0 copy -copypriorss:a:0 0";
|
||||
}
|
||||
@@ -1091,7 +1091,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
// }
|
||||
|
||||
// See if we can save come cpu cycles by avoiding encoding
|
||||
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
if (EncodingHelper.IsCopyCodec(codec))
|
||||
{
|
||||
if (state.VideoStream != null && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
var codec = EncodingHelper.GetAudioEncoder(state);
|
||||
|
||||
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
if (EncodingHelper.IsCopyCodec(codec))
|
||||
{
|
||||
return "-codec:a:0 copy";
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace MediaBrowser.Api.Playback
|
||||
return Request.SegmentLength.Value;
|
||||
}
|
||||
|
||||
if (string.Equals(OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
if (EncodingHelper.IsCopyCodec(OutputVideoCodec))
|
||||
{
|
||||
var userAgent = UserAgent ?? string.Empty;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user