mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 22:07:13 -04:00
support configurable transcoding temporary path
This commit is contained in:
parent
ef8b02d285
commit
7f57ef0689
@ -71,7 +71,7 @@ namespace MediaBrowser.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void DeleteEncodedMediaCache()
|
private void DeleteEncodedMediaCache()
|
||||||
{
|
{
|
||||||
foreach (var file in Directory.EnumerateFiles(AppPaths.EncodedMediaCachePath)
|
foreach (var file in Directory.EnumerateFiles(AppPaths.TranscodingTempPath)
|
||||||
.Where(i => EntityResolutionHelper.VideoFileExtensions.Contains(Path.GetExtension(i)))
|
.Where(i => EntityResolutionHelper.VideoFileExtensions.Contains(Path.GetExtension(i)))
|
||||||
.ToList())
|
.ToList())
|
||||||
{
|
{
|
||||||
|
@ -122,7 +122,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
protected virtual string GetOutputFilePath(StreamState state)
|
protected virtual string GetOutputFilePath(StreamState state)
|
||||||
{
|
{
|
||||||
var folder = ServerConfigurationManager.ApplicationPaths.EncodedMediaCachePath;
|
var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath;
|
||||||
|
|
||||||
var outputFileExtension = GetOutputFileExtension(state);
|
var outputFileExtension = GetOutputFileExtension(state);
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
|
|
||||||
protected override string GetOutputFilePath(StreamState state)
|
protected override string GetOutputFilePath(StreamState state)
|
||||||
{
|
{
|
||||||
var folder = ServerConfigurationManager.ApplicationPaths.EncodedMediaCachePath;
|
var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath;
|
||||||
|
|
||||||
var outputFileExtension = GetOutputFileExtension(state);
|
var outputFileExtension = GetOutputFileExtension(state);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
Logger.Info("OnEndRequest " + playlistId);
|
Logger.Info("OnEndRequest " + playlistId);
|
||||||
var normalizedPlaylistId = playlistId.Replace("-low", string.Empty);
|
var normalizedPlaylistId = playlistId.Replace("-low", string.Empty);
|
||||||
|
|
||||||
foreach (var playlist in Directory.EnumerateFiles(ApplicationPaths.EncodedMediaCachePath, "*.m3u8")
|
foreach (var playlist in Directory.EnumerateFiles(ApplicationPaths.TranscodingTempPath, "*.m3u8")
|
||||||
.Where(i => i.IndexOf(normalizedPlaylistId, StringComparison.OrdinalIgnoreCase) != -1)
|
.Where(i => i.IndexOf(normalizedPlaylistId, StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
.ToList())
|
.ToList())
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
|
|
||||||
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
|
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
|
||||||
|
|
||||||
file = Path.Combine(_appPaths.EncodedMediaCachePath, file);
|
file = Path.Combine(_appPaths.TranscodingTempPath, file);
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||||
|
|
||||||
file = Path.Combine(_appPaths.EncodedMediaCachePath, file);
|
file = Path.Combine(_appPaths.TranscodingTempPath, file);
|
||||||
|
|
||||||
OnBeginRequest(request.PlaylistId);
|
OnBeginRequest(request.PlaylistId);
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||||
|
|
||||||
file = Path.Combine(_appPaths.EncodedMediaCachePath, file);
|
file = Path.Combine(_appPaths.TranscodingTempPath, file);
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
var normalizedPlaylistId = playlistId.Replace("-low", string.Empty);
|
var normalizedPlaylistId = playlistId.Replace("-low", string.Empty);
|
||||||
|
|
||||||
foreach (var playlist in Directory.EnumerateFiles(_appPaths.EncodedMediaCachePath, "*.m3u8")
|
foreach (var playlist in Directory.EnumerateFiles(_appPaths.TranscodingTempPath, "*.m3u8")
|
||||||
.Where(i => i.IndexOf(normalizedPlaylistId, StringComparison.OrdinalIgnoreCase) != -1)
|
.Where(i => i.IndexOf(normalizedPlaylistId, StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
.ToList())
|
.ToList())
|
||||||
{
|
{
|
||||||
|
@ -95,10 +95,10 @@ namespace MediaBrowser.Controller
|
|||||||
string UserConfigurationDirectoryPath { get; }
|
string UserConfigurationDirectoryPath { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the FF MPEG stream cache path.
|
/// Gets the transcoding temporary path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The FF MPEG stream cache path.</value>
|
/// <value>The transcoding temporary path.</value>
|
||||||
string EncodedMediaCachePath { get; }
|
string TranscodingTempPath { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the downloaded images data path.
|
/// Gets the downloaded images data path.
|
||||||
|
@ -220,6 +220,7 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
public MetadataOptions BookOptions { get; set; }
|
public MetadataOptions BookOptions { get; set; }
|
||||||
|
|
||||||
public bool EnableDebugEncodingLogging { get; set; }
|
public bool EnableDebugEncodingLogging { get; set; }
|
||||||
|
public string TranscodingTempPath { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
|
@ -60,6 +60,7 @@ namespace MediaBrowser.Server.Implementations.Configuration
|
|||||||
protected override void OnConfigurationUpdated()
|
protected override void OnConfigurationUpdated()
|
||||||
{
|
{
|
||||||
UpdateItemsByNamePath();
|
UpdateItemsByNamePath();
|
||||||
|
UpdateTranscodingTempPath();
|
||||||
|
|
||||||
base.OnConfigurationUpdated();
|
base.OnConfigurationUpdated();
|
||||||
}
|
}
|
||||||
@ -74,6 +75,16 @@ namespace MediaBrowser.Server.Implementations.Configuration
|
|||||||
Configuration.ItemsByNamePath;
|
Configuration.ItemsByNamePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the transcoding temporary path.
|
||||||
|
/// </summary>
|
||||||
|
private void UpdateTranscodingTempPath()
|
||||||
|
{
|
||||||
|
((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(Configuration.TranscodingTempPath) ?
|
||||||
|
null :
|
||||||
|
Configuration.TranscodingTempPath;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces the configuration.
|
/// Replaces the configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -84,6 +95,7 @@ namespace MediaBrowser.Server.Implementations.Configuration
|
|||||||
var newConfig = (ServerConfiguration) newConfiguration;
|
var newConfig = (ServerConfiguration) newConfiguration;
|
||||||
|
|
||||||
ValidateItemByNamePath(newConfig);
|
ValidateItemByNamePath(newConfig);
|
||||||
|
ValidateTranscodingTempPath(newConfig);
|
||||||
|
|
||||||
base.ReplaceConfiguration(newConfiguration);
|
base.ReplaceConfiguration(newConfiguration);
|
||||||
}
|
}
|
||||||
@ -107,5 +119,25 @@ namespace MediaBrowser.Server.Implementations.Configuration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validates the transcoding temporary path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newConfig">The new configuration.</param>
|
||||||
|
/// <exception cref="DirectoryNotFoundException"></exception>
|
||||||
|
private void ValidateTranscodingTempPath(ServerConfiguration newConfig)
|
||||||
|
{
|
||||||
|
var newPath = newConfig.TranscodingTempPath;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(newPath)
|
||||||
|
&& !string.Equals(Configuration.TranscodingTempPath ?? string.Empty, newPath))
|
||||||
|
{
|
||||||
|
// Validate
|
||||||
|
if (!Directory.Exists(newPath))
|
||||||
|
{
|
||||||
|
throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,15 +200,16 @@ namespace MediaBrowser.Server.Implementations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private string _transcodingTempPath;
|
||||||
/// Gets the FF MPEG stream cache path.
|
public string TranscodingTempPath
|
||||||
/// </summary>
|
|
||||||
/// <value>The FF MPEG stream cache path.</value>
|
|
||||||
public string EncodedMediaCachePath
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Path.Combine(CachePath, "encoded-media");
|
return _transcodingTempPath ?? (_transcodingTempPath = Path.Combine(ProgramDataPath, "transcoding-temp"));
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_transcodingTempPath = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user