Skip to content

Single file C library for decoding MPEG1 Video and MP2 Audio

Notifications You must be signed in to change notification settings

nicolas42/pl_mpeg

This branch is 3 commits ahead of, 66 commits behind phoboslab/pl_mpeg:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

78317ab · May 3, 2020

History

11 Commits
May 3, 2020
Apr 17, 2020
May 3, 2020
Apr 17, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
May 3, 2020
Aug 21, 2019
May 3, 2020
Jun 11, 2019
Apr 17, 2020
May 3, 2020

Repository files navigation

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

Single-file MIT licensed library for C/C++

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).

Example Usage

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 mp2 -format mpeg output.mpg

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.
  • no seeking.
  • bugs, probably.

About

Single file C library for decoding MPEG1 Video and MP2 Audio

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 60.3%
  • Objective-C 39.6%
  • Other 0.1%