Skip to main content

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.randint(0, 256, size=(100, 512, 512), dtype=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

Metadata

Release files for h5ffmpeg 2.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for h5ffmpeg 2.5.0
File Size Uploaded
h5ffmpeg-2.5.0.tar.gz 68.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for h5ffmpeg 2.5.0
File
h5ffmpeg-2.5.0-cp315-cp315-win_amd64.whl CPython 3.15 CPython 3.15 Windows x86-64 Details
h5ffmpeg-2.5.0-cp315-cp315-manylinux_2_34_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.34+ x86-64 Details
h5ffmpeg-2.5.0-cp315-cp315-macosx_12_0_arm64.whl CPython 3.15 CPython 3.15 macOS 12.0+ ARM64 Details
h5ffmpeg-2.5.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
h5ffmpeg-2.5.0-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details
h5ffmpeg-2.5.0-cp314-cp314-macosx_12_0_arm64.whl CPython 3.14 CPython 3.14 macOS 12.0+ ARM64 Details
h5ffmpeg-2.5.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
h5ffmpeg-2.5.0-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
h5ffmpeg-2.5.0-cp313-cp313-macosx_12_0_arm64.whl CPython 3.13 CPython 3.13 macOS 12.0+ ARM64 Details
h5ffmpeg-2.5.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
h5ffmpeg-2.5.0-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
h5ffmpeg-2.5.0-cp312-cp312-macosx_12_0_arm64.whl CPython 3.12 CPython 3.12 macOS 12.0+ ARM64 Details
h5ffmpeg-2.5.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
h5ffmpeg-2.5.0-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
h5ffmpeg-2.5.0-cp311-cp311-macosx_12_0_arm64.whl CPython 3.11 CPython 3.11 macOS 12.0+ ARM64 Details
h5ffmpeg-2.5.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
h5ffmpeg-2.5.0-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
h5ffmpeg-2.5.0-cp310-cp310-macosx_12_0_arm64.whl CPython 3.10 CPython 3.10 macOS 12.0+ ARM64 Details

Total release size: 642.0 MB

Release files / h5ffmpeg-2.5.0.tar.gz

Download URL h5ffmpeg-2.5.0.tar.gz
Size 68.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f0341010c8a51c59b737ee2ab8fd22e33289e36e392c9eaa289387a5650c5f2f
BLAKE2b-256 checksum
How to use checksums
b1842f0208f8085012713a934cd836887aee9fe528724bbe91b607317ded0f78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp315-cp315-win_amd64.whl

Download URL h5ffmpeg-2.5.0-cp315-cp315-win_amd64.whl
Size 40.4 MB
Tags CPython 3.15 Windows x86-64
SHA-256 checksum
How to use checksums
b277e28d70722c9978fde5fbd7871698948846318515fe0106a1f179d8dbe673
BLAKE2b-256 checksum
How to use checksums
174a67e17e57dfae43f13d2e30299f6593af69fc8ea193cd86669491a375ecc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp315-cp315-manylinux_2_34_x86_64.whl

Download URL h5ffmpeg-2.5.0-cp315-cp315-manylinux_2_34_x86_64.whl
Size 40.9 MB
Tags CPython 3.15 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
7df4864ee0aab7ca44405cf3f7948e74522051bca5da48a9486ae6e7ddb22cd5
BLAKE2b-256 checksum
How to use checksums
b03aaa19708053197d5951029108ead088bc768ce9557eae1ff447de80e05789
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp315-cp315-macosx_12_0_arm64.whl

Download URL h5ffmpeg-2.5.0-cp315-cp315-macosx_12_0_arm64.whl
Size 26.4 MB
Tags CPython 3.15 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
537e3fbeee80526b0c2ba0be803c9fad94d86c9c64b59442d0505d8c4c290576
BLAKE2b-256 checksum
How to use checksums
4bf3de912ab58f9a825cb0e9447542fb3f3612790d76be1ef277172380cbc48f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp314-cp314-win_amd64.whl

Download URL h5ffmpeg-2.5.0-cp314-cp314-win_amd64.whl
Size 40.4 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
6633028d982af416c2beab41d0e4401d4a081db561934361a40f09252066e646
BLAKE2b-256 checksum
How to use checksums
6dfd7ad3cc2a50d465dd35f936867aa610a84d8bd6781e9a5a97afee44494a20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL h5ffmpeg-2.5.0-cp314-cp314-manylinux_2_34_x86_64.whl
Size 40.9 MB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
7fd77bab4530e4909c694db2f97f210504eb4f4ea74b7bd9bc556afa23a3bb4e
BLAKE2b-256 checksum
How to use checksums
e6b008df83bc94a6423f60f2927d25ecea7f79e15fb773a29bab6dd7671ccc96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp314-cp314-macosx_12_0_arm64.whl

Download URL h5ffmpeg-2.5.0-cp314-cp314-macosx_12_0_arm64.whl
Size 26.4 MB
Tags CPython 3.14 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
ecd5138cf7dbfa1b35d5b5d4a98a461dae8fdb4dc36c1b889d27f8920822776b
BLAKE2b-256 checksum
How to use checksums
7066ef2b6fdebccf631bbac528fcf5d8b5f46400ee015cae75002d6004de1c96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp313-cp313-win_amd64.whl

Download URL h5ffmpeg-2.5.0-cp313-cp313-win_amd64.whl
Size 39.4 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
f6b5ff97c9aa01189307c762e980c8f3d25ed25d0172ea87a7b3c200300ae415
BLAKE2b-256 checksum
How to use checksums
50f305c0d3df16a50c01d66f22af1794343fa9c02facfb56b6c2db12d2ac18cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL h5ffmpeg-2.5.0-cp313-cp313-manylinux_2_34_x86_64.whl
Size 40.9 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
28fd5585d82077b09a0798476ea5f906fff5d0a59f402ebb448a2cd68f68d438
BLAKE2b-256 checksum
How to use checksums
8ab56141d3438f23324a71dc77a7431c407504e6620d84f7987199e77939f8e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp313-cp313-macosx_12_0_arm64.whl

Download URL h5ffmpeg-2.5.0-cp313-cp313-macosx_12_0_arm64.whl
Size 26.4 MB
Tags CPython 3.13 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
5a69d4d9b31d1b0fea967dcee31c8ed08c2dff2004372b1983b43bec33934a95
BLAKE2b-256 checksum
How to use checksums
1e453a57641e74060397043c750f47ffb6c3e599100bdb38180856580c41c139
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp312-cp312-win_amd64.whl

Download URL h5ffmpeg-2.5.0-cp312-cp312-win_amd64.whl
Size 39.4 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
c6c85113f8b6473035bf6dbb7d0dca96e319082c8a6366edf21a47baf143e7ff
BLAKE2b-256 checksum
How to use checksums
6476eb207d502d06f6f0e216157797552c09ac1bd184261b086eb34f61345ab4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL h5ffmpeg-2.5.0-cp312-cp312-manylinux_2_34_x86_64.whl
Size 40.9 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
8cfe0df4ab6efe6e7da0f8b2e4988122bd7814ed4eefc78c2269ee643f09e1d5
BLAKE2b-256 checksum
How to use checksums
2e06c8df8540007c7641b3ce6a61133fd0c5521a6aec1fd25a084b97e907b7f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp312-cp312-macosx_12_0_arm64.whl

Download URL h5ffmpeg-2.5.0-cp312-cp312-macosx_12_0_arm64.whl
Size 26.4 MB
Tags CPython 3.12 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
99c26b47f1e3c3cf92ed36e04b1508ffc7f85345d4037ec8845fd54cb2e27ce2
BLAKE2b-256 checksum
How to use checksums
d2442b188df07443b7547a7a01f52a2549afe1284d640be11e65ed66f084584f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp311-cp311-win_amd64.whl

Download URL h5ffmpeg-2.5.0-cp311-cp311-win_amd64.whl
Size 39.4 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
b42478760a47da8e98f5be68317d3a43930e1d333de7dc8b4f6887882abd02a9
BLAKE2b-256 checksum
How to use checksums
68c4fe762b35b573985b901135c46e1936872835a78df997b551188516f92dba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL h5ffmpeg-2.5.0-cp311-cp311-manylinux_2_34_x86_64.whl
Size 40.9 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
88652d1ab2f20198c67b4e91d0ef5031a75eaf10d8485fbba2b71022f6c40506
BLAKE2b-256 checksum
How to use checksums
a91858d99fd7a311285a3260381760a26c949840a4851f5d05b7b1f654665263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp311-cp311-macosx_12_0_arm64.whl

Download URL h5ffmpeg-2.5.0-cp311-cp311-macosx_12_0_arm64.whl
Size 26.4 MB
Tags CPython 3.11 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
7845df47b7874851e4abd667fa3c32e52eb410f3975f9ae5e2112b33a3da201a
BLAKE2b-256 checksum
How to use checksums
ba60476831ef57bab3f9e51955ae04e682c2643e606b99656a965df668b74884
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp310-cp310-win_amd64.whl

Download URL h5ffmpeg-2.5.0-cp310-cp310-win_amd64.whl
Size 39.4 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
aa69155eb824573fa9e04ba4401d87bee1ea187cf22c1e2a11165a52d9d8d2be
BLAKE2b-256 checksum
How to use checksums
bbc035a9605afbb7f33339d90460e9f4eb66d3d05413adc2cea236220f8d1bfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL h5ffmpeg-2.5.0-cp310-cp310-manylinux_2_34_x86_64.whl
Size 40.9 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
7db98d6db7acc80a0e8aa8ce937928c4e4f968cee61a6a266377c72c834bd59f
BLAKE2b-256 checksum
How to use checksums
5c1bef15872a2481610bb49e7b02aadb386e322a8ad72a6b11f26e21fb73a7e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release files / h5ffmpeg-2.5.0-cp310-cp310-macosx_12_0_arm64.whl

Download URL h5ffmpeg-2.5.0-cp310-cp310-macosx_12_0_arm64.whl
Size 26.4 MB
Tags CPython 3.10 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
60bdd0afd3221edcf7c8bc53c12df9960017b170d188d43de66636832fee9814
BLAKE2b-256 checksum
How to use checksums
6cba827c86433dcf35492f1eb9493daba3c85ecb3305825ea51994e7b14f7d93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.20

Release history Release notifications | RSS feed

This release

2.5.0 This release

19 release files

2.4.0

13 release files

2.3.2

13 release files

2.3.0

10 release files

2.2.2

10 release files

2.0.0

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page