Skip to content

Commit

Permalink
feat: add files
Browse files Browse the repository at this point in the history
  • Loading branch information
h2non committed Jun 14, 2015
0 parents commit 63998d5
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
charset = utf-8
indent_style = tabs
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.sh]
insert_final_newline = false
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.DS_Store
npm-debug.log
test/.tmp
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.10"
- "0.12"
script: npm test
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# audioconcat [![Build Status](https://api.travis-ci.org/h2non/audioconcat.svg?branch=master)][travis] [![Code Climate](https://codeclimate.com/github/h2non/audioconcat/badges/gpa.svg)](https://codeclimate.com/github/h2non/audioconcat) [![NPM](https://img.shields.io/npm/v/audioconcat.svg)][npm] [![Dependency Status](https://gemnasium.com/h2non/audioconcat.svg)][gemnasium]

Tiny [node.js](http://nodejs.org) module to concat multiple audio files using ffmpeg

## Requirements

- **[ffmpeg](http://ffmpeg.org)** with additional compilation flags `--enable-libass --enable-libmp3lame`

You can download static builds of ffmpeg from [here](http://johnvansickle.com/ffmpeg/).

If you want to use `audioconcat` in Heroku, you could use the [ffmpeg2](https://github.com/h2non/heroku-buildpack-ffmpeg2) buildpack

## Install

```bash
npm install audioconcat
```

## Usage

```js
var videoshow = require('audioconcat')

var songs = [
'beatles.mp3',
'greenday.mp3',
'u2.mp3'
]

audioconcat(songs)
.save('all.mp3')
.on('start', function (command) {
console.log('ffmpeg process started:', command)
})
.on('error', function (err, stdout, stderr) {
console.error('Error:', err)
console.error('ffmpeg stderr:', stderr)
})
.on('end', function (output) {
console.error('Audio created in:', output)
})
```

Take a look to the [programmatic API](#api) for more details

## API

### audioconcat(images, [ options ])
Return: `audioconcat`

audioconcat constructor. You should pass an `array<string>` with the desired audio files,
and optionally passing the video render `options` object per each image.

Supported audio formats: `mp3`, `acc`, `ogg` (based on your ffmpeg compilation)

#### audioconcat#options(arguments)

Add multiple output options as command-line flags to pass to `ffmpeg`.
The argument must be an `array`

### audioconcat.VERSION
Type: `string`

Current package semantic version

### audioconcat.ffmpeg
Type: `function`

[fluent-ffmpeg](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg) API constructor

## License

[MIT](http://opensource.org/licenses/MIT) © Tomas Aparicio

[travis]: http://travis-ci.org/h2non/audioconcat
[gemnasium]: https://gemnasium.com/h2non/audioconcat
[npm]: http://npmjs.org/package/audioconcat
[ffmpeg-api]: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#creating-an-ffmpeg-command
[ffmpeg-colors]: https://www.ffmpeg.org/ffmpeg-utils.html#Color
38 changes: 38 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var merge = require('lodash.merge')
var ffmpeg = require('fluent-ffmpeg')

module.exports = function audioconcat(inputs, opts) {
return new Audioconcat(inputs, opts)
}

function Audioconcat(inputs) {
this.inputs = inputs || []
this.opts = opts || {}
}

Audioconcat.prototype.options = function (opts) {
merge(this.opts, opts)
return this
}

Audioconcat.prototype.concat = function (file) {
if (file) {
this.opts.output = file
}
return concat(this.inputs, this.opts)
}

function concat(inputs, opts) {
var first = inputs.slice(0, 1).shift()
var output = this.opts.output
var filter = 'concat:' + inputs.join('|')

var renderer = ffmpeg(first)
.filter(filer)

if (opts.output) {
renderer.save(opts.output)
}

return renderer
}
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "audioconcat",
"version": "0.1.0",
"description": "Concat multiple audio files into a unique one (uses ffmpeg)",
"repository": "h2non/audioconcat",
"author": "Tomas Aparicio",
"license": "MIT",
"main": "lib",
"directories": {
"lib": "./lib"
},
"scripts": {
"test": "./node_modules/.bin/mocha"
},
"keywords": [
"audio",
"mp3",
"acc",
"join",
"concat",
"merge",
"song",
"ffmpeg"
],
"dependencies": {
"fluent-ffmpeg": "^2.0.0",
"lodash.merge": "^3.0.0"
},
"devDependencies": {
"chai": "^1.10.0",
"mocha": "^2.0.1",
"rimraf": "^2.2.8"
}
}

0 comments on commit 63998d5

Please sign in to comment.