Skip to content

Add strict mode for video corruption detection#453

Open
IanButterworth wants to merge 2 commits into
masterfrom
ib/strict_mode
Open

Add strict mode for video corruption detection#453
IanButterworth wants to merge 2 commits into
masterfrom
ib/strict_mode

Conversation

@IanButterworth
Copy link
Copy Markdown
Member

Add a strict::Bool = false keyword to openvideo / VideoReader. When enabled, the underlying codec context is opened with AV_EF_EXPLODE | AV_EF_CRCCHECK | AV_EF_BITSTREAM, so bitstream / CRC errors propagate out of avcodec_receive_frame instead of being silently concealed. These errors surface to the caller as a VideoCorruptionError.

This makes decoding deterministic across FFmpeg versions for callers that need data integrity (no synthetic pixels from error concealment), while the default behaviour is unchanged.

  • Export VideoCorruptionError
  • Set err_recognition flags before avcodec_open2 when strict=true
  • Wrap the existing decode-error path in decode() to throw VideoCorruptionError instead of a plain error() when strict
  • Documentation in docs/src/reading.md and CHANGELOG.md
  • Tests covering the new keyword, exception type, normal-mode pass-through, and corruption detection via a malformed H.264 Annex-B bitstream

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.45%. Comparing base (e9e6e2e) to head (a86e431).

Files with missing lines Patch % Lines
src/avio.jl 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #453      +/-   ##
==========================================
- Coverage   80.05%   79.45%   -0.60%     
==========================================
  Files          10       10              
  Lines        1499     1504       +5     
==========================================
- Hits         1200     1195       -5     
- Misses        299      309      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add a `strict::Bool = false` keyword to `openvideo` / `VideoReader`. When
enabled, the underlying codec context is opened with
`AV_EF_EXPLODE | AV_EF_CRCCHECK | AV_EF_BITSTREAM`, so bitstream / CRC
errors propagate out of `avcodec_receive_frame` instead of being silently
concealed. These errors surface to the caller as a `VideoCorruptionError`.

This makes decoding deterministic across FFmpeg versions for callers that
need data integrity (no synthetic pixels from error concealment), while
the default behaviour is unchanged.

- Export `VideoCorruptionError`
- Set `err_recognition` flags before `avcodec_open2` when `strict=true`
- Wrap the existing decode-error path in `decode()` to throw
  `VideoCorruptionError` instead of a plain `error()` when strict
- Documentation in `docs/src/reading.md` and `CHANGELOG.md`
- Tests covering the new keyword, exception type, normal-mode pass-through,
  and corruption detection via a malformed H.264 Annex-B bitstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant