Skip to main content

HDF5 filter plugin for FFMPEG video codec compression

Project description

FFMPEG HDF5 Filter Enables High-Ratio Image Compression for Faithful Scientific Analysis

The FFMPEG HDF5 filter enables high-ratio compression of scientific datasets in HDF5 files using video codec technology. It supports a wide range of codecs (H.264, H.265/HEVC, AV1, etc.) with hardware acceleration options for NVIDIA GPUs and Intel QuickSync.

Features

  • High Compression Ratios: Achieve 10-10,000× compression while preserving analysis fidelity
  • Multiple Codec Support: H.264, H.265/HEVC, AV1, and more
  • Hardware Acceleration: NVIDIA GPU and Intel QuickSync support
  • Simple Python API: Easy-to-use interface for H5Py
  • Automated Optimization: Film grain synthesis and artifact minimization
  • Cross-Platform: Works on Linux, macOS, and Windows
  • ImageJ/Fiji Plugin Support: Direct visualization and analysis in popular scientific imaging tools

Installation

Via pip (recommended)

pip install h5ffmpeg

Using pre-built binaries for ImageJ/Fiji

We recommend using our imageJ update sites.

Note: Due to the limitation of static built ffmpeg to comply with Java, some codecs are not supported. We strongly recommend using our python package. If working with large-scale dataset, SISF_CDN with neuroglancer is recommended.

From source (not recommended)

git clone https://github.com/Cai-Lab-at-University-of-Michigan/ffmpeg_HDF5_filter.git
cd ffmpeg_HDF5_filter
pip install -e .

This is not recommended since it requires compiling FFmpeg from source with HDF5 support, which is complex and error-prone. Our pip package includes pre-built, tested binaries.

Quick Start

import h5py
import numpy as np
import h5ffmpeg as hf

# Create sample data
data = np.random.rand(100, 512, 512).astype(np.uint8)

# Save with default settings (H.264)
with h5py.File("compressed.h5", "w") as f:
    f.create_dataset("data", data=data, **hf.x264())

# Save with H.265/HEVC compression
with h5py.File("compressed_hevc.h5", "w") as f:
    f.create_dataset("data", data=data, **hf.x265(crf=28))

# Save with AV1 compression (highest ratio)
with h5py.File("compressed_av1.h5", "w") as f:
    f.create_dataset("data", data=data, **hf.svtav1(crf=30))

# Use with NVIDIA GPU acceleration
with h5py.File("compressed_gpu.h5", "w") as f:
    f.create_dataset("data", data=data, **hf.h264_nvenc())

Advanced Usage

Custom Codec Configuration

import h5ffmpeg as hf

# Access the full ffmpeg API for complete control
compression_options = hf.ffmpeg(
    codec="libx264",        # Codec to use
    preset="medium",        # Encoding speed vs compression efficiency
    tune="film",            # Content-specific optimization
    crf=23,                 # Quality level (lower = higher quality)
    bit_mode=hf.BitMode.BIT_10,  # 8, 10, or 12-bit encoding
    film_grain=50,          # Film grain synthesis (0-50)
    gpu_id=0                # GPU ID (Default: 0)
)

Automated Hardware Acceleration

The library can detect and use available hardware acceleration:

import h5ffmpeg as hf

# This will automatically use NVIDIA GPU if available, 
# or fall back to CPU if not
compression_options = hf.ffmpeg(
    codec="h264_nvenc" if hf.has_nvidia_gpu() else "libx264",
    preset="p4" if hf.has_nvidia_gpu() else "medium",
    crf=23
)

Available Codecs

Codec Implementation Description Typical Use Case
XVID libxvid MPEG-4 codec Legacy support
H.264 libx264 General-purpose codec Good balance of quality and speed
H.265/HEVC libx265 Higher efficiency than H.264 Better compression for same quality
AV1 libsvtav1 Next-gen open codec Highest compression ratio
AV1 librav1e Rust AV1 encoder Alternative AV1 implementation
H.264 NVENC h264_nvenc NVIDIA GPU-accelerated H.264 Fast encoding on NVIDIA GPUs
HEVC NVENC hevc_nvenc NVIDIA GPU-accelerated HEVC High-quality, fast encoding on NVIDIA GPUs
AV1 NVENC av1_nvenc NVIDIA GPU-accelerated AV1 Next-gen encoding on newest NVIDIA GPUs
AV1 QSV av1_qsv Intel QuickSync AV1 Hardware acceleration on Intel GPUs

Compatibility

  • Python: 3.11+
  • Operating Systems: Linux-x86_64, macOS Apple Silicon, and Windows-AMD64
  • hdf5: 1.14+
  • h5py: 3.8+

License

MIT License

Citation

If you use this software in your research, please cite:

Duan, B., Walker, L.A., Xie, B., Lee, W.J., Lin, A., Yan, Y., and Cai, D. (2024).
Artifact-Minimized High-Ratio Image Compression with Preserved Analysis Fidelity.

Acknowledgments

This work was funded by the United States National Institutes of Health (NIH) grants RF1MH123402, RF1MH124611, and RF1MH133764.

Community and Support

  • GitHub Issues: For bug reports and feature requests
  • Contact: Feel free to reach out to us with questions

Related Projects

Feel free to check out other tools from the Cai Lab:)

  • nGauge: Python library for neuron morphology analysis
  • nTracer2: Browser-based tool for neuron tracing
  • pySISF: Python wrapper for SISF format
  • SISF_CDN:Scalable Image Storage Format CDN

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

h5ffmpeg-2.2.8.tar.gz (65.0 kB view details)

Uploaded Source

Built Distributions

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

h5ffmpeg-2.2.8-cp313-cp313-win_amd64.whl (34.6 MB view details)

Uploaded CPython 3.13Windows x86-64

