Skip to content

FFMpeg: stream encrypted assets through MemBuf AVIO - #102

Open
defisym wants to merge 17 commits into
masterfrom
merge/encryption-core
Open

defisym wants to merge 17 commits into
masterfrom
merge/encryption-core

Conversation

@defisym

@defisym defisym commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

FFMpeg previously loaded an encrypted video's complete plaintext before playback. This PR connects the independent DecryptReader from #91 to the existing MemBuf/AVIO path so uncached encrypted assets can be read and sought on demand.

Depends on #91. The temporary base is codex/portable-encryption-sample, so this PR displays only the MemBuf/AVIO change and its compatibility follow-ups. Merge #91 first, then retarget/rebase this PR onto master as needed. The portable Encryption implementation, shared Unicode utilities and native analyzer fixes are reviewed in #91.

Changes

  • MemBuf remains the simple memory implementation and base class, with virtual read/seek/clone.
  • Plugin-side DecryptMemBuf receives an existing decryption context and forwards read/seek; the reusable encryption core has no FFmpeg types or includes.
  • The event bridge creates the decryption context only for uncached encrypted assets. Existing files/URLs, pointer/size memory and explicit caching keep their existing paths.
  • FFMpeg retains AVIO allocation, init_probe, format opening and cleanup. Probe uses av_probe_input_buffer2 and preserves probe bytes for later demuxing.
  • The optional FFMpegOptions::input is a shared_ptr prototype. Playback/preview clone independent cursors and own separate AVIO contexts. Default file/URL input creates no custom MemBuf/AVIO.
  • The original file/options and memory constructors remain. A private options-only delegate handles cleanup when construction fails. Grab-frame initialization retains the existing boolean error handling without a blanket catch.
  • Existing Debug/compiler/linker settings are preserved.
  • Core and KeyGen includes and native AVIO tests follow Encryption: portable core, KeyGen and existing asset compatibility #91's new Encryption/ module layout; the encryption implementation remains outside this PR.
  • No extra general input interface or AVIO wrapper is introduced. Existing Fusion action/expression parameters remain unchanged.

Validation

  • Local CMake Release and sanitizer suites passed for memory/encrypted WAV demuxing, explicit probing, exact payload bytes, size/seek bounds, independent previews and IO error translation.
  • A local harness compiled the actual FFMpeg probe/open/cleanup functions and verified identical full JPEG payloads from the original and old encrypted sample, plus invalid-probe cleanup.
  • After syncing the shared Unicode utilities from Encryption: portable core, KeyGen and existing asset compatibility #91, the complete core and AVIO suites passed again under ASan/UBSan. The event bridge uses std::filesystem::path directly and keygen::from_wide.
  • Core and old-asset compatibility coverage belongs to Encryption: portable core, KeyGen and existing asset compatibility #91. Native AVIO tests do not establish that the complete Fusion plugin has been built/run on Windows.

Manual acceptance

  • Build the FFMpeg extension with VS and load it in Fusion.
  • Play and seek a large encrypted video without caching; verify memory usage remains bounded.
  • Grab frames while playback seeks and confirm independent positions.
  • Check ordinary files/URLs, pointer/size memory, explicit caching and hardware/codec fallback.

After #91 merges, update this PR's base to master before final merge.

@defisym
defisym force-pushed the merge/encryption-core branch 4 times, most recently from 5315c7e to 1ac28bb Compare November 2, 2026 03:17
@defisym defisym changed the title Encryption: align shared core and streaming playback for merge FFMpeg: stream encrypted assets through MemBuf AVIO Nov 2, 2026
@defisym
defisym changed the base branch from master to codex/portable-encryption-sample November 2, 2026 07:41
@defisym
defisym force-pushed the merge/encryption-core branch from 1ac28bb to 639c671 Compare November 2, 2026 08:19
@defisym
defisym force-pushed the codex/portable-encryption-sample branch 2 times, most recently from 3d66802 to b8ec293 Compare November 3, 2026 05:59
@defisym
defisym force-pushed the merge/encryption-core branch 2 times, most recently from 1a741dd to b32eaf7 Compare November 3, 2026 06:37
@defisym
defisym force-pushed the codex/portable-encryption-sample branch from b8ec293 to 2f214ee Compare November 3, 2026 06:37
@defisym
defisym force-pushed the merge/encryption-core branch 3 times, most recently from a93a89c to 1e00866 Compare November 3, 2026 09:15
@defisym
defisym force-pushed the merge/encryption-core branch from 1e00866 to cdc2bed Compare November 4, 2026 02:05
@defisym
defisym force-pushed the codex/portable-encryption-sample branch from 45e68cc to 2fdd46c Compare November 4, 2026 02:05
@defisym
defisym force-pushed the merge/encryption-core branch from cdc2bed to 1bb6681 Compare November 4, 2026 02:19
@defisym
defisym force-pushed the merge/encryption-core branch from 93cdc3b to 2271a05 Compare November 4, 2026 02:23
@defisym
defisym force-pushed the merge/encryption-core branch from 2271a05 to ef1f66a Compare November 4, 2026 02:28
@defisym
defisym force-pushed the merge/encryption-core branch from ef1f66a to 741212d Compare November 4, 2026 02:40
@defisym
defisym force-pushed the merge/encryption-core branch from 741212d to 790975e Compare November 4, 2026 02:51
Base automatically changed from codex/portable-encryption-sample to master November 4, 2026 02:57

This branch has not been deployed

No deployments
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