Class: V2av

Inherits:
Object
  • Object
show all
Includes:
WavTool
Defined in:
lib/v2av.rb

Instance Method Summary collapse

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.



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/v2av.rb', line 77

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'})

  @working_dir, @debug = working_dir, debug

  @steps = srt.lines.map do |x| 
    raw_time, desc = rx.split(/ +/,)
    OpenStruct.new({time: raw_time.to_i, desc: desc})
  end

  @pollyspeech = PollySpeech.new(pollyspeech) if pollyspeech[:access_key]
end

Instance Method Details

#buildObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/v2av.rb', line 91

def build()

  if block_given? then

    yield(self)

  else

    dir = File.dirname(source)
    file = File.basename(source)
    
    tidy!
    
    vid2 = File.join(dir, file.sub(/\.mp4$/,'b\0'))
    trim_video source, vid2
    
    vid3 = File.join(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