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. We support Windows, Ubuntu, MacOS (ARM64).
MacOS users: Run setup_macos_fiji.sh to prevent crashes during compression/decompression.
SetUpH5FFMPEG.ijm: This macro runs automatically. After system restarts, open Fiji twice to configure HDF5_PLUGIN_PATH properly.
Ubuntu users: After the first time opening Fiji, You may need to Logout and LogIn for Fiji picking up the HDF5_PLUGIN_PATH enviroment variable.
Note: Due to the limitation of 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:)
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file h5ffmpeg-2.3.2.tar.gz.
File metadata
- Download URL: h5ffmpeg-2.3.2.tar.gz
- Upload date:
- Size: 67.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a541835bba6172b40af9471d886b02ac4db76d7ee38ac078415b0988d500ee1
|
|
| MD5 |
e862b64be981b1bbca3b017b7bc0bb8c
|
|
| BLAKE2b-256 |
e4574fd5ba750e1cb322ea6554bacdba5d8faadcc1711778345853daf7dca835
|
File details
Details for the file h5ffmpeg-2.3.2-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-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.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25127f7c46ba95ea82f431ef69694f6c329bd9e2dac6457b72831c71be6b7a9e
|
|
| MD5 |
9d37cd36c32c6e9b2007b595c77cf2b4
|
|
| BLAKE2b-256 |
0f9baa1ba64b6a36bc2affdc9773aae40ae94527be6fc1679886d132d1b28f87
|
File details
Details for the file h5ffmpeg-2.3.2-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 38.8 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e98a5bd62334132ec8cf91f4fef407af512302afa92b3021cf67f531401848b2
|
|
| MD5 |
25242ec29a669a2d6777841ad899e17b
|
|
| BLAKE2b-256 |
55cda25691458957ccc023c6228e53284c24c07a712a10b60823b111208ecd2f
|
File details
Details for the file h5ffmpeg-2.3.2-cp313-cp313-macosx_12_0_arm64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-cp313-cp313-macosx_12_0_arm64.whl
- Upload date:
- Size: 25.1 MB
- Tags: CPython 3.13, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2436cf864a386397852b8ae5e5f9f7856dbf76e6236a469504d0691361160ad5
|
|
| MD5 |
77414b518fdea059e8629f2563424200
|
|
| BLAKE2b-256 |
8c144539632aeea4c92480a9979d80e2a206fa736d0ef4bd8132983a43b6188f
|
File details
Details for the file h5ffmpeg-2.3.2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-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.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83bbb73ad8ac5397d183734ecc07464c41cc5350127d6810dafb722656f49e6b
|
|
| MD5 |
0a744b753431019a34b529a801fa399d
|
|
| BLAKE2b-256 |
033e494e5e1fa269814a9c476aa6de3879c26ae3e5b91cfc81fd3a3c6a2767f6
|
File details
Details for the file h5ffmpeg-2.3.2-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 38.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae046d6b65c43f9252d600b4f2d81c0a6dbc5a2a91ef5013c02e2909437fef16
|
|
| MD5 |
b6e370d48ba0f45065ae39895668ea24
|
|
| BLAKE2b-256 |
c7f7d0136c0864f230c2eaddb38393211741ef38f5159e2f185fb80e0572da5b
|
File details
Details for the file h5ffmpeg-2.3.2-cp312-cp312-macosx_12_0_arm64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-cp312-cp312-macosx_12_0_arm64.whl
- Upload date:
- Size: 25.1 MB
- Tags: CPython 3.12, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bba9f9d6c9b8429f5aef1dbc225fb055b30fc3a392358afdabbbb1ba99420e30
|
|
| MD5 |
8a80201d88b82009f733a64fd46bc4c3
|
|
| BLAKE2b-256 |
3294ec84a1af1e7e1bc80df5c1743759b57a802644e9d4ce84e168303db22ade
|
File details
Details for the file h5ffmpeg-2.3.2-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-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.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c7f32c5b5bc53266652c1dae4c85830d6d982fd8f1397e35784016552080843
|
|
| MD5 |
b8d4bcfc6801bd9735796a56b00298cd
|
|
| BLAKE2b-256 |
e30ca99f127a543c1fcf97505a8563ec3aab482d9703b8ecaf6f70e126a7bc11
|
File details
Details for the file h5ffmpeg-2.3.2-cp311-cp311-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 38.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46dac20b07caaaac9ff981b5b3452ffe311955d50a2f3d321686dbf2522060ec
|
|
| MD5 |
c24a62d1adcf3d38f8b968e94e305f21
|
|
| BLAKE2b-256 |
e34a38fe045f875828f6c60cf577bfd8079d3746ca319f0c61028f703c28ac31
|
File details
Details for the file h5ffmpeg-2.3.2-cp311-cp311-macosx_12_0_arm64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-cp311-cp311-macosx_12_0_arm64.whl
- Upload date:
- Size: 25.1 MB
- Tags: CPython 3.11, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
527dcf395dfdce0a8597576c59370774b6ea79735cd45aa62718929d876f3ea0
|
|
| MD5 |
628320f582aad0bfd8d0b42219d0076f
|
|
| BLAKE2b-256 |
5aa759ec3ff38ee1d2290afd29b826fc220ab38f19d1b92b487805308a551754
|
File details
Details for the file h5ffmpeg-2.3.2-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 34.6 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65773c8f2c87b2cca4186d1f86342fe978608cecf8a76916894cbe9a35c599a3
|
|
| MD5 |
c6c87e50bd030c57499e169f5a9c9222
|
|
| BLAKE2b-256 |
ed0937a2166a7f507fa5c2f0c5276dd3f0fa8ff89ecce6591e9b340cfa56d2a4
|
File details
Details for the file h5ffmpeg-2.3.2-cp310-cp310-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 38.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bc1637e0e49f8409c7899fa927a5d47dfedd74a26834b1dfc27f9f8f4431532
|
|
| MD5 |
791b05138eca3f1052743a15207eff81
|
|
| BLAKE2b-256 |
e83e22707a52624fa00130d07c23d2bc57e8b5e72a670150ae8ab422707d8cc8
|
File details
Details for the file h5ffmpeg-2.3.2-cp310-cp310-macosx_12_0_arm64.whl.
File metadata
- Download URL: h5ffmpeg-2.3.2-cp310-cp310-macosx_12_0_arm64.whl
- Upload date:
- Size: 25.1 MB
- Tags: CPython 3.10, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09e7f98d7355f788017f8d535813d6a6404242318061681dd7f5e50323166c20
|
|
| MD5 |
5d9d8d164f6f3126f0fd82c969f1b7ad
|
|
| BLAKE2b-256 |
ae6f9bf91b1e848a2ecc5bb29c0ae33b2e612d46bc20ceb09d072e59b5ffd59b
|