Skip to main content

Fast native H.264 QP and macroblock map extractor using FFmpeg

Project description

QPMBDeblock

Native H.264 QP and macroblock map extractor. Uses FFmpeg's AV_FRAME_DATA_VIDEO_ENC_PARAMS side-data to extract per-macroblock QP values from H.264 streams without log parsing.

Installation

pip install QPMBDeblock

Runtime requirement: FFmpeg must be installed and available in PATH.

Python API

from qpmbdeblock import h264QPparser

parser = h264QPparser("video.mkv")

# Extract + write in one step. Returns output path or None on failure.
result = parser.create_qp_map("output.qpmap.mkv")

# Or separately:
qpmap = parser.extract()           # numpy.ndarray (n_frames, mb_rows, mb_cols), dtype int8
parser.write_video(qpmap, "output.qpmap.mkv")

extract() returns a 3-D int8 NumPy array with QP values in [0, 63].

VapourSynth

from qpmbdeblock import VSqpmap_mask

# Generates output.qpmap.mkv on first call, loads it on subsequent calls.
qp = VSqpmap_mask(
    "video.mkv",
    reference_clip=src,   # required when scale_video=True (default)
    high_bitdepth=True,   # GRAY16, values 0–63
)

Source plugin priority: bestsource → ffms2 → lsmas

Parameter Default Description
qpmap_path <video>.qpmap.mkv Custom path for the QP map MKV
ffmpeg_path "ffmpeg" Path to ffmpeg executable
scale_video True Upscale 16× and crop to reference_clip dimensions
high_bitdepth True Output GRAY16 instead of GRAY8

Extracting Unfiltered Raw H.264 Video

You can also use this library to get a VapourSynth VideoNode of an H.264 stream with the in-loop deblocking filter disabled, essentially showing the raw block artifacts before any post-processing is applied by the codec itself. This relies on PyAV.

from qpmbdeblock.h264_indexer import h264_no_inloop_filter

# Returns a pure VS clip without the deblock filter.
# Since libavcodec is used frame extraction can be random-access frame accurate.
# During the first run, a '.idx' file will be built to ensure accurate seeking.
clip_nodeblock = h264_no_inloop_filter("video.mkv")

Build from source

Requirements: CMake ≥ 3.15, C++17 compiler, FFmpeg dev headers, pybind11.

# Set FFmpeg location (Windows only, if not using pkg-config)
$env:FFMPEG_ROOT = "C:\path\to\ffmpeg-full_build-shared"

pip install .

On Linux/macOS with system FFmpeg:

apt install libavcodec-dev libavformat-dev libavutil-dev  # Debian/Ubuntu
pip install .

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

qpmbdeblock-0.4.2-cp313-cp313-win_amd64.whl (87.9 kB view details)

Uploaded CPython 3.13Windows x86-64

qpmbdeblock-0.4.2-cp312-cp312-win_amd64.whl (87.8 kB view details)

Uploaded CPython 3.12Windows x86-64

File details

Details for the file qpmbdeblock-0.4.2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for qpmbdeblock-0.4.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0dd43ea40e5c6e6d495ccafac0c87fabd64d7f8533a11c449871c7c4d6efcf2e
MD5 5c8df5397d0f054d0d4d08da85c7929d
BLAKE2b-256 8a4045f5c63b5bc4bdf0be3813f3b104a025db684840e35219538b4c424e7905

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpmbdeblock-0.4.2-cp313-cp313-win_amd64.whl:

Publisher: build_wheels.yml on PingWer/QPMBDeblock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpmbdeblock-0.4.2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for qpmbdeblock-0.4.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a6cd27e4c090836eb0041cf6eefcebea77e46c83b6c4ed019c14ef1d3f8a08ef
MD5 9bdb04e2d99ab1ea2669778e45f82a0b
BLAKE2b-256 8f72856e4cf422d67feca6429fb3efd5f7df76b8ca90dfe97e907ac0ec6ebdbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpmbdeblock-0.4.2-cp312-cp312-win_amd64.whl:

Publisher: build_wheels.yml on PingWer/QPMBDeblock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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