diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2021-05-05 19:44:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 19:44:01 +0200 |
commit | 036556d3509fac5fa487a0d5ff3cf95767e8d84f (patch) | |
tree | f3435a4f1a5cbb999fde3118e9d17e62a889a59d /lib/paperclip/image_extractor.rb | |
parent | dfa002932d660656792a78887264dd00820f2dda (diff) |
Fix media processing getting stuck on too much stdin/stderr (#16136)
* Fix media processing getting stuck on too much stdin/stderr See thoughtbot/terrapin#5 * Remove dependency on paperclip-av-transcoder gem * Remove dependency on streamio-ffmpeg gem * Disable stdin on ffmpeg process
Diffstat (limited to 'lib/paperclip/image_extractor.rb')
-rw-r--r-- | lib/paperclip/image_extractor.rb | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/paperclip/image_extractor.rb b/lib/paperclip/image_extractor.rb index aab675a06..17fe4326f 100644 --- a/lib/paperclip/image_extractor.rb +++ b/lib/paperclip/image_extractor.rb @@ -31,21 +31,17 @@ module Paperclip private def extract_image_from_file! - ::Av.logger = Paperclip.logger - - cli = ::Av.cli dst = Tempfile.new([File.basename(@file.path, '.*'), '.png']) dst.binmode - cli.add_source(@file.path) - cli.add_destination(dst.path) - cli.add_output_param loglevel: 'fatal' - begin - cli.run - rescue Cocaine::ExitStatusError, ::Av::CommandError + command = Terrapin::CommandLine.new('ffmpeg', '-i :source -loglevel :loglevel -y :destination', logger: Paperclip.logger) + command.run(source: @file.path, destination: dst.path, loglevel: 'fatal') + rescue Terrapin::ExitStatusError dst.close(true) return nil + rescue Terrapin::CommandNotFoundError + raise Paperclip::Errors::CommandNotFoundError, 'Could not run the `ffmpeg` command. Please install ffmpeg.' end dst |