GithubHelp home page GithubHelp logo

audiosprite's Introduction

Build Status

What?

This is a ffmpeg wrapper that will take in multiple audio files and combines them into a single file. Silent gaps will be put between the parts so that every new part starts from full second and there is at least 1 second pause between every part. The final file will be exported in mp3, ogg, ac3, m4a and caf(IMA-ADPCM) to support as many devices as possible. This tool will also generate a JSON file that is compatible with Howler.js or zynga/jukebox framework.

Why?

iOS, Windows Phone and some Android phones have very limited HTML5 audio support. They only support playing a single file at a time and loading in new files requires user interaction and has a big latency. To overcome this there is a technique to combine all audio into single file and only play/loop certain parts of that file. zynga/jukebox is a audio framework that uses this technique. digitalfruit/limejs is a HTML5 game framework that includes Jukebox and lets you add audio to your games using audio sprites.

Installation

via npm package

npm install -g audiosprite

via github (latest)

npm install -g git+https://github.com/tonistiigi/audiosprite.git

Dependencies

You can install FFmpeg and the ogg codecs on OSX using brew:

brew install ffmpeg --with-theora --with-libvorbis

Hints for Windows users

  • You need to install Node.js
  • Use Git Bash instead of Command Line or Powershell
  • Download ffmpeg and include it in your path export PATH=$PATH:path/to/ffmpeg/bin
  • IMA-ADPCM(the fastest iPhone format) will only be generated if you are using OSX.

Usage

> audiosprite --help
info: Usage: audiosprite [options] file1.mp3 file2.mp3 *.wav
info: Options:
  --output, -o          Name for the output files.                                               [default: "output"]
  --path, -u            Path for files to be used on final JSON.                                 [default: ""]
  --export, -e          Limit exported file types. Comma separated extension list.               [default: "ogg,m4a,mp3,ac3"]
  --format, -f          Format of the output JSON file (jukebox, howler, howler2, createjs).     [default: "jukebox"]
  --log, -l             Log level (debug, info, notice, warning, error).                         [default: "info"]
  --autoplay, -a        Autoplay sprite name.                                                    [default: null]
  --loop                Loop sprite name, can be passed multiple times.                          [default: null]
  --silence, -s         Add special "silence" track with specified duration.                     [default: 0]
  --gap, -g             Silence gap between sounds (in seconds).                                 [default: 1]
  --minlength, -m       Minimum sound duration (in seconds).                                     [default: 0]
  --bitrate, -b         Bit rate. Works for: ac3, mp3, mp4, m4a, ogg.                            [default: 128]
  --vbr, -v             VBR [0-9]. Works for: mp3. -1 disables VBR.                              [default: -1]
  --samplerate, -r      Sample rate.                                                             [default: 44100]
  --channels, -c        Number of channels (1=mono, 2=stereo).                                   [default: 1]
  --rawparts, -p        Include raw slices(for Web Audio API) in specified formats.              [default: ""]
  --ignorerounding, -i  Bypass sound placement on whole second boundaries (0=round,1=bypass).    [default: 0]
  --help, -h            Show this help message.


> audiosprite --autoplay bg_loop --output mygameaudio bg_loop.wav *.mp3
info: File added OK file=bg_loop.wav
info: 1.25s silence gap added OK
info: File added OK file=click.mp3
info: 1.70s silence gap added OK
info: Exported caf OK file=mygameaudio.caf
info: Exported ac3 OK file=mygameaudio.ac3
info: Exported mp3 OK file=mygameaudio.mp3
info: Exported m4a OK file=mygameaudio.m4a
info: Exported ogg OK file=mygameaudio.ogg
info: Exported json OK file=mygameaudio.json
info: All done


> cat mygameaudio.json
{
  "resources": [
    "mygameaudio.caf",
    "mygameaudio.ac3",
    "mygameaudio.mp3",
    "mygameaudio.m4a",
    "mygameaudio.ogg"
  ],
  "spritemap": {
    "bg_loop": {
      "start": 0,
      "end": 3.75,
      "loop": true
    },
    "click": {
      "start": 5,
      "end": 5.3,
      "loop": false
    }
  },
  "autoplay": "bg_loop"
}

