From 9da48106c893bf179a00db7dadbb74f513277263 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 29 Dec 2016 16:50:53 -0500 Subject: update logging --- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 89730a11f..c26664921 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -533,8 +533,10 @@ namespace MediaBrowser.MediaEncoding.Encoder probeSize = probeSize + " " + analyzeDuration; probeSize = probeSize.Trim(); + var forceEnableLogging = request.Protocol != MediaProtocol.File; + return GetMediaInfoInternal(GetInputArgument(inputFiles, request.Protocol), request.InputPath, request.Protocol, extractChapters, - probeSize, request.MediaType == DlnaProfileType.Audio, request.VideoType, cancellationToken); + probeSize, request.MediaType == DlnaProfileType.Audio, request.VideoType, forceEnableLogging, cancellationToken); } /// @@ -577,14 +579,6 @@ namespace MediaBrowser.MediaEncoding.Encoder /// /// Gets the media info internal. /// - /// The input path. - /// The primary path. - /// The protocol. - /// if set to true [extract chapters]. - /// The probe size argument. - /// if set to true [is audio]. - /// Type of the video. - /// The cancellation token. /// Task{MediaInfoResult}. private async Task GetMediaInfoInternal(string inputPath, string primaryPath, @@ -593,6 +587,7 @@ namespace MediaBrowser.MediaEncoding.Encoder string probeSizeArgument, bool isAudio, VideoType videoType, + bool forceEnableLogging, CancellationToken cancellationToken) { var args = extractChapters @@ -614,7 +609,14 @@ namespace MediaBrowser.MediaEncoding.Encoder EnableRaisingEvents = true }); - _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + if (forceEnableLogging) + { + _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + } + else + { + _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + } using (var processWrapper = new ProcessWrapper(process, this, _logger)) { -- cgit v1.2.3 From dbba636290bb004392d4e675322d00d40a31b46f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 1 Jan 2017 15:47:54 -0500 Subject: handle unknown video stream --- .../Connect/ConnectEntryPoint.cs | 18 ++++++++++++++---- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 3 ++- MediaBrowser.Api/Playback/BaseStreamingService.cs | 3 ++- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/Emby.Server.Implementations/Connect/ConnectEntryPoint.cs b/Emby.Server.Implementations/Connect/ConnectEntryPoint.cs index 170ef07f3..7f15f20cb 100644 --- a/Emby.Server.Implementations/Connect/ConnectEntryPoint.cs +++ b/Emby.Server.Implementations/Connect/ConnectEntryPoint.cs @@ -9,6 +9,7 @@ using System; using System.IO; using System.Text; using System.Threading.Tasks; +using MediaBrowser.Controller.Security; using MediaBrowser.Model.IO; using MediaBrowser.Model.Threading; @@ -26,8 +27,9 @@ namespace Emby.Server.Implementations.Connect private readonly IApplicationHost _appHost; private readonly IFileSystem _fileSystem; private readonly ITimerFactory _timerFactory; + private readonly IEncryptionManager _encryption; - public ConnectEntryPoint(IHttpClient httpClient, IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager, IConnectManager connectManager, IApplicationHost appHost, IFileSystem fileSystem, ITimerFactory timerFactory) + public ConnectEntryPoint(IHttpClient httpClient, IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager, IConnectManager connectManager, IApplicationHost appHost, IFileSystem fileSystem, ITimerFactory timerFactory, IEncryptionManager encryption) { _httpClient = httpClient; _appPaths = appPaths; @@ -37,6 +39,7 @@ namespace Emby.Server.Implementations.Connect _appHost = appHost; _fileSystem = fileSystem; _timerFactory = timerFactory; + _encryption = encryption; } public void Run() @@ -143,7 +146,7 @@ namespace Emby.Server.Implementations.Connect private string CacheFilePath { - get { return Path.Combine(_appPaths.DataPath, "wan.txt"); } + get { return Path.Combine(_appPaths.DataPath, "wan.dat"); } } private void CacheAddress(IpAddressInfo address) @@ -153,7 +156,14 @@ namespace Emby.Server.Implementations.Connect try { _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); - _fileSystem.WriteAllText(path, address.ToString(), Encoding.UTF8); + } + catch (Exception ex) + { + } + + try + { + _fileSystem.WriteAllText(path, _encryption.EncryptString(address.ToString()), Encoding.UTF8); } catch (Exception ex) { @@ -169,7 +179,7 @@ namespace Emby.Server.Implementations.Connect try { - var endpoint = _fileSystem.ReadAllText(path, Encoding.UTF8); + var endpoint = _encryption.DecryptString(_fileSystem.ReadAllText(path, Encoding.UTF8)); IpAddressInfo ipAddress; if (_networkManager.TryParseIpAddress(endpoint, out ipAddress)) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 77efe8585..c2abf1d34 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -103,7 +103,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun TunerHostId = info.Id, IsHD = i.HD == 1, AudioCodec = i.AudioCodec, - VideoCodec = i.VideoCodec + VideoCodec = i.VideoCodec, + ChannelType = ChannelType.TV }); } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 17997f47a..430504a48 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -205,7 +205,8 @@ namespace MediaBrowser.Api.Playback } else { - args += "-map -0:v"; + // No known video stream + args += "-vn"; } if (state.AudioStream != null) diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 80bbc87e3..1121aeab9 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -896,7 +896,8 @@ namespace MediaBrowser.MediaEncoding.Encoder } else { - args += "-map -0:v"; + // No known video stream + args += "-vn"; } if (state.AudioStream != null) -- cgit v1.2.3 From c0ddeaab774c7280514556a01f983eef2cc49e0f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 2 Jan 2017 18:15:16 -0500 Subject: update maxrate --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 10 +++++++++- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 430504a48..1ad472038 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1496,8 +1496,16 @@ namespace MediaBrowser.Api.Playback return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); } + if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase)) + { + // h264 + return string.Format(" -maxrate {0} -bufsize {1}", + bitrate.Value.ToString(UsCulture), + (bitrate.Value * 2).ToString(UsCulture)); + } + // h264 - return string.Format(" -maxrate {0} -bufsize {1}", + return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", bitrate.Value.ToString(UsCulture), (bitrate.Value * 2).ToString(UsCulture)); } diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 1121aeab9..7654ec1d7 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -827,8 +827,16 @@ namespace MediaBrowser.MediaEncoding.Encoder return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); } + if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase)) + { + // h264 + return string.Format(" -maxrate {0} -bufsize {1}", + bitrate.Value.ToString(UsCulture), + (bitrate.Value * 2).ToString(UsCulture)); + } + // h264 - return string.Format(" -maxrate {0} -bufsize {1}", + return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", bitrate.Value.ToString(UsCulture), (bitrate.Value * 2).ToString(UsCulture)); } -- cgit v1.2.3 From 80a9bbf5ef624c7e60835649192aaeeb521a7472 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 18 Jan 2017 01:05:33 -0500 Subject: support rtp protocol --- .../LiveTv/TunerHosts/M3UTunerHost.cs | 4 ++++ MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs | 20 +------------------- MediaBrowser.Model/MediaInfo/MediaProtocol.cs | 3 ++- 3 files changed, 7 insertions(+), 20 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 05d71214e..7954b86ba 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -127,6 +127,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { protocol = MediaProtocol.Udp; } + else if (path.StartsWith("rtp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtmp; + } var mediaSource = new MediaSourceInfo { diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs index cec272b39..e547f2fae 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs @@ -8,25 +8,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { public static string GetInputArgument(List inputFiles, MediaProtocol protocol) { - if (protocol == MediaProtocol.Http) - { - var url = inputFiles.First(); - - return string.Format("\"{0}\"", url); - } - if (protocol == MediaProtocol.Rtmp) - { - var url = inputFiles.First(); - - return string.Format("\"{0}\"", url); - } - if (protocol == MediaProtocol.Rtsp) - { - var url = inputFiles.First(); - - return string.Format("\"{0}\"", url); - } - if (protocol == MediaProtocol.Udp) + if (protocol != MediaProtocol.File) { var url = inputFiles.First(); diff --git a/MediaBrowser.Model/MediaInfo/MediaProtocol.cs b/MediaBrowser.Model/MediaInfo/MediaProtocol.cs index 1474e6d96..efb31790b 100644 --- a/MediaBrowser.Model/MediaInfo/MediaProtocol.cs +++ b/MediaBrowser.Model/MediaInfo/MediaProtocol.cs @@ -6,6 +6,7 @@ namespace MediaBrowser.Model.MediaInfo Http = 1, Rtmp = 2, Rtsp = 3, - Udp = 4 + Udp = 4, + Rtp = 5 } } \ No newline at end of file -- cgit v1.2.3 From 8d668095bb663c51083b97eb61b09811cb97575b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 20 Jan 2017 12:53:48 -0500 Subject: add IsRemote property --- .../Data/SqliteItemRepository.cs | 6 ++-- .../LiveTv/EmbyTV/EncodedRecorder.cs | 39 ++++++++++++++++++++-- .../LiveTv/TunerHosts/M3UTunerHost.cs | 3 +- .../Channels/ChannelMediaInfo.cs | 3 +- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 12 +++---- MediaBrowser.Model/Dto/MediaSourceInfo.cs | 5 +++ MediaBrowser.Model/Entities/MediaStream.cs | 5 +++ 7 files changed, 61 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder') diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 5809d84fd..af1594cf7 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -3617,10 +3617,12 @@ namespace Emby.Server.Implementations.Data var index = 0; foreach (var type in query.TrailerTypes) { - clauses.Add("TrailerTypes like @TrailerTypes" + index); + var paramName = "@TrailerTypes" + index; + + clauses.Add("TrailerTypes like " + paramName); if (statement != null) { - statement.TryBind("@TrailerTypes" + index, "%" + type + "%"); + statement.TryBind(paramName, "%" + type + "%"); } index++; } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index 5e55b893f..beb08cc25 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -240,14 +240,49 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { try { - _logger.Info("Killing ffmpeg recording process for {0}", _targetPath); + _logger.Info("Stopping ffmpeg recording process for {0}", _targetPath); //process.Kill(); _process.StandardInput.WriteLine("q"); } catch (Exception ex) { - _logger.ErrorException("Error killing transcoding job for {0}", ex, _targetPath); + _logger.ErrorException("Error stopping recording transcoding job for {0}", ex, _targetPath); + } + + if (_hasExited) + { + return; + } + + try + { + _logger.Info("Calling recording process.WaitForExit for {0}", _targetPath); + + if (_process.WaitForExit(5000)) + { + return; + } + } + catch (Exception ex) + { + _logger.ErrorException("Error waiting for recording process to exit for {0}", ex, _targetPath); + } + + if (_hasExited) + { + return; + } + + try + { + _logger.Info("Killing ffmpeg recording process for {0}", _targetPath); + + _process.Kill(); + } + catch (Exception ex) + { + _logger.ErrorException("Error killing recording transcoding job for {0}", ex, _targetPath); } } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 7954b86ba..449a4104f 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -160,7 +160,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts Id = channel.Path.GetMD5().ToString("N"), IsInfiniteStream = true, - SupportsDirectStream = false + SupportsDirectStream = false, + IsRemote = true }; return new List { mediaSource }; diff --git a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs index 6d2190680..eda6ee1af 100644 --- a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs +++ b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs @@ -68,7 +68,8 @@ namespace MediaBrowser.Controller.Channels Id = id, ReadAtNativeFramerate = ReadAtNativeFramerate, SupportsDirectStream = false, - SupportsDirectPlay = SupportsDirectPlay + SupportsDirectPlay = SupportsDirectPlay, + IsRemote = true }; var bitrate = (AudioBitrate ?? 0) + (VideoBitrate ?? 0); diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index c26664921..6a5945b76 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -1250,8 +1250,8 @@ namespace MediaBrowser.MediaEncoding.Encoder lock (_runningProcesses) { proceses = _runningProcesses.ToList(); + _runningProcesses.Clear(); } - _runningProcesses.Clear(); foreach (var process in proceses) { @@ -1321,16 +1321,16 @@ namespace MediaBrowser.MediaEncoding.Encoder { } - lock (_mediaEncoder._runningProcesses) - { - _mediaEncoder._runningProcesses.Remove(this); - } - DisposeProcess(process); } private void DisposeProcess(IProcess process) { + lock (_mediaEncoder._runningProcesses) + { + _mediaEncoder._runningProcesses.Remove(this); + } + try { process.Dispose(); diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 814368d32..4f93f476f 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -21,6 +21,11 @@ namespace MediaBrowser.Model.Dto public string Name { get; set; } + /// + /// Differentiate internet url vs local network + /// + public bool IsRemote { get; set; } + public string ETag { get; set; } public long? RunTimeTicks { get; set; } public bool ReadAtNativeFramerate { get; set; } diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index 85f475ca2..0eb9e2730 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -92,6 +92,11 @@ namespace MediaBrowser.Model.Entities { attributes.Add(StringHelper.FirstToUpper(Language)); } + else + { + attributes.Add("Und"); + } + if (IsDefault) { attributes.Add("Default"); -- cgit v1.2.3