From 8820e60c6086b4ed720ae00f8bdd2ec09b928542 Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Tue, 30 Aug 2022 14:51:26 -0400 Subject: [PATCH] Improve error handling for ffmpeg adapter - Bump ffmpeg loglevel to fatal due to very verbose error logging for some files - Add level flag to ffmepg logging for clearer error messages - Add a human-readable, explanatory note to the errors on the encode object before the dump of the stderr output - Prepend fatal truncation error so it appears first in encode object's errors array --- lib/active_encode/engine_adapters/ffmpeg_adapter.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/active_encode/engine_adapters/ffmpeg_adapter.rb b/lib/active_encode/engine_adapters/ffmpeg_adapter.rb index 6ef47ef..e936fa0 100644 --- a/lib/active_encode/engine_adapters/ffmpeg_adapter.rb +++ b/lib/active_encode/engine_adapters/ffmpeg_adapter.rb @@ -111,7 +111,7 @@ def find(id, opts = {}) elsif cancelled? encode.id encode.state = :cancelled elsif encode.percent_complete < 100 - encode.errors << "Encoding has completed but the output duration is shorter than the input" + encode.errors.prepend("Encoding has completed but the output duration is shorter than the input") encode.state = :failed end @@ -170,7 +170,7 @@ def read_errors(id) err_path = working_path("error.log", id) error = File.read(err_path) if File.file? err_path if error.present? - [error] + ["Error encountered during encoding. Check ffmpeg log for more details.", error] else [] end @@ -227,7 +227,7 @@ def ffmpeg_command(input_url, id, opts) "#{k}: #{v}\r\n" end.join header_opt = "-headers '#{header_opt}'" if header_opt.present? - "#{FFMPEG_PATH} #{header_opt} -y -loglevel error -progress #{working_path('progress', id)} -i \"#{input_url}\" #{output_opt}" + "#{FFMPEG_PATH} #{header_opt} -y -loglevel level+fatal -progress #{working_path('progress', id)} -i \"#{input_url}\" #{output_opt}" end def sanitize_base(input_url)