diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index aca1abf9fd..d3014a2d88 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -121,6 +121,7 @@ namespace Emby.Server.Implementations
{
private SqliteUserRepository _userRepository;
private SqliteDisplayPreferencesRepository _displayPreferencesRepository;
+ private IMediaEncoder _mediaEncoder;
private ISessionManager _sessionManager;
private IHttpServer _httpServer;
@@ -251,12 +252,6 @@ namespace Emby.Server.Implementations
/// The user manager.
public IUserManager UserManager { get; set; }
- ///
- /// Gets or sets the media encoder.
- ///
- /// The media encoder.
- private IMediaEncoder MediaEncoder { get; set; }
-
public LocalizationManager LocalizationManager { get; set; }
///
@@ -486,7 +481,7 @@ namespace Emby.Server.Implementations
ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated;
- MediaEncoder.SetFFmpegPath();
+ _mediaEncoder.SetFFmpegPath();
Logger.LogInformation("ServerId: {0}", SystemId);
@@ -685,7 +680,8 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(UserManager);
- MediaEncoder = new MediaBrowser.MediaEncoding.Encoder.MediaEncoder(
+ // TODO: Add StartupOptions.FFmpegPath to IConfiguration so this doesn't need to be constructed manually
+ serviceCollection.AddSingleton(new MediaBrowser.MediaEncoding.Encoder.MediaEncoder(
LoggerFactory.CreateLogger(),
ServerConfigurationManager,
FileSystemManager,
@@ -693,8 +689,7 @@ namespace Emby.Server.Implementations
LocalizationManager,
Resolve,
startupConfig,
- StartupOptions.FFmpegPath);
- serviceCollection.AddSingleton(MediaEncoder);
+ StartupOptions.FFmpegPath));
// TODO: Refactor to eliminate the circular dependencies here so that Lazy isn't required
serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService));
@@ -772,6 +767,7 @@ namespace Emby.Server.Implementations
///
public void InitializeServices()
{
+ _mediaEncoder = Resolve();
_sessionManager = Resolve();
_httpServer = Resolve();
@@ -1306,7 +1302,7 @@ namespace Emby.Server.Implementations
ServerName = FriendlyName,
LocalAddress = localAddress,
SupportsLibraryMonitor = true,
- EncoderLocation = MediaEncoder.EncoderLocation,
+ EncoderLocation = _mediaEncoder.EncoderLocation,
SystemArchitecture = RuntimeInformation.OSArchitecture,
SystemUpdateLevel = SystemUpdateLevel,
PackageName = StartupOptions.PackageName