Skip to content

streamonkey/libav-stream-info-wasm

Repository files navigation

libav-stream-info-wasm

This library uses libav to extract an audio files metadata, just like ffprobe does.

Version 2.0.0 pulls the source code of ffmpeg version 4.3.1 in docker and compiles it to WASM/JS via emscripten.

At the end all code is bundled into a single file so it can be easily used in the Browser with any bundler.

Usage

The runtime exports two functions that take a File as an argument:

  • getAudioFileTags function returns an object of the corresponding metadata tags.
  • getAudioFileDuration function returns the duration of the audio file in milliseconds.

Internally this uses a WebWorker to prevent blocking the main thread.

Building

Prerequisites: Docker installed

bash build.sh

Thanks

A big thanks to https://github.com/tfoxy/ffprobe-wasm and https://github.com/alfg/ffprobe-wasm