/flac-to-mp3

:white_check_mark: Convert .flac to .mp3

Primary LanguageJavaScript

Flac to MP3

Convert .flac files to .mp3.

Usage

First install ffmpeg.

To test whether ffmpeg is installed, simply run ffmpeg on the command line.

ffmpeg version 2.6 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Install flac-to-mp3

npm install flac-to-mp3

Functions

convert(path, onData, onDone, [bitrate]) //converts one file. onData and onDone are callbacks. Bitrate is optional, defaulting to 320.
convertDir(path, onData, onDone, [bitrate]) //converts an entire directory, the above rules still apply

Examples

The bitrate argument is optional

var f2m = require("flac-to-mp3")

f2m.convert(
	"path/to/file.flac",
	function(data) {
		console.log(data.err.toString())
	},
	function(){
		console.log("Conversion Complete.")
	},
	320
)
var f2m=require("flac-to-mp3")

f2m.convertDir(
	"path/to/directory",
	function(data){
		console.log(data.err.toString())
	},
	function(){
		console.log("Conversion Complete")
	},
	320
)

Todo

  • Create a proper test suite
  • Add a convertDir() method
  • Turn into a CLI

Tests

Soon to be suited up with Mocha and Chai.

Test files are available from www.eclassical.com.

The tests use the following files: