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.6.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.6-cp313-cp313-win_amd64.whl (34.6 MB view details)

Uploaded CPython 3.13Windows x86-64

h5ffmpeg-2.2.6-cp313-cp313-manylinux_2_34_x86_64.whl (36.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

h5ffmpeg-2.2.6-cp313-cp313-macosx_12_0_arm64.whl (24.8 MB view details)

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

h5ffmpeg-2.2.6-cp312-cp312-manylinux_2_34_x86_64.whl (36.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

h5ffmpeg-2.2.6-cp312-cp312-macosx_12_0_arm64.whl (24.8 MB view details)

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

h5ffmpeg-2.2.6-cp311-cp311-manylinux_2_34_x86_64.whl (36.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

h5ffmpeg-2.2.6-cp311-cp311-macosx_12_0_arm64.whl (24.8 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

File details

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

File metadata

  • Download URL: h5ffmpeg-2.2.6.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.6.tar.gz
Algorithm Hash digest
SHA256 a2ab01ff9b60b706f9046ee05d782c5c53c29ede071676a0db9520f4e04b6bcc
MD5 42837ad29721933e29199388d662eed8
BLAKE2b-256 a952eb2366201a1a4ee56073a8b480f8f1734052f2dc04934f2685534900dc4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: h5ffmpeg-2.2.6-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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 08cf6b23de54fce797ad80b7785a921f7412aaf3f2593f7a94ccbce4dc5221b0
MD5 9cc1190fceba8fdafd2018a86fe4cd95
BLAKE2b-256 d0015055154f819788e996fc00d604bfa3452997d8543fb88dbecc3655a3466f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.2.6-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f25971e12930f35870d5ab7efd46554707b958b80bd71c6a88c4886a736d9a01
MD5 9345c8bdfb9aa5a7b78d15258b33ec15
BLAKE2b-256 48938ffb61bb815592da5b658782e190ff4fbbd1957ee3f1ab3b7c738059ce51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.2.6-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 42a3a648a38825838eb20d81156e919c13c9a898a3e912c6811c9e120be3eb9b
MD5 5fed19ff64544ab0d2378f8c6ff125a0
BLAKE2b-256 c264d4489edb1966390457af342259e552ce28e2f0f2e433e500870b5d7d75d7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: h5ffmpeg-2.2.6-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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ca172e6910024f453accd463768ae070a9686b6daa7b6794a246809b7b6fb21c
MD5 93c2f2421b0d63a2f390af453a2f1c75
BLAKE2b-256 fd4984c994a0842b57530d7c0d547c2f8692c740072f1ad98020b344a5f3a5ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.2.6-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5b77b02aafb44564c1f36add374f4e1e34e11394574a1952fa9cb0bf7842b959
MD5 2d9ae1ce1db31fd7b368204bac5081e4
BLAKE2b-256 60804617142fa7e568018661ea6d6a624b86c439d350dbaa23b2b51469dde8f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.2.6-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 7a950beb58ded74ecb5fce60fa247dd8089592f2f8406238651a6bfbb115ff27
MD5 303aa5378ddf4f149618848560c10211
BLAKE2b-256 4849e3e647eccfbda707cc6d9662b57519677991c88c304a7f22582fdf1210e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: h5ffmpeg-2.2.6-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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8304c54e3f535f27b27171fa49a7c8a254838531be0ca8ceaa61da1fee9ab5fe
MD5 3d9e917445192d9dec0494502dc3ee0d
BLAKE2b-256 49a81e1f3b6b854a6d085d5ed844f4ae2ead3763db2e69ab48965130cad63128

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.2.6-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 990dc725df120a646a50f2bfb3340ab57375f27dce9ca899e7c16f82996806f1
MD5 1fef2913eef7313bc39fc01124b554cd
BLAKE2b-256 f5a4df7c2a7a61a1b936cb36abe90a4ff5581b362e6a9cb0d21dba82f50072ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.2.6-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 b7ad017ec99703135d6e3bce04368b1ad23c9f704e1b76ed40f947df4c706193
MD5 16588934fb9b0e542f4f478526593f63
BLAKE2b-256 1ec816e672217093dd185dc8731884496e78554967865670bebe5f3077a17e8b

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