Class: OggEncode::OggEncoder
- Inherits:
-
Object
- Object
- OggEncode::OggEncoder
- Defined in:
- lib/autogg/encoder.rb
Class Method Summary collapse
- .count_flacs ⇒ Object
- .count_oggs ⇒ Object
- .encfile(inpath) ⇒ Object
- .encode(options) ⇒ Object
- .getoutpath(inpath) ⇒ Object
- .interupt ⇒ Object
- .oggencdir ⇒ Object
Class Method Details
.count_flacs ⇒ Object
35 36 37 38 39 |
# File 'lib/autogg/encoder.rb', line 35 def count_flacs c = 0 Find.find( .paths.flac ) {|p| c += 1 if Flac.exists?( p ) } c end |
.count_oggs ⇒ Object
41 42 43 44 45 |
# File 'lib/autogg/encoder.rb', line 41 def count_oggs c = 0 Find.find( .paths.ogg ) {|p| c += 1 if Ogg.exists?( p ) } c end |
.encfile(inpath) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/autogg/encoder.rb', line 22 def encfile( inpath ) outpath = getoutpath( inpath ) @ps_hash.store( nil, outpath ) do ps = IO.popen %Q{oggenc #{@options.oggargs.join(' ')} "#{inpath}" -o "#{outpath}"} end .inc end |
.encode(options) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/autogg/encoder.rb', line 55 def encode( ) = @ps_hash = SizedPsHash.new( .max_procs ) @log = Logger.new(.paths.ogg) oggencdir ensure @log.close end |
.getoutpath(inpath) ⇒ Object
30 31 32 33 |
# File 'lib/autogg/encoder.rb', line 30 def getoutpath( inpath ) outpath = inpath.gsub( .paths.flac, .paths.ogg ) outpath.gsub!( /\.flac/, '.ogg' ) end |
.interupt ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/autogg/encoder.rb', line 47 def interupt puts "\n" + "Shutting down and removing partially encoded files" @ps_hash.each do |pid, path| File.delete( path ) end exit end |
.oggencdir ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/autogg/encoder.rb', line 8 def oggencdir = ProgressBar.new( "Progress", ( count_flacs - count_oggs ) ) Find.find( .paths.flac ) do |path| if FileTest.directory?( path ) Find.prune if File.basename( path )[0] == ?. elsif Flac.exists?( path ) and not Ogg.exists?( getoutpath(path) ) encfile( path ) else @log << path end end Process.waitall ; @ps_hash = {} ; .finish end |