update NAL usage

This commit is contained in:
Luke Pulverenti 2016-04-18 13:43:00 -04:00
parent d9afd21ef5
commit 98cfbd99ad
6 changed files with 20 additions and 6 deletions

View File

@ -828,7 +828,7 @@ namespace MediaBrowser.Api.Playback.Hls
// See if we can save come cpu cycles by avoiding encoding // See if we can save come cpu cycles by avoiding encoding
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
{ {
if (state.VideoStream != null && IsH264(state.VideoStream) && !string.IsNullOrWhiteSpace(state.VideoStream.NalLengthSize)) if (state.VideoStream != null && IsH264(state.VideoStream) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{ {
Logger.Debug("Enabling h264_mp4toannexb due to nal_length_size of {0}", state.VideoStream.NalLengthSize); Logger.Debug("Enabling h264_mp4toannexb due to nal_length_size of {0}", state.VideoStream.NalLengthSize);
args += " -bsf:v h264_mp4toannexb"; args += " -bsf:v h264_mp4toannexb";

View File

@ -87,7 +87,7 @@ namespace MediaBrowser.Api.Playback.Hls
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase)) if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
{ {
// if h264_mp4toannexb is ever added, do not use it for live tv // if h264_mp4toannexb is ever added, do not use it for live tv
if (state.VideoStream != null && IsH264(state.VideoStream) && !string.IsNullOrWhiteSpace(state.VideoStream.NalLengthSize)) if (state.VideoStream != null && IsH264(state.VideoStream) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{ {
Logger.Debug("Enabling h264_mp4toannexb due to nal_length_size of {0}", state.VideoStream.NalLengthSize); Logger.Debug("Enabling h264_mp4toannexb due to nal_length_size of {0}", state.VideoStream.NalLengthSize);
args += " -bsf:v h264_mp4toannexb"; args += " -bsf:v h264_mp4toannexb";

View File

@ -139,7 +139,7 @@ namespace MediaBrowser.Api.Playback.Progressive
if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase)) if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase))
{ {
if (state.VideoStream != null && IsH264(state.VideoStream) && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(state.VideoStream.NalLengthSize)) if (state.VideoStream != null && IsH264(state.VideoStream) && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{ {
Logger.Debug("Enabling h264_mp4toannexb due to nal_length_size of {0}", state.VideoStream.NalLengthSize); Logger.Debug("Enabling h264_mp4toannexb due to nal_length_size of {0}", state.VideoStream.NalLengthSize);
args += " -bsf:v h264_mp4toannexb"; args += " -bsf:v h264_mp4toannexb";

View File

@ -73,7 +73,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase)) if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase))
{ {
if (state.VideoStream != null && IsH264(state.VideoStream) && string.Equals(state.Options.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(state.VideoStream.NalLengthSize)) if (state.VideoStream != null && IsH264(state.VideoStream) && string.Equals(state.Options.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{ {
Logger.Debug("Enabling h264_mp4toannexb due to nal_length_size of {0}", state.VideoStream.NalLengthSize); Logger.Debug("Enabling h264_mp4toannexb due to nal_length_size of {0}", state.VideoStream.NalLengthSize);
args += " -bsf:v h264_mp4toannexb"; args += " -bsf:v h264_mp4toannexb";

View File

@ -511,8 +511,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (!(service is EmbyTV.EmbyTV)) if (!(service is EmbyTV.EmbyTV))
{ {
// We can't trust that we'll be able to direct stream it through emby server, no matter what the provider says // We can't trust that we'll be able to direct stream it through emby server, no matter what the provider says
mediaSource.SupportsDirectStream = true; mediaSource.SupportsDirectStream = false;
mediaSource.SupportsTranscoding = true; mediaSource.SupportsTranscoding = true;
foreach (var stream in mediaSource.MediaStreams)
{
if (stream.Type == MediaStreamType.Video && string.IsNullOrWhiteSpace(stream.NalLengthSize))
{
stream.NalLengthSize = "0";
}
}
} }
} }

View File

@ -317,6 +317,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
videoCodec = "mpeg2video"; videoCodec = "mpeg2video";
} }
string nal = null;
if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase))
{
nal = "0";
}
var url = GetApiUrl(info, true) + "/auto/v" + channelId; var url = GetApiUrl(info, true) + "/auto/v" + channelId;
if (!string.IsNullOrWhiteSpace(profile) && !string.Equals(profile, "native", StringComparison.OrdinalIgnoreCase)) if (!string.IsNullOrWhiteSpace(profile) && !string.Equals(profile, "native", StringComparison.OrdinalIgnoreCase))
@ -339,7 +345,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
Codec = videoCodec, Codec = videoCodec,
Width = width, Width = width,
Height = height, Height = height,
BitRate = videoBitrate BitRate = videoBitrate,
NalLengthSize = nal
}, },
new MediaStream new MediaStream