Git Product home page Git Product logo

mpeg's Introduction

mpeg

Package mpeg provides an implementation of an experimental pure golang implementation of an MPEG-2 decoder. It is intended as an educational look at some of the patterns and algorithms involved in the ubiquitous technology of video compression/decompression.

This package is experimental and is not intended for use in production environments.

GoDoc

Composition

This library is split into four sub-packages:

  • mpeg/ts for parsing and processing MPEG-2 Transport Streams
  • mpeg/ps for parsing and processing MPEG-2 Program Streams
  • mpeg/pes for parsing and processing MPEG-2 Packetized Elementary Streams
  • mpeg/video for decoding MPEG-2 Video

Examples

Give it a spin!

go get -d github.com/32bitkid/mpeg

Decode a frame of video from a MPEG-2 TS and save it as a png

package main

import "os"
import "image/png"

import "github.com/32bitkid/mpeg/ts"
import "github.com/32bitkid/mpeg/pes"
import "github.com/32bitkid/mpeg/video"

func main() {
  // Open the file
  tsReader, err := os.Open("source.ts")

  // Decode PID 0x21 from the TS stream
  pesReader := ts.NewPayloadUnitReader(tsReader, ts.IsPID(0x21))

  // Decode the PES stream
  esReader := pes.NewPayloadReader(pesReader)

  // Decode the ES into a stream of frames
  v := video.NewVideoSequence(esReader)

  // Align to next sequence start/entry point
  v.AlignTo(video.SequenceHeaderStartCode)

  // get the next frame
  frame, _ = v.Next()
  file, _ := os.Create("output.png")
  png.Encode(file, frame)
}

mpeg's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.