You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MPEG-1 Video decoder, MP2 Audio decoder and MPEG-PS Demuxer in pure Go.
Why
This is a simple way to get video playback into your app or game.
MPEG-1 is an old and inefficient codec, but it is still good enough for many use cases. The quality and compression ratio still holds up surprisingly well.
Decoding costs very little CPU time compared to modern video formats. All patents related to MPEG-1 and MP2 have expired, so it is entirely free now.
Examples
frames - extracts all frames from a video and saves them as JPEG
video - video example using Ebitengine with accelerated YUV->RGB conversion
player-rl - player using raylib with YUV->RGB conversion done on CPU
player-sdl - player using SDL2 with accelerated YUV->RGB conversion
player-sdl3 - player using SDL3 with accelerated YUV->RGB conversion
-q:v sets a fixed video quality with a variable bitrate, where 0 is the highest.
You can use -b:v to set a fixed bitrate instead; e.g. -b:v 2000k for 2000 kbit/s.
Refer to the FFmpeg documentation for more details.
If you have FFmpeg compiled with libtwolame (an optimised MP2 encoder), you can use -c:a libtwolame -b:a 224k instead of -c:a mp2.
If you just want to test the library quickly, try this file:
https://gen2brain.github.io/mpeg/sintel.mpg
Example players are also able to handle HTTP streams so you can use the URL directly.