AssetPack plugin for converting files using ffmpeg.
There are two plugins exposed by this package:
audio
: Converts and compressesmp3
,wav
, andogg
audio files tomp3
andogg
.ffmpeg
: Exposes the fullffmpeg
API to convert any file to any other file
npm install --save-dev @assetpack/plugin-ffmpeg
You also need to install ffmpeg
on your system. You can find instructions on how to do that here.
import { audio } from "@assetpack/plugin-ffmpeg";
export default {
...
plugins: {
...
audio: audio(),
},
};
import { ffmpeg } from "@assetpack/plugin-ffmpeg";
export default {
...
plugins: {
...
// ffmpeg plugin takes an input array of extensions and produces an output based on the options
// You can pass any ffmpeg options to the options object
ffmpeg: ffmpeg({
inputs: ['.mp3', '.ogg', '.wav'],
outputs: [
{
formats: ['.mp3'],
recompress: false,
options: {
audioBitrate: 96,
audioChannels: 1,
audioFrequency: 48000,
}
},
{
formats: ['.ogg'],
recompress: false,
options: {
audioBitrate: 32,
audioChannels: 1,
audioFrequency: 22050,
}
},
]
}),
},
};