class MultimediaParadise::Video::SpeedUpVideo
Public Class Methods
[](i = '')
click to toggle source
Public Instance Methods
input_file?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
MultimediaParadise::Base#reset
# File lib/multimedia_paradise/video/speed_up_video.rb, line 35 def reset super() # ======================================================================= # # Define the speed-up as percentage-number for the instance # variable @speed_up_by_n_percent. 200 effectively means # "double speed". # ======================================================================= # @speed_up_by_n_percent = 200 end
return_filter_for_doubling_the_speed()
click to toggle source
return_multiplier_for_speeding_up_the_audio_rate()
click to toggle source
return_multiplier_for_speeding_up_the_video_rate()
click to toggle source
#¶ ↑
return_multiplier_for_speeding_up_the_video_rate
¶ ↑
This will return the number for the multiplier in use for videos. We can get it by using the multiplier 0.005 for percentage value.
Here is a table that shows these value:
50% is 2.0 # 50 / 25 100% is 1.0 # 100 / 100 150% is 0.75 # 150 / 200 200% is 0.5 # 200 / 400 400% is 0.25 # 400 / 1600
Normalized towards 100 it is:
50% is 2.0 # 200 / 100 100% is 1.0 # 100 / 100 150% is 0.75 # 75 / 100 200% is 0.5 # 50 / 100 400% is 0.25 # 25 / 100
#¶ ↑
# File lib/multimedia_paradise/video/speed_up_video.rb, line 95 def return_multiplier_for_speeding_up_the_video_rate (return_multiplier_for_speeding_up_the_audio_rate.to_f / 4).to_s end
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/speed_up_video.rb, line 109 def run # ======================================================================= # # We will speed up video and audio at the same time. # ======================================================================= # _ = 'ffmpeg'.dup _ << ' -i '+input_file? # _ << ' -filter_complex "[0:v]setpts='+return_multiplier_for_speeding_up_the_video_rate+ # 'x*PTS[v];[0:a]atempo='+return_multiplier_for_speeding_up_the_audio_rate+'[a]"' _ << return_filter_for_doubling_the_speed _ << ' -map "[v]" -map "[a]"' _ << ' -y' # Overwrite it: yes. _ << ' output.mkv' esystem _ end