Open-source project
pion/mediadevices avatar
pion/mediadevices

Pion mediadevices ships one audio codec, no Windows codec instructions, and a 2020 benchmark

Go implementation of the MediaDevices API.

650 stars149 forksGoMIT

At a glance

What is it?
A Go implementation of the browser MediaDevices API for cameras, microphones and screen capture, with encoding delegated to system libraries through cgo. The feature table is complete; the install table underneath it is not.
Who is it for?
Pion mediadevices is the right shape for a Go service that needs a camera or a screen and wants a browser-shaped API, and the deliberate choice to register nothing until you import a driver is the kind of decision that keeps a dependency tree honest. Before you rely on the performance claim, ignore it: the single figure in the readme is from 2020 on a different Go version.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 13 days ago.
What is it written in?
Mainly Go, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • pion/mediadevices650 ★ · +2
Star history
Repository2026-09-112026-11-15
pion/mediadevices648650

2 Stars in the last 65 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The only performance number is from 2020, on Go 1.14

There is one benchmark in the readme and it carries its own date.

The result is stated as of November 4, 2020, measured with Go 1.14 on a Raspberry Pi 3, producing video, encoding it, sending it across a network and decoding it at 720p and 30 frames per second with latency under 500 milliseconds.

The module now declares a Go floor of 1.24.0. That is not one minor version behind the benchmark; it is a different toolchain generation, fourteen releases along from the one the number was produced with, on hardware a decade old at the time.

So the figure is a historical data point rather than a current claim, and the readme does not present it as anything else: the date, the language version and the board are all stated in the same sentence. That is more honest than most projects manage, and it is still a number a reader will quote.

The release history has the same shape of drift. Two patch releases one day apart in February 2026, then a minor version in April, and the default branch was pushed on 2026-10-01 with nothing published in the five and a half months since.

Around 648 stars, 150 forks and 74 open issues is a project with a substantial user base and a busy tracker.

Windows gets three input rows and no codec install instructions

The media input table is complete and symmetrical. Camera, microphone and screen capture, each marked supported on Linux, Mac and Windows. Nine ticks.

The codec installation instructions underneath are not symmetrical at all. Video codecs list Mac and Ubuntu. The audio codec lists Mac and Ubuntu. One of them, the hardware acceleration API, lists Ubuntu only, which makes sense since that path is Linux-specific.

No codec in the list has a Windows installation line. Not one. So the input table promises you can open a camera, a microphone and a screen on Windows, while the section explaining how to get an encoder there says nothing.

Whether that is an omission or a deliberate refusal to claim Windows encoding is not stated. What is stated is the platform matrix in the build system, and it lists Windows on x64 only, with no Windows ARM entries at all. The operating system list and the architecture list multiply out to nine cells; six platform identifiers are declared, the two excluded ones being Windows on ARM.

So the input table is broader than the build matrix in one direction and narrower in another, and a reader planning a Windows deployment has to work that out from a Makefile.

One audio codec, and two video codecs that need nothing installed

There are seven codec packages. Six are video and exactly one is audio.

The audio one is Opus, described as a totally open, royalty-free, highly versatile audio codec, installed with a package manager command on Mac or Ubuntu. There is no MP3 encoder, no AAC, no Vorbis, no raw PCM path listed.

If your pipeline needs anything but Opus, this library is not the place to get it, and the readme does not discuss a fallback.

On the video side the install requirements vary more interestingly. Two of the six need nothing: the hardware encoder for Raspberry Pi boards with VideoCore GPUs is described as coming built into the devices, and the Cisco-branded encoder is described as included as a static binary.

The remaining four need a system library. Two are installed with a package manager on Mac or Ubuntu. The hardware acceleration API is Ubuntu only.

So of seven codecs, two are zero-install, four need a package manager on two platforms, and one needs a package manager on one.

The project explicitly declines to rank them, saying it does not provide recommendations on choosing one codec over another because it is very complex and can be subjective. Given that the codecs differ this much in how they are obtained, that abstention costs the reader more than it saves.

Codecs come from the system through cgo, which is what the build tag is for

The central architectural fact is stated plainly: the library does not implement the video and audio codecs. It calls the codec libraries from the system through cgo, and you are required to install those libraries before you can use the encoders.

So the abstraction hides the hardware and the encoder, and leaves the operating system package manager in the path.

That has one direct consequence for the module declaration, which requires a Go version of 1.24.0 and a direct dependency on a C-backed miniaudio binding. A pure-Go build is not possible for anything that encodes.

The escape hatch is a build tag. `nomicrophone` builds without microphone support, and the readme gives two reasons it exists: cross-compilation where C-backed dependencies like the miniaudio binding are unavailable, and projects where audio is not simply required.

Installation itself is one line:

bash
go get -u github.com/pion/mediadevices

The readme is honest that this is a library rather than a program, so there is nothing to run after installing it. What you get is a package that compiles when your system has the encoder libraries your imported codec packages expect, and fails with a link error when it does not.

Nothing is registered until you blank-import the driver you want

The design decision that shapes every first attempt is stated as a choice: by default there is no media input registered, and the reason given is so you play only what you need.

The consequence is that a program which imports the library and calls the user-media entry point gets nothing back unless it also blank-imports the package that registers a device. The readme is explicit that the camera import is required to register the camera adapter.

There is an escape from that too. If you have no camera, or your adapters are not supported on your machine, you can swap them for the dummy adapters instead, which the example shows as a commented alternative import.

The same pattern applies to codecs, where you import the codec package and add its parameters to a codec selector that you then pass to the user-media call.

So there are three separate registration steps a new user has to discover: a driver, a codec, and the selector that joins them. Each is documented with a code sample, and each is a place where a first run produces an empty result rather than an error.

Five examples are listed and nine exist

The examples section names five, each with a one-line description.

A peer-to-peer video call built on WebRTC. Face detection in a camera stream using a machine learning algorithm. Capture, encode in H264, VP8 or VP9, and send to an RTP server. Broadcast through HTTP with MJPEG. And archive an H264 encoded stream.

The examples directory holds nine subdirectories. Four of them are not in that list: a device observer for macOS, an internal directory, a directory named for the bundled encoder, and a VNC example.

The macOS device observer and the VNC example are the two a reader would most want listed, since both demonstrate something the input table promises and neither is described anywhere in the readme.

The examples are also a separate Go module, with their own manifest and checksum file inside the directory. That is a deliberate boundary: the module you install with `go get` does not pull in the dependencies of nine sample programs, and the five documented examples therefore install faster than they look like they should.

The testing layout follows the same flatness. Four test files sit at the repository root next to the source they test, including one benchmark file.

Codec builds run container images from a personal Docker account

The build system for the codec dependencies is the most unusual part of the repository.

The Makefile declares a Docker image owner that is a personal account rather than the project organisation, and a prefix that describes what the images are. The toolchain directory is a subdirectory of the scripts directory, and each platform gets its own image pulled on demand by a target named for the operating system and architecture.

The supported platform list has six entries, and the codec list is not written down anywhere in the file. It is discovered at parse time by listing the codec directory for subdirectories that contain a Makefile. From those two lists the file generates one build target per codec per platform, which with seven codecs and six platforms is up to forty-two combinations.

The per-codec build is delegated to each codec's own Makefile, with the target platform, operating system and architecture and the toolchain binary path passed in as variables.

The default target runs the tests and then the builds. Two package lists are computed for it, and they are worth reading: one excludes the packages needing an external device or a GPU, and one excludes everything under the codec directory, the driver directory and the AVFoundation bindings. That second list is the set of packages that build without cgo, and it is how the pure-Go surface is identified.

There is also a formatting configuration for C in a Go repository, which is what you would expect from cgo bindings.

Fourteen Go files at the root, and the WebRTC stack as a hard dependency

The repository root is where the package lives, not a subdirectory. Fourteen Go source files sit at the top level, named for what they provide: the codec selector, the driver registry, an IO reader, logging, device information, the media stream, its constraints, metadata, an RTP reader, a sampler, a source and a track. Five test files sit beside them.

The dependency list explains the weight. Eleven are direct, and four of them are the pion media transport stack: the WebRTC library at major version four, RTP, RTCP and the interceptor package.

A library whose stated job is opening a camera therefore hard-depends on a WebRTC implementation. You do not get WebRTC by importing this, and there is no optional flag, but you do get it in your build graph.

The remaining direct dependencies are one per platform concern: a webcam library for Linux video capture, the miniaudio binding for microphones, a screenshot library pinned to a pseudo-version for screen capture, a UUID package, an image processing package, and a testing assertion library sitting in the same require block as the runtime ones.

The twenty-one indirect dependencies read like a platform matrix. A D-Bus binding for Linux, an X11 binding for screen capture under X, a Windows API binding, a shared memory package, and a network interface enumerator used by peer discovery.

Four of those are the reason the input table's three ticks per platform are credible rather than aspirational.

Editorial conclusion

Pion mediadevices is the right shape for a Go service that needs a camera or a screen and wants a browser-shaped API, and the deliberate choice to register nothing until you import a driver is the kind of decision that keeps a dependency tree honest. Before you rely on the performance claim, ignore it: the single figure in the readme is from 2020 on a different Go version. Plan instead for system codec libraries on every platform you deploy to, since Windows is listed as supported for input while no codec in the list carries a Windows install line, and keep the nomicrophone build tag in mind for anything you cross-compile.

Frequently asked questions

What is getUserMedia?

It is the browser entry point this library reimplements in Go, under the name GetUserMedia. You pass it media stream constraints, including a callback that fills in per-track constraints, and it returns a stream you read frames from and encode.

what is mediadevices api

A Go implementation of the browser MediaDevices API for cameras, microphones and screen capture, plus an encoder selector. Nothing is registered by default, so you blank-import the driver package for the input you want, which is why a bare import returns no devices.

what is navigator mediadevices

In a browser, navigator.mediaDevices is the object exposing getUserMedia and display capture. This repository implements that API shape for Go rather than for a browser, which is why the entry points are named the same and the import path is a Go module.

what is mediadevices getusermedia

It is the Go entry point, spelled GetUserMedia. You pass it media stream constraints with a callback that fills in per-track constraints, and it returns a media stream you read frames from, hand to a codec selector and read back encoded output from.

What are media devices?

In this library, cameras, microphones and screen capture, all three of which it reports as supported on Linux, Mac and Windows. None of them is registered until you blank-import the matching driver package, and encoding is delegated to system libraries through cgo rather than implemented here.

Official sources

  1. License: MIT
  2. pion/mediadevices on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/pion-mediadevices.svg)](https://hysenlabs.com/projects/pion-mediadevices)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/pion-mediadevices.svg)](https://hysenlabs.com/projects/pion-mediadevices)

Was this useful?