Class: V2av
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#steps ⇒ Object
Returns the value of attribute steps.
Instance Method Summary collapse
- #build(destination) ⇒ Object
-
#initialize(src, srt, working_dir: '/tmp/v2av', debug: false, pollyspeech: {access_key: nil, secret_key: nil, voice_id: 'Amy', cache_filepath: '/tmp/v2av/pollyspeech/cache'}) ⇒ V2av
constructor
A new instance of V2av.
Methods included from WavTool
#ogg_to_wav, #wav_concat, #wav_silence
Constructor Details
#initialize(src, srt, working_dir: '/tmp/v2av', debug: false, pollyspeech: {access_key: nil, secret_key: nil, voice_id: 'Amy', cache_filepath: '/tmp/v2av/pollyspeech/cache'}) ⇒ V2av
Returns a new instance of V2av.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/v2av.rb', line 79 def initialize(src, srt, working_dir: '/tmp/v2av', debug: false, pollyspeech: {access_key: nil, secret_key: nil, voice_id: 'Amy', cache_filepath: '/tmp/v2av/pollyspeech/cache'}) @source, @working_dir, @debug = src, working_dir, debug @steps = srt.lines.map do |x| raw_time, desc = x.chomp.split(/ +/,2) OpenStruct.new({time: raw_time.to_i, desc: desc}) end s = `exiftool #{src}` puts 's: ' + s.inspect if @debug #a = s[/Duration.*(\d{1,2}:\d{2}:\d{2})/,1].split(':').map(&:to_i) #@duration = Subunit.new(units={minutes:60, hours:60, seconds: 0}, a).to_i @duration = s[/Duration.*: (\d+)/,1].to_i puts ('@duration: ' + @duration.inspect).debug if @debug @steps[0..-2].each.with_index do |x, i| x.duration = @steps[i+1].time - x.time end @steps.last.duration = @duration - @steps.last.time @pollyspeech = PollySpeech.new(pollyspeech) if pollyspeech[:access_key] end |
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
77 78 79 |
# File 'lib/v2av.rb', line 77 def duration @duration end |
#steps ⇒ Object
Returns the value of attribute steps.
77 78 79 |
# File 'lib/v2av.rb', line 77 def steps @steps end |
Instance Method Details
#build(destination) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/v2av.rb', line 107 def build(destination) if block_given? then yield(self) else dir = File.dirname(@source) file = File.basename(@source) vid2 = File.join(@working_dir, file.sub(/\.mp4$/,'b\0')) trim_video @source, vid2 vid3 = File.join(@working_dir, file.sub(/\.mp4$/,'c.avi')) generate_audio add_audio_track File.join(@working_dir, 'audio.wav'), vid2, vid3 vid4 = File.join(dir, file.sub(/\.avi$/,'d\0')) resize_video vid3, vid4 vid5 = File.join(dir, file.sub(/\.mp4$/,'e\0')) transcode_video(vid4, vid5) add_subtitles(vid5, destination) end end |