Class: AudioBotRepl
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- AudioBotRepl
- Defined in:
- src/ruby/audio-bot-repl.rb
Class Method Summary collapse
Class Method Details
.perform_update ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'src/ruby/audio-bot-repl.rb', line 17 def self.perform_update() STDERR.puts ">>> Transcoding audio comments from ogg/opus to mp3!" file_count = 0 start_time = Time.now paths = Dir['/raw/uploads/audio_comments/**/*'] paths.each do |path| STDERR.puts path # tag = File.basename(path).split('.').first # last_jpg_path = path # (GEN_IMAGE_WIDTHS.reverse + [:p]).each do |width| # jpg_path = File.join("/gen/i/#{tag}-#{width}.jpg") # unless File.exist?(jpg_path) # STDERR.puts jpg_path # if width == :p # system("convert -auto-orient -colorspace RGB \"#{last_jpg_path}\" -blur 0x8 -quality 85 -sampling-factor 4:2:0 -strip \"#{jpg_path}\"") # else # system("convert -auto-orient -colorspace RGB \"#{last_jpg_path}\" -resize #{width}x\\> -quality 85 -sampling-factor 4:2:0 -strip \"#{jpg_path}\"") # end # file_count += 1 # end # webp_path = File.join("/gen/i/#{tag}-#{width}.webp") # unless File.exist?(webp_path) # STDERR.puts webp_path # system("cwebp -quiet \"#{jpg_path}\" -q #{webp_path.include?('-b') ? 100 : 85} -o \"#{webp_path}\"") # file_count += 1 # end # last_jpg_path = jpg_path # end end end_time = Time.now STDERR.puts sprintf("<<< Finished transcoding audio comments in %1.2f seconds, wrote #{file_count} files.", (end_time - start_time).to_f) STDERR.puts '-' * 59 end |