Skip to content

Commit

Permalink
Merge pull request #5468 from avalonmediasystem/minute_by_minute
Browse files Browse the repository at this point in the history
Reduce ffmpeg timeout to 1 minute
  • Loading branch information
cjcolvar authored Nov 15, 2023
2 parents 55974ff + 9be64f3 commit 4db6d0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/services/waveform_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_normalized_peaks(uri)
def get_wave_io(uri)
headers = "-headers $'Referer: #{Rails.application.routes.url_helpers.root_url}\r\n'" if uri.starts_with? "http"
normalized_uri = uri.starts_with?("file") ? Addressable::URI.unencode(uri) : uri
timeout = 3600000000 # Must be in microseconds. Current value = 1 hour.
timeout = 60000000 # Must be in microseconds. Current value = 1 minute.
cmd = "#{Settings.ffmpeg.path} #{headers} -rw_timeout #{timeout} -i '#{normalized_uri}' -f wav -ar 44100 - 2> /dev/null"
IO.popen(cmd)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/services/waveform_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

context "http file" do
let(:uri) { "http://domain/to/video.mp4" }
let(:cmd) {"#{Settings.ffmpeg.path} -headers $'Referer: http://test.host/\r\n' -rw_timeout 3600000000 -i '#{uri}' -f wav -ar 44100 - 2> /dev/null"}
let(:cmd) {"#{Settings.ffmpeg.path} -headers $'Referer: http://test.host/\r\n' -rw_timeout 60000000 -i '#{uri}' -f wav -ar 44100 - 2> /dev/null"}

it "should call ffmpeg with headers" do
service.send(:get_wave_io, uri)
Expand All @@ -77,7 +77,7 @@

context "local file" do
let(:uri) { "file:///path/to/video.mp4" }
let(:cmd) {"#{Settings.ffmpeg.path} -rw_timeout 3600000000 -i '#{uri}' -f wav -ar 44100 - 2> /dev/null"}
let(:cmd) {"#{Settings.ffmpeg.path} -rw_timeout 60000000 -i '#{uri}' -f wav -ar 44100 - 2> /dev/null"}

it "should call ffmpeg without headers" do
service.send(:get_wave_io, uri)
Expand All @@ -87,7 +87,7 @@
context 'with spaces in filename' do
let(:uri) { 'file:///path/to/special%20video%20file.mp4' }
let(:unencoded_uri) { 'file:///path/to/special video file.mp4' }
let(:cmd) {"#{Settings.ffmpeg.path} -rw_timeout 3600000000 -i '#{unencoded_uri}' -f wav -ar 44100 - 2> /dev/null"}
let(:cmd) {"#{Settings.ffmpeg.path} -rw_timeout 60000000 -i '#{unencoded_uri}' -f wav -ar 44100 - 2> /dev/null"}

it "should call ffmpeg without url encoding" do
service.send(:get_wave_io, uri)
Expand Down

0 comments on commit 4db6d0f

Please sign in to comment.