Skip to content

transitive-bullshit/ffmpeg-extract-audio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ffmpeg-extract-audio

Extracts an audio stream from a media file using fluent-ffmpeg.

NPM Build Status JavaScript Style Guide

Install

npm install --save ffmpeg-extract-audio
# or
yarn add ffmpeg-extract-audio

Usage

const extractAudio = require('ffmpeg-extract-audio')

await extractAudio({
  input: 'media/1.mp4',
  output: 'test.mp3'
})

API

extractAudio(options)

Extracts an audio stream from a media file. Returns a Promise for when the operation is complete.

options

input

Type: String

Path or URL to a media file.

output

Type: String

Path to write the output file to. If output is not specified, the result will be a ReadableStream.

format

Type: String

Audio container format to use.

Note: you may either specify output or format. If format is not specified, it will be inferred from the output file extension. If no format or output file is specified, the result will default to an mp3 stream.

channel

Type: Number Default: 0

Which audio channel to extract in the case of multiple audio channels.

transform

Type: Function Default: noop

Optional function to make changes to the underlying fluent-ffmpeg command. You may, for instance, change the audio bitrate or add custom audio filters.

Example:

// extract audio at 50% volume (result is an mp3 stream)
const mp3Stream = await extractAudio({
  input: 'media/1.mp4',
  format: 'mp3',
  transform: (cmd) => {
    cmd.audioFilters([
      {
        filter: 'volume',
        options: '0.5'
      }
    ])
  }
})
log

Type: Function Default: noop

Optional function to log the underlying ffmpeg command. You may, for example, use console.log

Related

License

MIT © Travis Fischer

Support my OSS work by following me on twitter twitter

About

Extracts an audio stream from a media file.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published