v0.1.0
π Deno native audio duration for MP3 / M4A / M4B (no dependencies)
Repository
Current version released
2 years ago
Dependencies
std
π Deno Audio Duration
Get the millisecond duration of audio files in pure Deno flavoured JavaScript. Currently MP3 / M4A / M4B formats are supported.
Usage
import {duration} from 'https://deno.land/x/deno_audio_duration@v0.1.0/mod.ts';
const ms = await duration('/path/to/audio.mp3');
The duration
function will detect audio formats based on the file extension. Import and use mp3Duration
and m4aDuration
to bypass this detection.
Other Solutions
If this module is insufficient use another tool with Deno.Command
:
With ffprobe:
ffprobe -loglevel quiet -show_format -print_format json audio.mp3
With exiftool:
exiftool -j -Duration audio.mp3
For example:
const stat = await Deno.stat(entry.path);
const command = new Deno.Command('exiftool', {
args: ['-j', '-Duration', `${entry.path}`]
});
const {stdout} = await command.output();
const json = JSON.parse(
new TextDecoder().decode(stdout)
);
Youβll need to parse the output.
License
MIT License
MIT License | Copyright Β© 2023 David Bushell | @dbushell