The Free Software Media System - Server Backend & API
Update FFmpeg log
artiume4e07d9d5618d
diff --git a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs b/Jellyfin.Api/Helpers/TranscodingJobHelper.csindex 168dc27a83..11682d88b1 100644--- a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs+++ b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs@@ -145,7 +145,7 @@ namespace Jellyfin.Api.Helperslock (_activeTranscodingJobs){// This is really only needed for HLS.- // Progressive streams can stop on their own reliably+ // Progressive streams can stop on their own reliably.jobs = _activeTranscodingJobs.Where(j => string.Equals(playSessionId, j.PlaySessionId, StringComparison.OrdinalIgnoreCase)).ToList();}@@ -241,7 +241,7 @@ namespace Jellyfin.Api.Helperslock (_activeTranscodingJobs){// This is really only needed for HLS.- // Progressive streams can stop on their own reliably+ // Progressive streams can stop on their own reliably.jobs.AddRange(_activeTranscodingJobs.Where(killJob));}@@ -304,10 +304,10 @@ namespace Jellyfin.Api.Helpersprocess!.StandardInput.WriteLine("q");- // Need to wait because killing is asynchronous+ // Need to wait because killing is asynchronous.if (!process.WaitForExit(5000)){- _logger.LogInformation("Killing ffmpeg process for {Path}", job.Path);+ _logger.LogInformation("Killing FFmpeg process for {Path}", job.Path);process.Kill();}}@@ -470,11 +470,11 @@ namespace Jellyfin.Api.Helpers}/// <summary>- /// Starts the FFMPEG.+ /// Starts FFmpeg./// </summary>/// <param name="state">The state.</param>/// <param name="outputPath">The output path.</param>- /// <param name="commandLineArguments">The command line arguments for ffmpeg.</param>+ /// <param name="commandLineArguments">The command line arguments for FFmpeg.</param>/// <param name="request">The <see cref="HttpRequest"/>.</param>/// <param name="transcodingJobType">The <see cref="TranscodingJobType"/>.</param>/// <param name="cancellationTokenSource">The cancellation token source.</param>@@ -501,13 +501,13 @@ namespace Jellyfin.Api.Helpers{this.OnTranscodeFailedToStart(outputPath, transcodingJobType, state);- throw new ArgumentException("User does not have access to video transcoding");+ throw new ArgumentException("User does not have access to video transcoding.");}}if (string.IsNullOrEmpty(_mediaEncoder.EncoderPath)){- throw new ArgumentException("FFMPEG path not set.");+ throw new ArgumentException("FFmpeg path not set.");}var process = new Process@@ -544,18 +544,18 @@ namespace Jellyfin.Api.Helpersvar commandLineLogMessage = process.StartInfo.FileName + " " + process.StartInfo.Arguments;_logger.LogInformation(commandLineLogMessage);- var logFilePrefix = "ffmpeg-transcode";+ var logFilePrefix = "FFmpeg.Transcode-";if (state.VideoRequest != null&& EncodingHelper.IsCopyCodec(state.OutputVideoCodec)){logFilePrefix = EncodingHelper.IsCopyCodec(state.OutputAudioCodec)- ? "ffmpeg-remux"- : "ffmpeg-directstream";+ ? "FFmpeg.Remux-"+ : "FFmpeg.DirectStream-";}- var logFilePath = Path.Combine(_serverConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + "-" + Guid.NewGuid() + ".txt");+ var logFilePath = Path.Combine(_serverConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + DateTime.Now.ToString("YYYY-MM-dd_HH-mm-ss") + "_" + state.Request.MediaSourceId + ".log");- // FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.+ // FFmpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.Stream logStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(request.Path + Environment.NewLine + Environment.NewLine + JsonSerializer.Serialize(state.MediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);@@ -569,17 +569,17 @@ namespace Jellyfin.Api.Helpers}catch (Exception ex){- _logger.LogError(ex, "Error starting ffmpeg");+ _logger.LogError(ex, "Error starting FFmpeg");this.OnTranscodeFailedToStart(outputPath, transcodingJobType, state);throw;}- _logger.LogDebug("Launched ffmpeg process");+ _logger.LogDebug("Launched FFmpeg process");state.TranscodingJob = transcodingJob;- // Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback+ // Important - don't await the log task or we won't be able to kill FFmpeg when the user stops playback_ = new JobLogger(_logger).StartStreamingLog(state, process.StandardError.BaseStream, logStream);// Wait for the file to exist before proceeeding@@ -748,11 +748,11 @@ namespace Jellyfin.Api.Helpersif (process.ExitCode == 0){- _logger.LogInformation("FFMpeg exited with code 0");+ _logger.LogInformation("FFmpeg exited with code 0");}else{- _logger.LogError("FFMpeg exited with code {0}", process.ExitCode);+ _logger.LogError("FFmpeg exited with code {0}", process.ExitCode);}process.Dispose();