h5ffmpeg-2.2.8-cp313-cp313-manylinux_2_34_x86_64.whl (38.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

h5ffmpeg-2.2.8-cp313-cp313-macosx_12_0_arm64.whl (24.9 MB view details)

Uploaded CPython 3.13macOS 12.0+ ARM64

h5ffmpeg-2.2.8-cp312-cp312-win_amd64.whl (34.6 MB view details)

Uploaded CPython 3.12Windows x86-64

h5ffmpeg-2.2.8-cp312-cp312-manylinux_2_34_x86_64.whl (38.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

h5ffmpeg-2.2.8-cp312-cp312-macosx_12_0_arm64.whl (24.9 MB view details)

Uploaded CPython 3.12macOS 12.0+ ARM64

h5ffmpeg-2.2.8-cp311-cp311-win_amd64.whl (34.6 MB view details)

Uploaded CPython 3.11Windows x86-64

h5ffmpeg-2.2.8-cp311-cp311-manylinux_2_34_x86_64.whl (38.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

h5ffmpeg-2.2.8-cp311-cp311-macosx_12_0_arm64.whl (24.9 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

File details

Details for the file h5ffmpeg-2.2.8.tar.gz.

File metadata

  • Download URL: h5ffmpeg-2.2.8.tar.gz
  • Upload date:
  • Size: 65.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for h5ffmpeg-2.2.8.tar.gz
Algorithm Hash digest
SHA256 81f9ceae62e613a97b7b15743a2d19c1ac0235d7806b0df022c9c8bdd55d3931
MD5 1052f01a0784c9e99261c26afd7de96f
BLAKE2b-256 59693518da19c4021f30207f9558883a63d55224d32c5fd6a286565fb2a76053

See more details on using hashes here.

File details

Details for the file h5ffmpeg-2.2.8-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: h5ffmpeg-2.2.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 34.6 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for h5ffmpeg-2.2.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 74c0cb65f8d8c96b83488534dfcf4d6236b58dbbc437a5b272e3a775cc1c5560
MD5 3d1df7a1b7d7c9b8ee44b133ec4fd973
BLAKE2b-256 3d62bf633148fc4aff638b8a7b2930f7e01497c6a1c7262e283877de57371ec2

See more details on using hashes here.

File details

Details for the file h5ffmpeg-2.2.8-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for h5ffmpeg-2.2.8-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 fe69d0f099ea4c003de0cc30daf359d1f4a0206b58fecdcf8bdc9d0a18cb8262
MD5 1d9ae377737b40191c5e0ddda4f796b9
BLAKE2b-256 835409c86c587ed63a9dc5c6bdb97d2affcd8e470c37345167eb3b1515c51e79

See more details on using hashes here.

File details

Details for the file h5ffmpeg-2.2.8-cp313-cp313-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for h5ffmpeg-2.2.8-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 cef3cf3d0af7686332142ebaac443cc5d4aa83365c6bfc33b94feeebb52e4db7
MD5 15b28e2769448188b290f2e441baa9cb
BLAKE2b-256 12bce08722accea6f991d1f233ce7858d31caab5d2b6d2be45b3ad19de0c0870

See more details on using hashes here.

File details

Details for the file h5ffmpeg-2.2.8-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: h5ffmpeg-2.2.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 34.6 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for h5ffmpeg-2.2.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 606b417ecdfc93cc54c5715d0f6aff15c015552395b17d3df63af8ada539a020
MD5 53e8c2ae1d5fe2395fcc4e885a169d54
BLAKE2b-256 4c91f2d9250dfa9b658415209a47fe2e7fb1c5fa4e34feab2a4f94d4e89383e4

See more details on using hashes here.

File details

Details for the file h5ffmpeg-2.2.8-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for h5ffmpeg-2.2.8-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e726a1c519ae4986bfda89554e0f943d8260c42ef907d559775d3081fb1fa078
MD5 f70df2043fed8c48f27f20a7b04f24e9
BLAKE2b-256 feb4d311d95d78bdffab08bfee285ff818e0ca9caec7cff90399c8abffa76d54

See more details on using hashes here.

File details

Details for the file h5ffmpeg-2.2.8-cp312-cp312-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for h5ffmpeg-2.2.8-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 82f46dc3db451dbcd88653a1caeb0f6418eea5338c02dbcd0bd427c1d0cc6c47
MD5 0dd957aec7fd381d9cc2f49062f42ac6
BLAKE2b-256 51e7599ccc196f70fa0550894f2b364200aa082b6dcaceb5369700de941eda0f

See more details on using hashes here.

File details

Details for the file h5ffmpeg-2.2.8-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: h5ffmpeg-2.2.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 34.6 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for h5ffmpeg-2.2.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b7b9227c02eb4b209a7968772133cecee1d63331d9d4856d62561ec72aeed872
MD5 4118aaa181aa9b6606b9522dc0fb3368
BLAKE2b-256 87f3ff72fef147dde9bfab3b6ae44692597a4d2f25790b6501a40101a1a7b786

See more details on using hashes here.

File details

Details for the file h5ffmpeg-2.2.8-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for h5ffmpeg-2.2.8-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e32acdb5c40afff6fabb12d28864c533f9996993d1eb81172e93de1623d43f13
MD5 02443a742b36396eae8ce2b3921cf598
BLAKE2b-256 aed09074fb65118542898ad498bcadbad044b7b11f132b985e017fa6c03cad39

See more details on using hashes here.

File details

Details for the file h5ffmpeg-2.2.8-cp311-cp311-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for h5ffmpeg-2.2.8-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 275a91bb30511786ce247e77d33c2fa30133a03273775618bfb361cb417851b8
MD5 7b9d2b16747c0b3409c0fe5c372b1e5b
BLAKE2b-256 861a34b4b81854a710c3364aa5834e59e92fd4b955a4f22eeca55e1b5d5c4967

See more details on using hashes here.

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