Skip to content

[Discussion] Add best practice check for browser-compatible video codecs in ImageSeries external files #669

@h-mayorquin

Description

@h-mayorquin

A core goal of DANDI and the NWB ecosystem is making neuroscience data not just archived but genuinely accessible and reusable. For behavioral video stored as ImageSeries external files, the choice of video codec has a direct impact on storage efficiency and interoperability. Older or camera-native codecs like MJPEG, MPEG-4 Part 2 (mp4v), and DIVX produce significantly larger files than modern alternatives like H.264 for the same visual content, and are poorly supported across platforms and tooling. Modern codecs like H.264, VP9, and AV1 have near-universal support. In practice, most labs don't intentionally choose these older codecs; they inherit them from camera SDK defaults (FLIR SpinView, Basler pylon) or OpenCV scripts. Cameras favor MJPEG because each frame encodes independently, which is computationally cheap enough for onboard hardware and avoids latency or data loss propagation during capture - but these advantages are irrelevant once the data is archived.

The NWB Inspector already checks that ImageSeries external files exist and use relative paths. A natural addition would be a best practice check that probes the codec of each referenced video file and suggests re-encoding to a widely supported modern codec when an inefficient or poorly supported one is detected. Since most of these files are already lossy-compressed, re-encoding to H.264 actually improves compression (smaller files) with negligible additional quality loss at high quality settings (CRF 17-18). The check message could include a ready-to-use ffmpeg command, e.g. ffmpeg -i input.avi -c:v libx264 -crf 18 -pix_fmt yuv420p output.mp4. For the rare case of intentionally lossless video (FFV1, raw), users can ignore the suggestion as with any best practice check.

Detected codec Suggest Reason
MJPEG H.264 No inter-frame compression, very large files, poor tooling support
MPEG-4 Part 2 (mp4v, DIVX, XVID) H.264 Outdated lossy codec, larger files and worse support than H.264
Raw / uncompressed H.264 No compression at all, enormous files
FFV1 H.264 Lossless and not widely supported; note that re-encoding is lossy
H.264, VP8, VP9, AV1 No suggestion Already widely supported and efficient

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions