npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pl_mpeg.c

v1.2025.3

Published

Single file C library for decoding MPEG1 Video and MP2 Audio; Dominic Szablewski (2019).

Readme

PL_MPEG - MPEG1 Video decoder, MP2 Audio decoder, MPEG-PS demuxer

Single-file MIT licensed library for C/C++, by Dominic Szablewski.

See pl_mpeg.h for the documentation.

Why?

This is meant as a simple way to get video playback into your app or game. Other solutions, such as ffmpeg require huge libraries and a lot of glue code.

MPEG1 is an old and inefficient codec, but it's still good enough for many use cases. All patents related to MPEG1 and MP2 have expired, so it's completely free now.

This library does not make use of any SIMD instructions, but because of the relative simplicity of the codec it still manages to decode 4k60fps video on a single CPU core (on my i7-6700k at least).

Installing

Run:

$ npm i pl_mpeg.c

And then include pl_mpeg.h as follows:

// main.c
#define PL_MPEG_IMPLEMENTATION
#include "node_modules/pl_mpeg.c/pl_mpeg.h"

int main() { /* ... */ }

And then compile with clang or gcc as usual.

$ clang main.c  # or, use gcc
$ gcc   main.c

You may also use a simpler approach:

// main.c
#define PL_MPEG_IMPLEMENTATION
#include <pl_mpeg.h>

int main() { /* ... */ }

If you add the path to node_modules/pl_mpeg.c to your compiler's include paths.

$ clang -I./node_modules/pl_mpeg.c main.c  # or, use gcc
$ gcc   -I./node_modules/pl_mpeg.c main.c

Encoding for PL_MPEG

Most MPEG-PS (.mpg) files containing MPEG1 Video ("mpeg1") and MPEG1 Audio Layer II ("mp2") streams should work with PL_MPEG. Note that .mpg files can also contain MPEG2 Video, which is not supported by this library.

You can encode video in a suitable format using ffmpeg:

ffmpeg -i input.mp4 -c:v mpeg1video -q:v 0 -c:a libtwolame -b:a 224k -format mpeg output.mpg

-q:v sets a fixed video quality with a variable bitrate, where 0 is the highest. You may use -b:v to set a fixed bitrate instead; e.g. -b:v 2000k for 2000 kbit/s. Please refer to the ffmpeg documentation for more details.

If you just want to quickly test the library, try this file:

https://phoboslab.org/files/bjork-all-is-full-of-love.mpg

Limitations

  • No error reporting. PL_MPEG will silently ignore any invalid data.
  • The PTS (presentation time stamp) for packets in the MPEG-PS container is ignored. This may cause sync issues with some files.
  • Bugs, probably.

ORG