Update FFmpeg log

This commit is contained in:
artiume 2020-11-19 08:49:21 -05:00 committed by GitHub
parent 49ebbcf87e
commit 4e07d9d561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,7 +145,7 @@ namespace Jellyfin.Api.Helpers
lock (_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.Helpers
lock (_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.Helpers
process!.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.Helpers
var 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.Helpers
if (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();