Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent error when generating a gif image #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ffmpeg/transcoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def screenshot_seek_time(options)
unless seek_time_idx.nil?
options.delete_at(seek_time_idx) # delete 'seek_time'
input_seek_time = options.delete_at(seek_time_idx).to_s # fetch the seek value

options.delete_at(options.find_index('-screenshot')) # delete 'screenshot'
end
result = options, input_seek_time
elsif options.is_a?(Hash)
Expand Down
13 changes: 13 additions & 0 deletions spec/ffmpeg/movie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,19 @@ module FFMPEG

movie.transcode("#{tmp_path}/awesome.flv", {custom: "-vcodec libx264"}, preserve_aspect_ratio: :width)
end

context "when create a gif image" do
it "should run the transcoder" do

transcoder_double = double(Transcoder)
expect(Transcoder).to receive(:new).
with(movie, "#{tmp_path}/hello.gif", %w[-screenshot -seek_time 1 -r 5 -t 0.5 -vf scale=320:-1], {}).
and_return(transcoder_double)
expect(transcoder_double).to receive(:run)

movie.transcode("#{tmp_path}/hello.gif", %w[-screenshot -seek_time 1 -r 5 -t 0.5 -vf scale=320:-1], {})
end
end
end

describe "transcode" do
Expand Down