Audio & Video Processing

Libraries for manipulating audio, video, and their metadata.

To track tempo and beats with a Python audio processing library, load music into librosa. MoviePy cuts and joins video in code. Mutagen reads and writes tags.

How to choose:

  • Tempo, beats, and other music analysis: librosa
  • Scripted video edits, titles, and compositing: MoviePy
  • Reading and writing tags: Mutagen
  • Reading and writing sound files as NumPy arrays: soundfile
  • Slicing, fading, and joining audio clips: pydub
  • Frame- and packet-level access to FFmpeg: PyAV
  • Reading tags only, without GPL code: tinytag
  • Organizing a music collection with MusicBrainz data: beets

Listed in editorial order, grouped by use case. Click a column header to re-sort the whole list.

Press / to search. Tags open their category. Click a row for details.

Search and filter

Results

Row number Tags

Audio 3 projects

An audio library for reading and writing sound files, based on libsndfile, CFFI, and NumPy.
Python library for audio and music analysis.
librosa/github.com/librosa/librosa /8,719 stars /
Manipulate audio with a simple and easy, high-level interface.
jiaaro/github.com/jiaaro/pydub /9,803 stars /

Video 2 projects

Pythonic bindings for FFmpeg's libraries.
PyAV-Org/github.com/PyAV-Org/PyAV /3,321 stars /
A module for script-based movie editing with many formats, including animated GIFs.
Zulko/github.com/Zulko/moviepy /15,054 stars /

Metadata 3 projects

A Python module to handle audio metadata.
quodlibet/github.com/quodlibet/mutagen /1,981 stars /
A library for reading audio file metadata of MP3, MP4, WAV, OGG, FLAC, WMA, and AIFF files.
tinytag/github.com/tinytag/tinytag /843 stars /
A music library manager and MusicBrainz tagger.
beetbox/github.com/beetbox/beets /15,869 stars /

Audio & Video Processing guide

librosa is a Python library for audio and music signal processing, with the building blocks for music information retrieval: spectrograms, chroma, onsets, tempo, and beats. Load each file with librosa.load(), which resamples it to a standard rate and mixes it down to mono, the defaults the rest of librosa is designed around.

soundfile reads and writes any format libsndfile supports, like WAV, FLAC, and OGG: sf.read() returns the samples as a NumPy array along with the sample rate, and sf.write() saves them. librosa reads files through soundfile, and its docs recommend using soundfile directly to write audio, or when you need more control than loading a whole recording into memory.

MoviePy is for automating video edits: cutting scenes, adding titles and subtitles, or composing many videos into one. A typical script loads videos as clips, modifies them, puts them together in a CompositeVideoClip, and writes the result with write_videofile().

PyAV binds FFmpeg's libraries for direct and precise access to your media's containers, streams, packets, codecs, and frames. Open a file with av.open() and loop over container.decode(video=0) to get frames, which convert to NumPy arrays with to_ndarray() and back with av.VideoFrame.from_ndarray().

Mutagen reads and writes tags in many audio formats through one API that's roughly the same across them. mutagen.File() guesses the file's type, you set tags like dict keys, and save() writes them. Mutagen is GPL.

tinytag, which is MIT and pure Python, only reads: TinyTag.get(path) returns the title, artist, album, duration, and more as attributes.

beets runs from the command line: it catalogs your music collection and improves its metadata from MusicBrainz as it goes. Point beet import at a folder of albums, and it tags the files as it adds them to your library. The docs recommend this autotagged import: it asks you questions along the way, but gets every song's tags right from the start.

MoviePy and PyAV both run on FFmpeg. When the ffmpeg command does the job on its own, call it directly: MoviePy's docs say that's faster and more memory-efficient.

Know a project that belongs here?

Tell us what it does and why it stands out.