Add additional logging for ffmpeg and prevent NRE errors from obscuring the actual errors from ffmpeg.
This commit is contained in:
parent
616aaef1c8
commit
0eae466368
@ -630,7 +630,36 @@ public class DownloadHelper : IDownloadHelper
|
|||||||
// break;
|
// break;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
string parameters = $"-cenc_decryption_key {decKey} -headers \"Cookie:CloudFront-Policy={policy}; CloudFront-Signature={signature}; CloudFront-Key-Pair-Id={kvp}; {sess} Origin: https://onlyfans.com Referer: https://onlyfans.com User-Agent: {user_agent}\" -y -i \"{url}\" -map 0:v:{streamIndex} -map 0:a? -codec copy \"{tempFilename}\"";
|
// Configure ffmpeg log level and optional report file location
|
||||||
|
bool ffmpegDebugLogging = Log.IsEnabled(Serilog.Events.LogEventLevel.Debug);
|
||||||
|
|
||||||
|
string logLevelArgs = ffmpegDebugLogging || downloadConfig.LoggingLevel is LoggingLevel.Verbose or LoggingLevel.Debug
|
||||||
|
? "-loglevel debug -report"
|
||||||
|
: downloadConfig.LoggingLevel switch
|
||||||
|
{
|
||||||
|
LoggingLevel.Information => "-loglevel info",
|
||||||
|
LoggingLevel.Warning => "-loglevel warning",
|
||||||
|
LoggingLevel.Error => "-loglevel error",
|
||||||
|
LoggingLevel.Fatal => "-loglevel fatal",
|
||||||
|
_ => string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
if (logLevelArgs.Contains("-report", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// Direct ffmpeg report files into the same logs directory Serilog uses (relative to current working directory)
|
||||||
|
string logDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "logs"));
|
||||||
|
Directory.CreateDirectory(logDir);
|
||||||
|
string ffReportPath = Path.Combine(logDir, "ffmpeg-%p-%t.log"); // ffmpeg will replace %p/%t
|
||||||
|
Environment.SetEnvironmentVariable("FFREPORT", $"file={ffReportPath}:level=32");
|
||||||
|
Log.Debug("FFREPORT enabled at: {FFREPORT} (cwd: {Cwd})", Environment.GetEnvironmentVariable("FFREPORT"), Environment.CurrentDirectory);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Environment.SetEnvironmentVariable("FFREPORT", null);
|
||||||
|
Log.Debug("FFREPORT disabled (cwd: {Cwd})", Environment.CurrentDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
string parameters = $"{logLevelArgs} -cenc_decryption_key {decKey} -headers \"Cookie:CloudFront-Policy={policy}; CloudFront-Signature={signature}; CloudFront-Key-Pair-Id={kvp}; {sess} Origin: https://onlyfans.com Referer: https://onlyfans.com User-Agent: {user_agent}\" -y -i \"{url}\" -map 0:v:{streamIndex} -map 0:a? -codec copy \"{tempFilename}\"".Trim();
|
||||||
|
|
||||||
Log.Debug($"Calling FFMPEG with Parameters: {parameters}");
|
Log.Debug($"Calling FFMPEG with Parameters: {parameters}");
|
||||||
|
|
||||||
@ -965,10 +994,20 @@ public class DownloadHelper : IDownloadHelper
|
|||||||
|
|
||||||
private void OnError(object sender, ConversionErrorEventArgs e)
|
private void OnError(object sender, ConversionErrorEventArgs e)
|
||||||
{
|
{
|
||||||
Log.Debug("[{0} => {1}]: Error: {2}\n{3}", e.Input.Name, e.Output.Name, e.Exception.ExitCode, e.Exception.InnerException);
|
// Guard all fields to avoid NullReference exceptions from FFmpeg.NET
|
||||||
|
var input = e?.Input?.Name ?? "<none>";
|
||||||
|
var output = e?.Output?.Name ?? "<none>";
|
||||||
|
var exitCode = e?.Exception?.ExitCode.ToString() ?? "<unknown>";
|
||||||
|
var message = e?.Exception?.Message ?? "<no message>";
|
||||||
|
var inner = e?.Exception?.InnerException?.Message ?? "<no inner>";
|
||||||
|
|
||||||
|
Log.Error("FFmpeg failed. Input={Input} Output={Output} ExitCode={ExitCode} Message={Message} Inner={Inner}",
|
||||||
|
input, output, exitCode, message, inner);
|
||||||
|
|
||||||
_completionSource?.TrySetResult(false);
|
_completionSource?.TrySetResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#region drm posts
|
#region drm posts
|
||||||
public async Task<bool> DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Messages.List? messageInfo, Messages.Medium? messageMedia, Messages.FromUser? fromUser, Dictionary<string, long> users)
|
public async Task<bool> DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, ProgressTask task, string? filenameFormat, Messages.List? messageInfo, Messages.Medium? messageMedia, Messages.FromUser? fromUser, Dictionary<string, long> users)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user