Skip to main content

Streamlined MPEG-1 and MPEG-2 source loader and helper utility for VapourSynth

Project description

MPGG
Streamlined MPEG-1 and MPEG-2 source loader and helper utility for VapourSynth

Build status Python version VapourSynth version DeepSource

Features

  • 🎥 Supports MPEG-1 and MPEG-2 Sources
  • 🧠 Understands Mixed-scan Sources
  • 🤖 VFR to CFR (Variable to Constant frame rate)
  • 🛠️ Automatic Frame-indexing using DGIndex
  • ⚙️ Zero-configuration
  • 🧩 Easy installation via PIP/PyPI
  • ❤️ Fully Open-Source! Pull Requests Welcome

Installation

$ pip install mpgg

Voilà 🎉! You now have the mpgg package installed, and you can now import it from a VapourSynth script.

Dependencies

The following is a list of software that needs to be installed manually. MPGG cannot install these automatically on your behalf.

Software

  • MKVToolnix (specifically mkvextract) for demuxing MPEG streams from MKV containers.
  • DGIndex for automatic frame-indexing of MPEG streams.

Make sure you put them in your current working directory, in the installation directory, or put the directory path in your PATH environment variable. If you do not do this then their binaries will not be able to be found.

VapourSynth Plugins

  • d2vsource for loading an indexed DGIndex project file.

These plugins may be installed using vsrepo on Windows, or from a package repository on Linux.

Usage

The following is an example of using MPGG to get a clean CFR Fully Progressive stream from an Animated Mixed-scan VFR DVD-Video source.

import functools

from mpgg import MPGG
from havsfunc import QTGMC

# load the source with verbose information printed
mpg = MPGG(r"C:\Users\John\Videos\animated_dvd_video.mkv", verbose=True)

# recover progressive frames where possible, and show which frames were recovered
mpg.recover(verbose=True)

# deinterlace any remaining interlaced frames with QTGMC, and show which frames were deinterlaced
mpg.deinterlace(
  kernel=functools.partial(QTGMC, Preset="Very Slow", FPSDivisor=2),
  verbose=True
)

# convert VFR to CFR by duplicating frames in a pattern
mpg.ceil()

# get the final clip (you may use the clip in between actions as well)
clip = mpg.clip

# ...

clip.set_output()

You can also chain calls! This is the same script but chained,

import functools

from mpgg import MPGG
from havsfunc import QTGMC

# load MPEG, recover progressive frames, deinterlace what's left, and finally VFR to CFR
clip = MPGG(r"C:\Users\John\Videos\animated_dvd_video.mkv", verbose=True).\
  recover(verbose=True).\
  deinterlace(kernel=functools.partial(QTGMC, Preset="Very Slow", FPSDivisor=2), verbose=True).\
  ceil().\
  clip

# ...

clip.set_output()

There are more methods not shown here. I recommend taking a look at the MPGG class for further information, methods, and more.

Warning Do not copy/paste and re-use these examples. Read each method's doc-string information as they each have their own warnings, tips, and flaws that you need to be aware of. For example, recover() shouldn't be used on all MPEG sources, floor() shouldn't be used with recover(), you may not want to use ceil() if you want to keep encoding as VFR, and such.

Terminology

Term Meaning
CFR Constant frame-rate, the source uses a set frame rate on playback
VFR Variable frame-rate, the source switches frame rate at least once on playback
Scan The technology used to show images on screens, i.e., Interlaced or Progressive
Mixed-scan Source with both Progressive and Interlaced frames within the video data
Frame-indexing Analyzing a source to index frame/field information for frame-serving

Contributors

License

© 2021-2023 rlaphoenix — GNU General Public License, Version 3.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpgg-1.0.0.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

mpgg-1.0.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file mpgg-1.0.0.tar.gz.

File metadata

  • Download URL: mpgg-1.0.0.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.10 Linux/5.15.0-1034-azure

File hashes

Hashes for mpgg-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5f008c5a701b94e3ef9b4adadb7d42da80e6dd42cbe38f5eefae98d5016e20c2
MD5 20e30ef902b719d0da5a279248760890
BLAKE2b-256 da3fd9ee547e775bfdca21730ade21bf2212d150445ff9277151fe3dcd178602

See more details on using hashes here.

File details

Details for the file mpgg-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mpgg-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.10 Linux/5.15.0-1034-azure

File hashes

Hashes for mpgg-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1adcc8e24eabd09868eb63baa3d88ec21090f2f385ae979cf30348eb2451fc33
MD5 9be5d4b2e220dab79c3ef54a219fff04
BLAKE2b-256 7abf8a56c63d00ee5d9092d74aa4b98e892c0e9a692fc266754d15a6c0cfc38a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page