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.3.0.tar.gz (65.1 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.3.0-cp313-cp313-win_amd64.whl (34.6 MB view details)

Uploaded CPython 3.13Windows x86-64

h5ffmpeg-2.3.0-cp313-cp313-manylinux_2_34_x86_64.whl (38.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

h5ffmpeg-2.3.0-cp312-cp312-manylinux_2_34_x86_64.whl (38.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

h5ffmpeg-2.3.0-cp311-cp311-manylinux_2_34_x86_64.whl (38.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

h5ffmpeg-2.3.0-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.3.0.tar.gz.

File metadata

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

File hashes

Hashes for h5ffmpeg-2.3.0.tar.gz
Algorithm Hash digest
SHA256 2f8a6be15ba18c924b3dcf5c34da90eb6892c1a85d40a2292a22c27b13a179d8
MD5 bf2a6419e17b083fd49cedd3867c2da0
BLAKE2b-256 c8b0f2c63ea2e860baeb9f92f9ca258dcef496721068871aeadb08f1492b6b8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: h5ffmpeg-2.3.0-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.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 778cae7854dfb639050a08738934b9bdb5bd7390a65d6d24ff63df678c9d5559
MD5 06632c2a7cece3678409e29d41995100
BLAKE2b-256 cefaf6704b59ad200b1283123768cda14bc2c32914c00404b3c01a3369b4c576

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.3.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 db025d9c0659831839e82f552899bbb17261d8c27bd0c51b7086482d5d0d2c87
MD5 924dc1bf9810f82637a75e154fe9e8f5
BLAKE2b-256 65a4e4764d968ef1d5ebaccc6649614514e4cee538c5a21b143e861d8761e54a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.3.0-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 2d185ed6fd4df9464285a6970305ba29dd74e4be1c32a966e2d1a89b1f6ddac2
MD5 ed7f1af2cf2eae0bbd1d1b3fb5a53d31
BLAKE2b-256 3a1a19860c07b95bd23842f524277af40fc64b74a656f443184e2780e1ce6077

See more details on using hashes here.

File details

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

File metadata

  • Download URL: h5ffmpeg-2.3.0-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.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 da1c855d4b82cd5c4d0a9f683947689e5bdcb34302e6fefed9f42a8bd7aa78ed
MD5 8726e0c007c18ca759ec84ae398c1dd5
BLAKE2b-256 e4eed4c0dfbb8ecaef4853aa754fc11d4865c171b683dc0feb2e641bd9d65181

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.3.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 179cf0025e28ce5f7e95a3b076733bc5f7144e2842d9cee6218cbafaa0621bdf
MD5 9c77a86004c4aef06277c1914e5bc21e
BLAKE2b-256 84601449f8eba3af8be94db49c3ec510a4d138a0c7a7f28a7e1d85c169426cd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.3.0-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 c9d042a46b4611c1337f17120f6612aa7d726ec6bc95e8012a68a36968d70850
MD5 11e49f3286905421a447253a71499789
BLAKE2b-256 f1333ec38ed270bf1b3d9c4b0ef3a37de3509d5b9ad85253a8134fa3be5ea370

See more details on using hashes here.

File details

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

File metadata

  • Download URL: h5ffmpeg-2.3.0-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.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c17104d9b2435d32b32b6f68b091273bfe91bd041025cd37cce7bf472e2a6969
MD5 7a4a77a5b589aeeff3335a2ffaea2924
BLAKE2b-256 a2d33e511d0c75937c359b3d988117e403f31d99077303ca5cb7ee254af96adf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.3.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ebdb264311b40ec3874ce24fb81a91f4759a2e4031fa6b36e33e4c67df2876ef
MD5 d7f8356013a574d81f2af0973535f35a
BLAKE2b-256 0a402203ac6c628e3a823706db90d04a6b4497fc0d97f094ec9ee2daaec31062

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for h5ffmpeg-2.3.0-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 686ee926bb9fb42c28e3b4b9dd10a418fff83c7a1f192d605b53e01aad0c0f56
MD5 2960aa8f80144a27b3093c609a9bc059
BLAKE2b-256 21c9dd7c86c96ffeeea3fdb90b4adbe9c061711c2ac2fe364ffa867ebafa9cea

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