audio_monster 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d0e6ea4c3b3357151c51698a23c7edcae67c33e
4
- data.tar.gz: 64439d9c9f2cc8105187c77d136ef4280fa51ef2
3
+ metadata.gz: c2f4df3869b78f65dc95459fe8bcb28d306a30e1
4
+ data.tar.gz: f13f261b25dc162762ff3988ec6a909f7f7a1201
5
5
  SHA512:
6
- metadata.gz: ccac8d90d73c02d4b9c552b6ba13eebfd7ecbdeebda0cffd6ada4dd3fc467252f94ac2adb39328bbffabc3712edf95ee9bdbf5c4ea59f11fcf762252ebd4779c
7
- data.tar.gz: 2bdccfd682e2b6fa3df6578d737126ff7e996275a2c5c40db33f04add9bc8ccfbb1e92085f8ee0c7fbc2d73501368b6c5ca6076fb5effd04d86061f49dc399e0
6
+ metadata.gz: b98ae9df3cc40799244ac59b21e3e481d7c90d421c9543a8af0615aa909ab2f80a3094311e57f0831dbab9b4709caf59bb33d4db75e524db89833597693ac48c
7
+ data.tar.gz: 2e760fb680f90fa4bc4619063894a8fdfa48e80baf97673d4cc868c0b0ab1b8d2c7d1d18503c3b0b16131328a09b4cff3be009981796a8302c0d5537ebbdea77
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - "2.2.1"
4
+ - "2.3.1"
4
5
  before_install:
5
- - sudo add-apt-repository ppa:jon-severinsson/ffmpeg -y
6
+ - sudo add-apt-repository ppa:jonathonf/ffmpeg -y
6
7
  - sudo apt-get update -qq
7
- - sudo apt-get install -qq libsndfile1-dev imagemagick libsox-fmt-all lame mp3val sox madplay twolame flac
8
+ - sudo apt-get install -qq libsndfile1-dev libsox-fmt-all lame mp3val sox twolame
8
9
  - sudo apt-get install -qq ffmpeg
data/README.md CHANGED
@@ -1,20 +1,20 @@
1
1
  # AudioMonster
2
2
 
3
3
  AudioMonster manipulates and transcodes audio.