API Usage

var audiosprite = require('audiosprite')

var files = ['file1.mp3', 'file2.mp3']
var opts = {output: 'result'}

audiosprite(files, opts, function(err, obj) {
  if (err) return console.error(err)

  console.log(JSON.stringify(obj, null, 2))
})

Setting autoplay track

You can use --autoplay option to set a track that will start playing automatically. This track is then marked as autoplay and looping in the JSON. This syntax is Jukebox framework specific.

Custom silent track

On some cases starting and pausing a file has bigger latency than just setting playhead position. You may get better results if your file is always playing. --silence <duration> option will generate extra track named silence that you can play instead of pausing the file.

Usage with digitalfruit/limejs framework.

First generate LimeJS asset from the JSON file that you can require inside your code.

> bin/lime.py gensoy path/to/mygameaudio.json

Then use AudioMap class to play the file.

goog.require('lime.audio.AudioMap');
goog.require('lime.ASSETS.mygameaudio.json');

var audio = new lime.audio.AudioMap(lime.ASSETS.mygameaudio.json);
...
audio.play('click');

Don't forget to use the --rawparts=mp3 option to benefit from the LimeJS feature to automatically switch to Web Audio API when it's supported by the client.

Usage with zynga/jukebox framework. (DISCONTINUED)

NOTE: The jukebox project from Zynga has been abandoned. This section remains for reference.

Generated JSON file can be passed straight into jukebox.Player constructor. Check out Jukebox documentation/demos for more info.

var settings = {/* JSON generated by audiosprite*/};
...
// This part needs to be in user event callback.
var myPlayer = new jukebox.Player(settings);
...
myPlayer.play('click');

audiosprite's People

Contributors

bassarisse avatar blvz avatar ceefour avatar davidprozesky avatar endel avatar gmartigny avatar jelmervdl avatar juice49 avatar k2s avatar kacinskas avatar kalafut avatar larsonjj avatar marekventur avatar mariuz avatar mathieuloutre avatar okaybenji avatar probityrules avatar qtiki avatar sargodarya avatar tonistiigi avatar viezevingertjes avatar zlumer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

audiosprite's Issues

output increases size significantly

I'm testing this lib out by combining two mp3s. One is 22kb and the other is 37kb. The output mp3 is 113kb. I'm using 0 gap for testing purposes. What could be increasing the output file size so much?

Ubuntu 16.04 compatability

To make this work on Ubuntu I had to symlink avconv as ffmpeg and change line 166 to add "-strict -2" just before the output file name

spawn('ffmpeg',['-y', '-ar', opts.samplerate, '-ac', opts.channels, '-f', 's16le', '-i', src]
    .concat(opt).concat(['-strict','-2']).concat(outfile))

--gap options does not work

