diff --git a/lib/ffmpeg/transcoder.rb b/lib/ffmpeg/transcoder.rb index b2d685b..cf7c05b 100644 --- a/lib/ffmpeg/transcoder.rb +++ b/lib/ffmpeg/transcoder.rb @@ -139,16 +139,26 @@ def validate_output_file if succeeded? yield(1.0) if block_given? - FFMPEG.logger.info "Transcoding of #{@input_path} to #{@output_path} succeeded\n" + FFMPEG.logger.info(self.class) do + "Transcoding #{@input_path} to #{@output_path} succeeded\n" \ + "Command: #{command.join(' ')}\n" \ + "Output: #{@output}" + end else - errors = "Errors: #{@errors.join(', ')}. " - FFMPEG.logger.error "Failed encoding...\n#{command.join(' ')}\n\n#{@output}\n#{errors}\n" - raise Error, "Failed encoding. #{errors}Full output: #{@output}" + message = "Transcoding #{@input_path} to #{@output_path} failed\n" \ + "Command: #{command.join(' ')}\n" \ + "Errors: #{@errors.join(', ')}\n " \ + "Output: #{@output}\n" + FFMPEG.logger.error(self.class) { message } + raise Error, message end end def execute - FFMPEG.logger.info("Running transcoding...\n#{command.join(' ')}\n") + FFMPEG.logger.info(self.class) do + "Transcoding #{@input_path} to #{@output_path}...\n" \ + "Command: #{command.join(' ')}" + end @output = String.new @@ -175,9 +185,12 @@ def execute @errors << 'ffmpeg returned non-zero exit code' unless wait_thr.value.success? rescue Timeout::Error + message = "Transcoding #{@input_path} to #{@output_path} failed, process hung\n" \ + "Command: #{command.join(' ')}\n" \ + "Output: #{@output}" Process.kill(FFMPEG::SIGKILL, wait_thr.pid) - FFMPEG.logger.error "Process hung...\n#{command.join(' ')}\nOutput\n#{@output}\n" - raise Error, "Process hung. Full output: #{@output}" + FFMPEG.logger.error(self.class) { message } + raise Error, message end end end diff --git a/lib/ffmpeg/version.rb b/lib/ffmpeg/version.rb index 0951c77..61103b6 100644 --- a/lib/ffmpeg/version.rb +++ b/lib/ffmpeg/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module FFMPEG - VERSION = '5.0.0' + VERSION = '5.0.1' end diff --git a/spec/ffmpeg/transcoder_spec.rb b/spec/ffmpeg/transcoder_spec.rb index 1f7d9d1..5df2469 100644 --- a/spec/ffmpeg/transcoder_spec.rb +++ b/spec/ffmpeg/transcoder_spec.rb @@ -66,7 +66,7 @@ module FFMPEG it 'should fail when the timeout is exceeded' do expect(FFMPEG.logger).to receive(:error) - expect { subject.run }.to raise_error(FFMPEG::Error, /Process hung/) + expect { subject.run }.to raise_error(FFMPEG::Error, /Transcoding .+ failed, process hung/) end end @@ -150,7 +150,7 @@ module FFMPEG end it 'should fail when the timeout is exceeded' do - expect { subject.run }.to raise_error(FFMPEG::Error, /Process hung/) + expect { subject.run }.to raise_error(FFMPEG::Error, /Transcoding .+ failed, process hung/) end end end @@ -298,7 +298,7 @@ module FFMPEG it 'should fail' do expect do subject.run - end.to raise_error(FFMPEG::Error, /Failed encoding/) + end.to raise_error(FFMPEG::Error, /Transcoding .+ failed/) end end