improve ffmpeg cleanup
This commit is contained in:
parent
1b600aee37
commit
4f7e8fee24
|
@ -1161,12 +1161,10 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var locations = user.RootFolder
|
var folders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList();
|
||||||
.GetChildren(user, true)
|
var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList();
|
||||||
.OfType<CollectionFolder>()
|
|
||||||
.SelectMany(i => i.PhysicalLocations);
|
|
||||||
|
|
||||||
return locations.Any(l => FileSystem.ContainsSubPath(l, topParent.Path));
|
return itemCollectionFolders.Any(folders.Contains);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Controller.Channels;
|
using MediaBrowser.Controller.Channels;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
@ -74,6 +75,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
protected readonly Func<ISubtitleEncoder> SubtitleEncoder;
|
protected readonly Func<ISubtitleEncoder> SubtitleEncoder;
|
||||||
protected readonly Func<IMediaSourceManager> MediaSourceManager;
|
protected readonly Func<IMediaSourceManager> MediaSourceManager;
|
||||||
|
|
||||||
|
private List<Process> _runningProcesses = new List<Process>();
|
||||||
|
|
||||||
public MediaEncoder(ILogger logger, IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, string version, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ILiveTvManager liveTvManager, IIsoManager isoManager, ILibraryManager libraryManager, IChannelManager channelManager, ISessionManager sessionManager, Func<ISubtitleEncoder> subtitleEncoder, Func<IMediaSourceManager> mediaSourceManager)
|
public MediaEncoder(ILogger logger, IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, string version, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ILiveTvManager liveTvManager, IIsoManager isoManager, ILibraryManager libraryManager, IChannelManager channelManager, ISessionManager sessionManager, Func<ISubtitleEncoder> subtitleEncoder, Func<IMediaSourceManager> mediaSourceManager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
@ -192,7 +195,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
process.Start();
|
StartProcess(process);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -375,7 +378,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
process.Start();
|
StartProcess(process);
|
||||||
|
|
||||||
var memoryStream = new MemoryStream();
|
var memoryStream = new MemoryStream();
|
||||||
|
|
||||||
|
@ -391,18 +394,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
if (!ranToCompletion)
|
if (!ranToCompletion)
|
||||||
{
|
{
|
||||||
try
|
StopProcess(process, 1000, false);
|
||||||
{
|
|
||||||
_logger.Info("Killing ffmpeg process");
|
|
||||||
|
|
||||||
process.StandardInput.WriteLine("q");
|
|
||||||
|
|
||||||
process.WaitForExit(1000);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error killing process", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resourcePool.Release();
|
resourcePool.Release();
|
||||||
|
@ -426,31 +418,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
return memoryStream;
|
return memoryStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Stream> EncodeImage(ImageEncodingOptions options, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
|
||||||
protected virtual void Dispose(bool dispose)
|
|
||||||
{
|
|
||||||
if (dispose)
|
|
||||||
{
|
|
||||||
_videoImageResourcePool.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTimeParameter(long ticks)
|
public string GetTimeParameter(long ticks)
|
||||||
{
|
{
|
||||||
var time = TimeSpan.FromTicks(ticks);
|
var time = TimeSpan.FromTicks(ticks);
|
||||||
|
@ -519,7 +486,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
process.Start();
|
StartProcess(process);
|
||||||
|
|
||||||
// Need to give ffmpeg enough time to make all the thumbnails, which could be a while,
|
// Need to give ffmpeg enough time to make all the thumbnails, which could be a while,
|
||||||
// but we still need to detect if the process hangs.
|
// but we still need to detect if the process hangs.
|
||||||
|
@ -543,18 +510,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
if (!ranToCompletion)
|
if (!ranToCompletion)
|
||||||
{
|
{
|
||||||
try
|
StopProcess(process, 1000, false);
|
||||||
{
|
|
||||||
_logger.Info("Killing ffmpeg process");
|
|
||||||
|
|
||||||
process.StandardInput.WriteLine("q");
|
|
||||||
|
|
||||||
process.WaitForExit(1000);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error killing process", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -615,5 +571,78 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
|
|
||||||
return job.OutputFilePath;
|
return job.OutputFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StartProcess(Process process)
|
||||||
|
{
|
||||||
|
process.Start();
|
||||||
|
|
||||||
|
lock (_runningProcesses)
|
||||||
|
{
|
||||||
|
_runningProcesses.Add(process);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void StopProcess(Process process, int waitTimeMs, bool enableForceKill)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.Info("Killing ffmpeg process");
|
||||||
|
|
||||||
|
process.StandardInput.WriteLine("q");
|
||||||
|
|
||||||
|
if (!process.WaitForExit(1000))
|
||||||
|
{
|
||||||
|
if (enableForceKill)
|
||||||
|
{
|
||||||
|
process.Kill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error killing process", ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
lock (_runningProcesses)
|
||||||
|
{
|
||||||
|
_runningProcesses.Remove(process);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopProcesses()
|
||||||
|
{
|
||||||
|
List<Process> proceses;
|
||||||
|
lock (_runningProcesses)
|
||||||
|
{
|
||||||
|
proceses = _runningProcesses.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var process in proceses)
|
||||||
|
{
|
||||||
|
StopProcess(process, 500, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
|
protected virtual void Dispose(bool dispose)
|
||||||
|
{
|
||||||
|
if (dispose)
|
||||||
|
{
|
||||||
|
_videoImageResourcePool.Dispose();
|
||||||
|
StopProcesses();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ namespace MediaBrowser.Model.Dto
|
||||||
public string PreferredMetadataCountryCode { get; set; }
|
public string PreferredMetadataCountryCode { get; set; }
|
||||||
|
|
||||||
public string AwardSummary { get; set; }
|
public string AwardSummary { get; set; }
|
||||||
|
public string ShareUrl { get; set; }
|
||||||
|
|
||||||
public float? Metascore { get; set; }
|
public float? Metascore { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ namespace MediaBrowser.Model.Users
|
||||||
|
|
||||||
public int InvalidLoginAttemptCount { get; set; }
|
public int InvalidLoginAttemptCount { get; set; }
|
||||||
|
|
||||||
|
public bool EnablePublicSharing { get; set; }
|
||||||
|
|
||||||
public UserPolicy()
|
public UserPolicy()
|
||||||
{
|
{
|
||||||
EnableSync = true;
|
EnableSync = true;
|
||||||
|
@ -94,6 +96,7 @@ namespace MediaBrowser.Model.Users
|
||||||
EnableAllDevices = true;
|
EnableAllDevices = true;
|
||||||
|
|
||||||
EnableContentDownloading = true;
|
EnableContentDownloading = true;
|
||||||
|
EnablePublicSharing = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -517,7 +517,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||||
|
|
||||||
if (!connectUser.IsActive)
|
if (!connectUser.IsActive)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The Emby account has been disabled.");
|
throw new ArgumentException("The Emby account is not active. Please ensure the account has been activated by following the instructions within the email confirmation.");
|
||||||
}
|
}
|
||||||
|
|
||||||
connectUserId = connectUser.Id;
|
connectUserId = connectUser.Id;
|
||||||
|
|
|
@ -1513,7 +1513,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
return GetUserRootFolder().Children
|
return GetUserRootFolder().Children
|
||||||
.OfType<Folder>()
|
.OfType<Folder>()
|
||||||
.Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path));
|
.Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path, StringComparer.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetContentType(BaseItem item)
|
public string GetContentType(BaseItem item)
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
"TitleLiveTV": "Live TV",
|
"TitleLiveTV": "Live TV",
|
||||||
"TitleSync": "Sync",
|
"TitleSync": "Sync",
|
||||||
"ButtonDonate": "Donate",
|
"ButtonDonate": "Donate",
|
||||||
|
"HeaderMyMedia": "My Media",
|
||||||
"TitleNotifications": "Notifications",
|
"TitleNotifications": "Notifications",
|
||||||
"ErrorLaunchingChromecast": "There was an error launching chromecast. Please ensure your device is connected to your wireless network.",
|
"ErrorLaunchingChromecast": "There was an error launching chromecast. Please ensure your device is connected to your wireless network.",
|
||||||
"MessageErrorLoadingSupporterInfo": "There was an error loading supporter information. Please try again later.",
|
"MessageErrorLoadingSupporterInfo": "There was an error loading supporter information. Please try again later.",
|
||||||
|
|
|
@ -552,7 +552,7 @@
|
||||||
"LabelPublicHttpsPort": "Public https port number:",
|
"LabelPublicHttpsPort": "Public https port number:",
|
||||||
"LabelPublicHttpsPortHelp": "The public port number that should be mapped to the local https port.",
|
"LabelPublicHttpsPortHelp": "The public port number that should be mapped to the local https port.",
|
||||||
"LabelEnableHttps": "Report https as external address",
|
"LabelEnableHttps": "Report https as external address",
|
||||||
"LabelEnableHttpsHelp": "If enabled, the server will report an https url to clients as it's external address. This may break clients that do not yet support https.",
|
"LabelEnableHttpsHelp": "If enabled, the server will report an https url to clients as it's external address.",
|
||||||
"LabelHttpsPort": "Local https port number:",
|
"LabelHttpsPort": "Local https port number:",
|
||||||
"LabelHttpsPortHelp": "The tcp port number that Emby's https server should bind to.",
|
"LabelHttpsPortHelp": "The tcp port number that Emby's https server should bind to.",
|
||||||
"LabelWebSocketPortNumber": "Web socket port number:",
|
"LabelWebSocketPortNumber": "Web socket port number:",
|
||||||
|
@ -896,9 +896,9 @@
|
||||||
"LabelHomePageSection2": "Home page section 2:",
|
"LabelHomePageSection2": "Home page section 2:",
|
||||||
"LabelHomePageSection3": "Home page section 3:",
|
"LabelHomePageSection3": "Home page section 3:",
|
||||||
"LabelHomePageSection4": "Home page section 4:",
|
"LabelHomePageSection4": "Home page section 4:",
|
||||||
"OptionMyViewsButtons": "My views (buttons)",
|
"OptionMyMediaButtons": "My media (buttons)",
|
||||||
"OptionMyViews": "My views",
|
"OptionMyMedia": "My media",
|
||||||
"OptionMyViewsSmall": "My views (small)",
|
"OptionMyMediaSmall": "My media (small)",
|
||||||
"OptionResumablemedia": "Resume",
|
"OptionResumablemedia": "Resume",
|
||||||
"OptionLatestMedia": "Latest media",
|
"OptionLatestMedia": "Latest media",
|
||||||
"OptionLatestChannelMedia": "Latest channel items",
|
"OptionLatestChannelMedia": "Latest channel items",
|
||||||
|
|
|
@ -12,7 +12,7 @@ We have several client apps released and in production:
|
||||||
- [iPad](https://itunes.apple.com/us/app/media-browser-client/id879475585 "iPad")
|
- [iPad](https://itunes.apple.com/us/app/media-browser-client/id879475585 "iPad")
|
||||||
- [iPhone](https://itunes.apple.com/us/app/media-browser-for-ios/id705058087?mt=8 "iPhone")
|
- [iPhone](https://itunes.apple.com/us/app/media-browser-for-ios/id705058087?mt=8 "iPhone")
|
||||||
- [Media Portal](http://www.team-mediaportal.com/ "Media Portal")
|
- [Media Portal](http://www.team-mediaportal.com/ "Media Portal")
|
||||||
- [Roku](http://www.roku.com/channels/#!details/44191/media-browser-for-roku "Roku")
|
- [Roku](https://www.roku.com/channels#!details/44191/emby "Roku")
|
||||||
- Windows 7/8 Desktop
|
- Windows 7/8 Desktop
|
||||||
- Windows Media Center
|
- Windows Media Center
|
||||||
- [Windows Phone](http://www.windowsphone.com/s?appid=f4971ed9-f651-4bf6-84bb-94fd98613b86 "Windows Phone")
|
- [Windows Phone](http://www.windowsphone.com/s?appid=f4971ed9-f651-4bf6-84bb-94fd98613b86 "Windows Phone")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user