4
- It wraps a number of different command line binaries such as sox, lame, flac, twolame, and ffmpeg.
4
+ It wraps a number of different command line binaries such as sox, lame, twolame, and ffmpeg.
5
+
6
+ [![Build Status](https://travis-ci.org/PRX/audio_monster.svg?branch=master)](https://travis-ci.org/PRX/audio_monster)
5
7
 
6
8
  ## Dependencies
7
9
 
8
- The following binary tools are required. They are available via most OS package managers.
10
+ The following binary tools are required. They are available via most OS package managers.
9
11
 
10
12
  For OS X use homebrew:
11
13
 
12
14
  ```
13
15
  brew install lame
14
- brew install flac
15
16
  brew install sox
16
17
  brew install twolame --frontend
17
- brew install madplay
18
18
  brew install mp3val
19
19
  brew install ffmpeg
20
20
  ```
@@ -26,10 +26,8 @@ http://wiki.centos.org/TipsAndTricks/MultimediaOnCentOS7
26
26
 
27
27
  ```
28
28
  yum install lame
29
- yum install flac
30
- yum install sox
31
- yum install twolame
32
- yum install madplay
29
+ yum install sox
30
+ yum install twolame
33
31
  yum install mp3val
34
32
  yum install ffmpeg
35
33
  yum install libsndfile-devel libsndfile-utils
@@ -61,6 +59,16 @@ For convenience, all methods can be called from the AudioMonster module.
61
59
 
62
60
  The `monster_test.rb` contains examples of method calls.
63
61
 
62
+ ## Development
63
+ To print potential expect checks, I sometimes change `AudioMonster`:
64
+ ```ruby
65
+ def self.method_missing(method, *args, &block)
66
+ r = monster.send(method, *args)
67
+ puts "audio_monster.expect(:#{method}, #{r}, #{args.map { |a| a.class.name }})"
68
+ r
69
+ end
70
+ ```
71
+
64
72
  ## Contributing
65
73
 
66
74
  1. Fork it ( https://github.com/[my-github-username]/audio_monster/fork )
@@ -12,8 +12,6 @@ module AudioMonster
12
12
  MP3VAL_WARNING_RE = /WARNING/
13
13
  MP3VAL_ERROR_RE = /ERROR/
14
14
  MP3VAL_IGNORE_RE = /(^Done!|Non-layer-III frame encountered. See related INFO message for details.|No supported tags in the file|It seems that file is truncated or there is garbage at the end of the file|MPEG stream error, resynchronized successfully)/
15
- MPCK_ERROR_RE = /(mpck:|errors)/
16
- MPCK_IGNORE_RE = /errors(\s*)(CRC error|none)/
17
15
  LAME_SUCCESS_RE = /0/
18
16
  LAME_ERROR_RE = /fatal error/
19
17
  SOX_ERROR_RE = /error:/
@@ -35,7 +33,7 @@ module AudioMonster
35
33
 
36
34
  AES46_2002_TIME_FORMAT = '%H:%M:%S'
37
35
 
38
- BINARIES_KEYS = [:file, :ffmpeg, :ffprobe, :flac, :lame, :mpck, :mp3val, :sox, :soxi, :madplay, :twolame].freeze
36
+ BINARIES_KEYS = [:file, :ffmpeg, :ffprobe, :lame, :mp3val, :sox, :soxi, :twolame].freeze
39
37
 
40
38
  VALID_OPTIONS_KEYS = ([
41
39
  :logger,
@@ -115,13 +113,10 @@ module AudioMonster
115
113
  self.file = 'file'
116
114
  self.ffmpeg = 'ffmpeg'
117
115
  self.ffprobe = 'ffprobe'
118
- self.flac = 'flac'
119
116
  self.lame = 'lame'
120
- self.mpck = 'mpck'
121
117
  self.mp3val = 'mp3val'
122
118
  self.sox = 'sox'
123
119
  self.soxi = 'soxi'
124
- self.madplay = 'madplay'
125
120
  self.twolame = 'twolame'
126
121
  self
127
122
  end
@@ -24,6 +24,7 @@ module AudioMonster
24
24
  COMMON_EXTENSIONS = {
25
25
  'application/xml' => 'xml',
26
26
  'audio/mpeg' => 'mp3',
27
+ 'audio/flac' => 'flac',
27
28
  'audio/mp4' => 'm4a',
28
29
  'audio/ogg' => 'ogg',
29
30
  'image/jpeg' => 'jpg',
@@ -170,39 +171,6 @@ module AudioMonster
170
171
  ranges
171
172
  end
172
173
 
173
- def encode_wav_pcm_from_mpeg(original_path, wav_path, options={})
174
- logger.info "encode_wav_pcm_from_mpeg: #{original_path}, #{wav_path}, #{options.inspect}"
175
- # check to see if there is an original
176
- check_local_file(original_path)
177
-
178
- logger.debug "encode_wav_pcm_from_mpeg: start"
179
- command = "#{bin(:madplay)} -Q -i --output=wave:'#{wav_path}' '#{original_path}'"
180
-
181
- out, err = run_command(command)
182
-
183
- # check to see if there is a file created, or don't go on.
184
- check_local_file(wav_path)
185
- return [out, err]
186
- end
187
-
188
- def encode_wav_pcm_from_flac(original_path, wav_path, options={})
189
- logger.info "encode_wav_pcm_from_flac: #{original_path}, #{wav_path}, #{options.inspect}"
190
- # check to see if there is an original
191
- check_local_file(original_path)
192
-
193
- logger.debug "encode_wav_pcm_from_mpeg: start"
194
- command = "#{bin(:flac)} -s -f --decode '#{original_path}' --output-name='#{wav_path}'"
195
- out, err = run_command(command)
196
-
197
- # check to see if there is a file created, or don't go on.
198
- check_local_file(wav_path)
199
- return [out, err]
200
- end
201
-
202
- alias encode_wav_pcm_from_mp2 encode_wav_pcm_from_mpeg
203
- alias encode_wav_pcm_from_mp3 encode_wav_pcm_from_mpeg
204
-
205
- # experimental...should work on any ffmpeg compatible file
206
174
  def decode_audio(original_path, wav_path, options={})
207
175
  # check to see if there is an original
208
176
  logger.info "decode_audio: #{original_path}, #{wav_path}, #{options.inspect}"
@@ -771,44 +739,6 @@ module AudioMonster
771
739
  return true
772
740
  end
773
741
 
774
- def append_mp3_to_wav(wav_path, mp3_path, out_path, add_length, fade_length=5)
775
- # raise "append_mp3_to_wav: Can't find file to create mp3 preview of: #{mp3_path}" unless File.exist?(mp3_path)
776
-
777
- mp3info = Mp3Info.new(mp3_path)
778
- raise "mp3 is not sufficiently long enough (#{mp3info.length.to_i}) to add length (#{add_length})" if mp3info.length.to_i < add_length
779
- append_length = [mp3info.length.to_i, (add_length - 1)].min
780
- append_fade_length = [mp3info.length.to_i, fade_length].min
781
-
782
-
783
- # find out if the wav file is stereo or mono as this meeds to match the wav from the mp3
784
- wavinfo = info_for_wav(wav_path)
785
- channels = wavinfo[:channel_mode] == 'Mono' ? 1 : 2
786
- sample_rate = wavinfo[:sample_rate]
787
- append_file = nil
788
-
789
- begin
790
- append_file = create_temp_file(mp3_path)
791
- append_file.close
792
-
793
- # create the mp3 to append
794
- command = "#{bin(:madplay)} -q -o wave:- '#{mp3_path}' - | #{bin(:sox)} -t wav - -t raw -s -b 16 -c #{channels} - trim 0 #{append_length} | #{bin(:sox)} -t raw -r #{sample_rate} -s -b 16 -c #{channels} - -t wav - fade h 0 #{append_length} #{append_fade_length} | #{bin(:sox)} -t wav - -t wav '#{append_file.path}' pad 1 0"
795
- out, err = run_command(command)
796
- response = out + err
797
- response.split("\n").each{ |out| raise("append_mp3_to_wav: create append file error: '#{response}' on:\n #{command}") if out =~ SOX_ERROR_RE }
798
-
799
- # append the files to out_filew
800
- command = "#{bin(:sox)} -t wav '#{wav_path}' -t wav '#{append_file.path}' -t wav '#{out_path}'"
801
- out, err = run_command(command)
802
- response = out + err
803
- response.split("\n").each{ |out| raise("append_mp3_to_wav: create append file error: '#{response}' on:\n #{command}") if out =~ SOX_ERROR_RE }
804
- ensure
805
- append_file.close rescue nil
806
- append_file.unlink rescue nil
807
- end
808
-
809
- return true
810
- end
811
-
812
742
  def normalize_wav(wav_path, out_path, level=-9)
813
743
  logger.info "normalize_wav: wav_path:#{wav_path}, level:#{level}"
814
744
  command = "#{bin(:sox)} -t wav '#{wav_path}' -t wav '#{out_path}' gain -n #{level.to_i}"
@@ -824,10 +754,6 @@ module AudioMonster
824
754
 
825
755
  info = mp3info_validation(audio_file_path, options)
826
756
 
827
- # there are condtions where this spews output uncontrollably - so lose it for now: AK on 20080915
828
- # e.g. mpck:/home/app/mediajoint/tmp/audio_monster/prxfile-66097_111955868219902-0:3366912:read error
829
- # mpck_validation(audio_file_path, errors) if errors.size <= 0
830
-
831
757
  # if the format seems legit, check the audio itself
832
758
  mp3val_validation(audio_file_path, options)
833
759
 
@@ -1016,19 +942,6 @@ module AudioMonster
1016
942
  end
1017
943
  end
1018
944
 
1019
- def mpck_validation(audio_file_path, options)
1020
- errors= []
1021
- # validate using mpck
1022
- response = run_command("nice -n 19 #{bin(:mpck)} #{audio_file_path}")
1023
- response.split("\n").each { |o|
1024
- if ((o =~ MPCK_ERROR_RE) && !(o =~ MPCK_IGNORE_RE))
1025
- errors << "is not a valid mp2 file. The file is bad according to the 'mpck' audio check."
1026
- end
1027
- }
1028
-
1029
- errors
1030
- end
1031
-
1032
945
  def method_missing(name, *args, &block)
1033
946
  if name.to_s.starts_with?('encode_wav_pcm_from_')
1034
947
  decode_audio(*args)
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  module AudioMonster
4
- VERSION = '1.2.3'
4
+ VERSION = '1.3.0'
5
5
  end
@@ -11,7 +11,7 @@ describe AudioMonster do
11
11
  end
12
12
 
13
13
  it 'delegates methods to monster' do
14
- AudioMonster.flac.must_equal 'flac'
14
+ AudioMonster.ffmpeg.must_equal 'ffmpeg'
15
15
  end
16
16
 
17
17
  it 'returns an instance of monster' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audio_monster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kuklewicz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-15 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nu_wav