I need no gap between sound sprites but logs shows that gaps are added and quite big gaps
e.g.
cmd line: audiosprite -l debug --output d:/work/hero/sounds-reduced -f howler -v 3 -g 0.0001 D:/work/hero/src/branches/small/res/sounds-reduced/*
output
info: File added OK file=C:\Users\SSOLOZ1\AppData\Local\Temp\audiosprite.6968405144289136, duration=1.629750566893424
info: Silence gap added duration=0.370349433106576
debug: Start processing file=D:/work/hero/src/branches/small/res/sounds-reduced/stone_fall.ogg
debug: Spawn cmd=ffmpeg -i D:\work\hero\src\branches\small\res\sounds-reduced\stone_fall.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=C:\Users\SSOLOZ
1\AppData\Local\Temp\audiosprite.26521250791847706, duration=0.21623582766439908
info: Silence gap added duration=0.7838641723356009
debug: Start processing file=D:/work/hero/src/branches/small/res/sounds-reduced/stones_collision.ogg
debug: Spawn cmd=ffmpeg -i D:\work\hero\src\branches\small\res\sounds-reduced\stones_collision.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=C:\Users\SSOLOZ1\AppData\Local\Temp\audiosprite.707215964095667, duration=0.14512471655328799
info: Silence gap added duration=0.854975283446712
debug: Start processing file=D:/work/hero/src/branches/small/res/sounds-reduced/stones_collision2.ogg
debug: Spawn cmd=ffmpeg -i D:\work\hero\src\branches\small\res\sounds-reduced\stones_collision2.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=C:\Users\SSOLOZ
1\AppData\Local\Temp\audiosprite.14779552235268056, duration=0.2620181405895692
info: Silence gap added duration=0.7380818594104308
debug: Start processing file=D:/work/hero/src/branches/small/res/sounds-reduced/stopwatch_add.ogg
debug: Spawn cmd=ffmpeg -i D:\work\hero\src\branches\small\res\sounds-reduced\stopwatch_add.ogg -ar 44100 -ac 1 -f s16le pipe:

env: node\r: No such file or directory

For some reason, after installing the package, the binary audiosprite has wrong line endings, resulting this error.

$ npm install --save-dev audiosprite
$ ./node_modules/.bin/audiosprite --help
env: node\r: No such file or directory

I've cloned the project locally and ./cli.js works properly - no problem with line ending. Maybe publishing to NPM from a windows machine mess up with line endings?

More info about this here: npm/npm#4607

Under heavy CPU load audiosprite sometimes generates 0-length sprites on Linux

Audiosprite spawns ffmpeg with stdout pipe when it generates sprites. It is listening for the 'exit' event instead of 'close' which causes the piped stdout stream to sometimes be incomplete before the sprite is generated:

ffmpeg.on('exit', function(code, signal) {

I ran into this issue with our build system which is concurrently generating loads of sprites (ie. maxing out cpu). I was able to reproduce this with Amazon AMI Linux as well as Ubuntu Linux (running in AWS as well). Also I tried with Node 6.x and 8.x - both behaving similarly. I wrote a small script to reproduce this behaviour with a simple 'cat' operation piping a large text file to stdout and listening to the 'exit' event. Changing the 'exit' to 'close' fixed the problem.

Link to the 'close' event documentation: https://nodejs.org/api/child_process.html#child_process_event_close

Some related discussion: https://stackoverflow.com/questions/37522010/difference-between-childprocess-close-exit-events

Let me know if you need more details on this.

Rawparts ordering can get mixed up

Spritemap object keys are not ordered. This means that it can get mixed up with rawparts that are just a sequence of numbers.

Possible solutions:

  • always sort rawparts by spritename
  • use spritename in rawparts filename

Any way to do this without breaking old behavior? Don't want to add a new option flag again.

Test output json format

Tests currently only check the old jukebox format. Ideally all formats should be checked as new contributors will likely use only one themselves.

Beep end time not 1.77

$ git clone [email protected]:tonistiigi/audiosprite.git
$ cd audiosprite
$ npm install
$ npm test

...
Uncaught AssertionError: beep end time not 1.77

Am I missing something?

Edit: Oh, it's 1.7235147392290249 btw.

Audio file formats

Hello... first, thanks for the really useful tool!

I was just wondering, is there any way to ask the program to only spit out an mp3? The problem is that recent versions of FFMPEG don't come with the correct codecs to generate m4a files, so the process dies when it gets to that point.

Cheers
Jon

Error on export

Hi !

I'm trying to use audiosprite on Windows and I get the following error.
FFmpeg is installed and working.
Do you know why I get that error message ?
(error: Error exporting file msg=Error exporting file, format=mp3, retcode=1, signal=null)

Thanks !

$ audiosprite 1.mp3 2.mp3
info: File added OK file=C:\Users\fboss\AppData\Local\Temp\audiosprite.917463, duration=1.4106122448979592
info: Silence gap added duration=1.5893877551020408
info: File added OK file=C:\Users\fboss\AppData\Local\Temp\audiosprite.13961, duration=1.5151020408163265
info: Silence gap added duration=1.4848979591836735
error: Error exporting file msg=Error exporting file, format=mp3, retcode=1, signal=null

API Usage

Hi

I am busy writing a little app that uses a UI to create AudioSprites. Im running into an issue where when my app is packaged it does not seem to find ffmpeg. Is there a way to bundle ffmpeg into my app and point audiosprite to that file? Also, where do the exported files get created when using the API?

Not sure if this is an issue or just lack of documentation or maybe my own stupidity.

Regards

PS: This is the error im getting :

Uncaught Exception:
Error: spawn ffmpeg ENOENT
at exports._errnoException (util.js:856:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at doNTCallback2 (node.js:465:9)
at process._tickCallback (node.js:379:17)

Minimal length can't be set less than 1 sec

By default samples length is 1 second, I've tried set --minlength 0.2 and 0 sec but looks like samples length is still 1 second. Values longer then 1 seconds works properly.

Full command
audiosprite PATH\*.wav --output PATH\sprites\mysound --export ogg,mp3,wav --gap 0 --minlength 0.2

source wav-files

File export (ffmpeg) is hanging because spawned ffmpeg output is not processed

Having given audiosprite many input mp3's, we have found that final file export never completes.

It seems, the reason is that ffmpeg's output buffer gets full and should be read out. Otherwise it starts hanging. (Please, check the following: http://stackoverflow.com/questions/20792427/why-is-my-node-child-process-that-i-created-via-spawn-hanging)

As a workaround, we tried to specify the -v quiet option to ffmpeg and it solved the problem. Also specifying {stdio: 'ignore'} to spawn solves the issue.

Allow output to be in subdirectory

Currently output files are only written to current directory. Because JSON asset paths are loaded relative to the page the plain filenames are likely to be wrong.

Support for Promise API?

It would be nice to have this library being able to export a Promise in order to use it synchronously with async/await.

error: Error: Error exporting file

I have a question about an error, and two small additional questions:

  1. I tried running this for the first time and got the error shown below. Could anyone explain it to me, please? I have FFmpeg installed.
  2. I specified a 2 second silence gap, but it says "Silence gap added duration=3". Why the extra second?
  3. Is there a way to add silence to the start of the track, too?

Thanks very much.


$ audiosprite -s 2 -o combo1 'AARON GERVAIS (LOUIS CK AM SPINRADE).mp3' 'ALICIA WALTER (REAL TALK).mp3 BIRTHMARK' '(LOVE POWER).mp3'

info: Silence gap added duration=3
info: 0=AARON GERVAIS (LOUIS CK AM SPINRADE).mp3
info: File added OK file=/var/folders/qq/wjmnhkns4vjb1r77hqv2f1pr0000gn/T/audiosprite.14227197977886363, duration=155.37632653061223
info: Silence gap added duration=1.623673469387768

error: Error: Error exporting file
at /usr/local/lib/node_modules/audiosprite/audiosprite.js:312:27
at /usr/local/lib/node_modules/audiosprite/node_modules/async/lib/async.js:148:21
at ChildProcess. (/usr/local/lib/node_modules/audiosprite/audiosprite.js:190:18)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

0.6.0 seems to be broken in npmjs

└> npm -g i audiosprite
/Users/metalim/.nvm/versions/node/v5.7.0/bin/audiosprite -> /Users/metalim/.nvm/versions/node/v5.7.0/lib/node_modules/audiosprite/cli.js
/Users/metalim/.nvm/versions/node/v5.7.0/lib
└── [email protected]

└> audiosprite
env: node\r: No such file or directory

└> npm -g i [email protected]
/Users/metalim/.nvm/versions/node/v5.7.0/bin/audiosprite -> /Users/metalim/.nvm/versions/node/v5.7.0/lib/node_modules/audiosprite/cli.js
- [email protected] node_modules/audiosprite/node_modules/balanced-match
- [email protected] node_modules/audiosprite/node_modules/concat-map
- [email protected] node_modules/audiosprite/node_modules/brace-expansion
- [email protected] node_modules/audiosprite/node_modules/inherits
- [email protected] node_modules/audiosprite/node_modules/minimatch
- [email protected] node_modules/audiosprite/node_modules/path-is-absolute
- [email protected] node_modules/audiosprite/node_modules/wrappy
- [email protected] node_modules/audiosprite/node_modules/once
- [email protected] node_modules/audiosprite/node_modules/inflight
- [email protected] node_modules/audiosprite/node_modules/glob
/Users/metalim/.nvm/versions/node/v5.7.0/lib
└── [email protected]

└> audiosprite
error: No input files specified.
info: Usage: audiosprite [options] file1.mp3 file2.mp3 *.wav
...

*.mp3 doens't find all mp3-files

Hi,
When I try to add all the mp3-files in the directory, i get this:

No errors

Only if I specify each file, it works.

Do you have an idea what to do?

ffmpeg error with [s16le @ 0x863400] Could not find codec parameters (Audio: pcm_s16le, 1 channels, s16)

Files are from http://gnome-look.org/content/show.php/Cleanus?content=61245

(these are MP3 files named as ogg, don't know why, but renaming the files to mp3 has no effect)

ceefour@hendy:~/tmp/Cleanus-OGG/sprite > audiosprite -e ogg,mp3 -f howler -o cleanus-ogg -g 0.3 ../*.ogg
debug: Parsed arguments _=[../Battery_Charging.ogg, ../K3B_Error.ogg, ../K3B_Success.ogg, ../KDE_Desktop10.ogg, ../KDE_Desktop1.ogg, ../KDE_Desktop2.ogg, ../KDE_Desktop3.ogg, ../KDE_Desktop4.ogg, ../KDE_Desktop5.ogg, ../KDE_Desktop6.ogg, ../KDE_Desktop7.ogg, ../KDE_Desktop8.ogg, ../KDE_Desktop9.ogg, ../KDE_Device_Connected.ogg, ../KDE_Device_Disconnected.ogg, ../KDE_Error.ogg, ../KDE_Event2.ogg, ../KDE_Event.ogg, ../KDE_Logout.ogg, ../KDE_pop.ogg, ../KDE_Startup.ogg, ../KDE_Window_Close.ogg, ../KDE_Window_Open.ogg, ../KDE_Window_Shade_Down.ogg, ../KDE_Window_Shade_Up.ogg, ../Kopete_Event.ogg, ../Kopete_Received.ogg, ../Kopete_Sent.ogg, ../Kopete_User_is_Online.ogg, ../LowBatteryAlarm.ogg, ../Window_Iconify.ogg], e=ogg,mp3, export=ogg,mp3, f=howler, format=howler, o=cleanus-ogg, output=cleanus-ogg, g=0.3, gap=0.3, path=, u=, log=info, l=info, autoplay=null, a=null, silence=0, s=0, minlength=0, m=0, samplerate=44100, r=44100, channels=1, c=1, rawparts=, p=, $0=audiosprite
debug: Created temporary file file=/tmp/audiosprite.014362295158207417
debug: Spawn cmd=ffmpeg -version
debug: Start processing file=../Battery_Charging.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/Battery_Charging.ogg -ar 44100 -ac 1 -f s16le pipe:
util.pump() is deprecated. Use readableStream.pipe() instead.
info: File added OK file=/tmp/audiosprite.22132545709609985, duration=1.044671201814059
info: Silence gap added duration=1.2553287981859411
debug: Start processing file=../K3B_Error.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/K3B_Error.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.13487249799072742, duration=2.141814058956916
info: Silence gap added duration=1.1581859410430841
debug: Start processing file=../K3B_Success.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/K3B_Success.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.3766818977892399, duration=1.7499773242630385
info: Silence gap added duration=0.5500226757369615
debug: Start processing file=../KDE_Desktop10.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop10.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.7876935570966452, duration=0.5744671201814059
info: Silence gap added duration=0.725532879818594
debug: Start processing file=../KDE_Desktop1.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop1.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.7543931272812188, duration=0.5483446712018141
info: Silence gap added duration=0.751655328798186
debug: Start processing file=../KDE_Desktop2.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop2.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.26619959552772343, duration=0.5483446712018141
info: Silence gap added duration=0.751655328798186
debug: Start processing file=../KDE_Desktop3.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop3.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.5545179196633399, duration=0.5483446712018141
info: Silence gap added duration=0.751655328798186
debug: Start processing file=../KDE_Desktop4.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop4.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.7542353158351034, duration=0.5483446712018141
info: Silence gap added duration=0.751655328798186
debug: Start processing file=../KDE_Desktop5.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop5.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.622084665345028, duration=0.5483446712018141
info: Silence gap added duration=0.751655328798186
debug: Start processing file=../KDE_Desktop6.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop6.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.173782936995849, duration=0.5483446712018141
info: Silence gap added duration=0.751655328798186
debug: Start processing file=../KDE_Desktop7.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop7.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.0012624321971088648, duration=0.5483446712018141
info: Silence gap added duration=0.751655328798186
debug: Start processing file=../KDE_Desktop8.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop8.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.6332280528731644, duration=0.5483446712018141
info: Silence gap added duration=0.751655328798186
debug: Start processing file=../KDE_Desktop9.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Desktop9.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.5749752067495137, duration=0.6267120181405895
info: Silence gap added duration=0.6732879818594104
debug: Start processing file=../KDE_Device_Connected.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Device_Connected.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.20169578585773706, duration=1.044671201814059
info: Silence gap added duration=1.2553287981859411
debug: Start processing file=../KDE_Device_Disconnected.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Device_Disconnected.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.956946864258498, duration=1.0185487528344672
info: Silence gap added duration=1.2814512471655328
debug: Start processing file=../KDE_Error.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Error.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.18649493507109582, duration=0.7312018140589569
info: Silence gap added duration=0.5687981859410431
debug: Start processing file=../KDE_Event2.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Event2.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.7731257516425103, duration=0.8095691609977325
info: Silence gap added duration=0.4904308390022675
debug: Start processing file=../KDE_Event.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Event.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.400481037562713, duration=0.8095691609977325
info: Silence gap added duration=0.4904308390022675
debug: Start processing file=../KDE_Logout.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Logout.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.7914322479628026, duration=2.820997732426304
info: Silence gap added duration=0.4790022675736962
debug: Start processing file=../KDE_pop.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_pop.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.42137549072504044, duration=0.4960997732426304
info: Silence gap added duration=0.8039002267573696
debug: Start processing file=../KDE_Startup.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Startup.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.06403044448234141, duration=5.589977324263039
info: Silence gap added duration=0.7100226757369612
debug: Start processing file=../KDE_Window_Close.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Window_Close.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.36530930432491004, duration=0.5483446712018141
info: Silence gap added duration=0.751655328798186
debug: Start processing file=../KDE_Window_Open.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Window_Open.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.019994460744783282, duration=0.1565079365079365
info: Silence gap added duration=1.1434920634920636
debug: Start processing file=../KDE_Window_Shade_Down.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Window_Shade_Down.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.29141633468680084, duration=0.3654875283446712
info: Silence gap added duration=0.9345124716553288
debug: Start processing file=../KDE_Window_Shade_Up.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/KDE_Window_Shade_Up.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.4547124393284321, duration=0.31324263038548755
info: Silence gap added duration=0.9867573696145124
debug: Start processing file=../Kopete_Event.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/Kopete_Event.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.2244569652248174, duration=1.2797732426303854
info: Silence gap added duration=1.0202267573696147
debug: Start processing file=../Kopete_Received.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/Kopete_Received.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.5800625709816813, duration=0.9401814058956917
info: Silence gap added duration=0.35981859410430833
debug: Start processing file=../Kopete_Sent.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/Kopete_Sent.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.9119340069591999, duration=0.7573242630385487
info: Silence gap added duration=0.5426757369614512
debug: Start processing file=../Kopete_User_is_Online.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/Kopete_User_is_Online.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.622257454553619, duration=0.8618140589569161
info: Silence gap added duration=0.4381859410430839
debug: Start processing file=../LowBatteryAlarm.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/LowBatteryAlarm.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.35453224810771644, duration=1.2275283446712018
info: Silence gap added duration=1.0724716553287983
debug: Start processing file=../Window_Iconify.ogg
debug: Spawn cmd=ffmpeg -i /home/ceefour/tmp/Cleanus-OGG/Window_Iconify.ogg -ar 44100 -ac 1 -f s16le pipe:
info: File added OK file=/tmp/audiosprite.48956903093494475, duration=0.4438548752834467
info: Silence gap added duration=0.8561451247165532
debug: Start export format=ogg
debug: Spawn cmd=ffmpeg -y -ac 1 -f s16le -i /tmp/audiosprite.014362295158207417 -acodec libvorbis -f ogg cleanus-ogg.ogg
[1]

ceefour@hendy:~/tmp/Cleanus-OGG/sprite > ffmpeg -y -ac 1 -f s16le -i /tmp/audiosprite.014362295158207417 -acodec libvorbis -f ogg cleanus-ogg.ogg
ffmpeg version 0.8.10-6:0.8.10-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers
  built on Feb  6 2014 20:53:28 with gcc 4.8.1
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Ignoring attempt to set invalid timebase for st:0
[s16le @ 0x863400] Could not find codec parameters (Audio: pcm_s16le, 1 channels, s16)
[s16le @ 0x863400] Estimating duration from bitrate, this may be inaccurate
/tmp/audiosprite.014362295158207417: could not find codec parameters
[1]

For audiosprite -c 2 -f howler -o cleanus-mp3 -g 0.3 ../*.mp3 :

ceefour@hendy:~/tmp/Cleanus-OGG/sprite > ffmpeg -y -ac 2 -f s16le -i /tmp/audiosprite.45090715354308486 -acodec libvorbis -f ogg cleanus-mp3.ogg
ffmpeg version 0.8.10-6:0.8.10-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers
  built on Feb  6 2014 20:53:28 with gcc 4.8.1
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.                                        
Ignoring attempt to set invalid timebase for st:0
[s16le @ 0x2193400] Estimating duration from bitrate, this may be inaccurate
Input #0, s16le, from '/tmp/audiosprite.45090715354308486':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0.0: Audio: pcm_s16le, 2 channels, s16
[ogg @ 0x219f120] sample rate not set
Output #0, ogg, to 'cleanus-mp3.ogg':
    Stream #0.0: Audio: libvorbis, 2 channels, s16
Stream mapping:
  Stream #0.0 -> #0.0
Could not write header for output file #0 (incorrect codec parameters ?)

Additionally #14 should be fixed to make it less confusing.

Audiosprite doesn't see the first file in the folder.

audiosprite --output minimalist -f howler --export ogg,mp3 -g 0 --path *.wav

When there are 6 wave files in the folder, audiosprite will only see 5 of them.
When there are 5 wave files in the folder, audiosprite will only see 4 of them.
..
..
When there is 1 wave file in the folder, audiosprite will mention there are no files.

MacOS ventura.

.ogg not exporting when using single channel

Im trying to export an ogg using single channel, but it breaks on the following command :
debug: Start export format=ogg
debug: Spawn cmd=ffmpeg -y -ar 22050 -ac 1 -f s16le -i /var/folders/2g/mnz3cs295mx9hrx7l9y3c3640000gp/T/audiosprite.3490381531883031 -acodec libvorbis -f ogg -ab 128k baseGameSound.ogg

It does however work when I do not use single channel.

id's are incorrect in json if source files have number filnames

Hi,

ran in to an issue where if using a directory for input and the filenames are all numberic ie.. 1.mp3, 2.mp3, 3.mp3 the id's generated in the json (i'm using createjs) don't correspond to the input files.

the json has all the id's, and the information included with the id is valid (start, duration), but the id does not correspond to the input file. i'm on win 10.

Check for actual existence of TMPDIR before initiating ffmpeg?

I just had a long head-scratching session that could be solved with a simple addition to audiosprite. On Linux at least, audiosprite uses the directory found in the TMPDIR environment variable for temporary file creation. Because it is the only app on my PC that uses that variable it took me a while to figure out what my root problem was with my audiosprite runs, since they were failing with the dreaded ENOENT error. The problem turned out to be that the directory value assigned to TMPDIR was invalid. That is, the value assigned to TMPDIR did not exist on my disk. Once I figured this out I changed TMPDIR to a valid directory and audiosprite worked fine.

I suggest having audiosprite do a directory existence check for the directory found in TMPDIR, before actually trying to run ffmpeg, and reporting a fatal error if the directory is not found.

Thank you for creating this useful utility.

It publish some empty audio file, zero length

"spritemap": {
"a_lose": {
"start": 0,
"end": 0,
"loop": false
},
"a_sitdown": {
"start": 1,
"end": 1,
"loop": false
},
"a_standup": {
"start": 2,
"end": 2,
"loop": false
},
...........................
File added OK file=/var/folders/kk/nc3_3h215n928hptm6g52ps40000gn/T/audiosprite.7941562433261424, duration=0

JSON output is Jukebox format by default; help says it is Howler

The help notes that Howler is the default, however the JSON output appears to be Jukebox format when "--format howler" is not specified:

info: Usage: audiosprite [options] file1.mp3 file2.mp3 *.wav
info: Options:
...
  --format, -f      Format of the output JSON file (default, howler)

Tested on Windows with audiosprite v0.3.0.

Error exporting file msg=Error exporting file, format=aiff, retcode=1, signal=null

When run with debug option
ffmpeg version 0.8.9-6:0.8.9-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers
built on Nov 9 2013 19:09:46 with gcc 4.8.1
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Ignoring attempt to set invalid timebase for st:0
[s16le @ 0x1e2a1c0] Could not find codec parameters (Audio: pcm_s16le, 1 channels, s16)
[s16le @ 0x1e2a1c0] Estimating duration from bitrate, this may be inaccurate
/tmp/audiosprite.2510260413400829: could not find codec parameters

Can't generate audiosprite

I tried to create an audiosprite for my game. But audiosprite always fail with the same error.

stefans-mbp:sounds stefansvebeck$ sudo audiosprite --log debug *.mp3
debug: Parsed arguments _=[bk_between_questions.mp3, bk_dialog_1.mp3, bk_dialog_2.mp3, bk_final_round.mp3, bk_main_1.mp3, bk_main_2.mp3, bk_question.mp3, ch_ming.mp3, ch_nemi.mp3, ch_rosanna.mp3, ch_simon.mp3, fx_after_question.mp3, fx_before_question.mp3, fx_bladlusen.mp3, fx_bladlusen_short.mp3, fx_click.mp3, fx_liv.mp3, fx_liv_short.mp3, fx_pr.mp3, fx_right.mp3, fx_right_short.mp3, fx_round_new.mp3, fx_wrong.mp3, fx_wrong_scary.mp3], log=debug, l=debug, output=output, o=output, path=, u=, export=ogg,m4a,mp3,ac3, e=ogg,m4a,mp3,ac3, format=default, f=default, autoplay=null, a=null, silence=0, s=0, gap=1, g=1, minlength=0, m=0, samplerate=44100, r=44100, channels=1, c=1, rawparts=, p=, $0=node /usr/local/bin/audiosprite
debug: Created temporary file file=/tmp/audiosprite.24839226342737675
debug: Spawn cmd=ffmpeg -version

events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:988:11)
at Process.ChildProcess._handle.onexit (child_process.js:779:34)

Better error reporting

  • audiosprite checks that ffmpeg doesn't return error but doesn't check for ENOENT.
  • if there is any error during spawn, stdout/stderr of the child process should be printed out.

See #13

Silence gaps introduce pops in output file.

Suddenly audio distortions have started to appear in our audiosprites files. We're not sure if it's a change to node or what but here is a fix:

(In appendSilence function line 231)

buffer.fill(null)

becomes

buffer.fill(0)

I'm running node v0.11.12 and ffmpeg 2.2.3

Previously I had ffmpeg 1.2 and the pops/cracks were still in the generated file. Upgrading ffmpeg did not resolve the issue.

README ffmpeg brew install command

When using the install command for ffmpeg from the readme

brew install ffmpeg --with-theora --with-libogg --with-libvorbis

I received this warning from brew:

Warning: ffmpeg: this formula has no --with-libogg option so it will be ignored!

Seems to work fine

--rawparts filenames

audiosprite --rawparts "mp3,ogg" -o 'sprite' -s 2 .

creates rawparts with filenames "sprite_001", "sprite_002" etc - should these filenames not match the original filenames and therefore the id's in the sprite json file so that switching between using a webaudio system and an audiosprite system can use the same ids?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.