summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Rogers <rogers.timothy.john@gmail.com>2024-04-22 04:00:24 -0500
committerGitHub <noreply@github.com>2024-04-22 09:00:24 +0000
commit1ca6ff8ca537a51dc2ed83ee3a262e7ec01b9f00 (patch)
tree3131a17d7233de198e4c2eb4925c399035458aea
parent75163d9daf831a0562bcf35bffb883c2e7b239b7 (diff)
Fixed crash when supplying FFMPEG_BINARY environment variable (#30022)
-rw-r--r--app/lib/video_metadata_extractor.rb2
-rw-r--r--config/initializers/ffmpeg.rb5
-rw-r--r--lib/paperclip/image_extractor.rb2
-rw-r--r--lib/paperclip/transcoder.rb2
4 files changed, 6 insertions, 5 deletions
diff --git a/app/lib/video_metadata_extractor.rb b/app/lib/video_metadata_extractor.rb
index f27d34868a2..df5409375f1 100644
--- a/app/lib/video_metadata_extractor.rb
+++ b/app/lib/video_metadata_extractor.rb
@@ -22,7 +22,7 @@ class VideoMetadataExtractor
private
def ffmpeg_command_output
- command = Terrapin::CommandLine.new('ffprobe', '-i :path -print_format :format -show_format -show_streams -show_error -loglevel :loglevel')
+ command = Terrapin::CommandLine.new(Rails.configuration.x.ffprobe_binary, '-i :path -print_format :format -show_format -show_streams -show_error -loglevel :loglevel')
command.run(path: @path, format: 'json', loglevel: 'fatal')
end
diff --git a/config/initializers/ffmpeg.rb b/config/initializers/ffmpeg.rb
index 30ea617fcd2..87f85eeec70 100644
--- a/config/initializers/ffmpeg.rb
+++ b/config/initializers/ffmpeg.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
-if ENV['FFMPEG_BINARY'].present?
- FFMPEG.ffmpeg_binary = ENV['FFMPEG_BINARY']
+Rails.application.configure do
+ config.x.ffmpeg_binary = ENV['FFMPEG_BINARY'] || 'ffmpeg'
+ config.x.ffprobe_binary = ENV['FFPROBE_BINARY'] || 'ffprobe'
end
diff --git a/lib/paperclip/image_extractor.rb b/lib/paperclip/image_extractor.rb
index 17fe4326fdb..8a565d0469e 100644
--- a/lib/paperclip/image_extractor.rb
+++ b/lib/paperclip/image_extractor.rb
@@ -35,7 +35,7 @@ module Paperclip
dst.binmode
begin
- command = Terrapin::CommandLine.new('ffmpeg', '-i :source -loglevel :loglevel -y :destination', logger: Paperclip.logger)
+ command = Terrapin::CommandLine.new(Rails.configuration.x.ffmpeg_binary, '-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)
diff --git a/lib/paperclip/transcoder.rb b/lib/paperclip/transcoder.rb
index d2d946d3ade..3efffa355a5 100644
--- a/lib/paperclip/transcoder.rb
+++ b/lib/paperclip/transcoder.rb
@@ -61,7 +61,7 @@ module Paperclip
command_arguments, interpolations = prepare_command(destination)
begin
- command = Terrapin::CommandLine.new('ffmpeg', command_arguments.join(' '), logger: Paperclip.logger)
+ command = Terrapin::CommandLine.new(Rails.configuration.x.ffmpeg_binary, command_arguments.join(' '), logger: Paperclip.logger)
command.run(interpolations)
rescue Terrapin::ExitStatusError => e
raise Paperclip::Error, "Error while transcoding #{@basename}: #{e}"