Skip to content

fix: treat PlaceMarker failure as non-fatal and shut down sink on error#157

Merged
ruccho merged 2 commits into
CyberAgentGameEntertainment:mainfrom
scream870102:fix/mpeg4-sink-placemarker-nonfatal
Jul 17, 2026
Merged

fix: treat PlaceMarker failure as non-fatal and shut down sink on error#157
ruccho merged 2 commits into
CyberAgentGameEntertainment:mainfrom
scream870102:fix/mpeg4-sink-placemarker-nonfatal

Conversation

@scream870102

Copy link
Copy Markdown
Contributor

Summary

Fixes #156.

On recent Windows 11 builds (observed on OS build 10.0.26200 with mfmp4srcsnk.dll 10.0.26100.8457), IMFStreamSink::PlaceMarker on the OS-provided MPEG4 media sink returns MF_E_INVALIDTYPE for every marker type and argument combination. The ? on the PlaceMarker call killed the stream event loop, the finish signal was never sent, and CompleteAsync failed with Failed to complete muxer: channel closed (a hard Rust panic on versions before better_error_handling).

Changes

  • PlaceMarker(ENDOFSEGMENT) failure is now logged and treated as non-fatal. The marker is only used as a completion hint; finalization still runs and writes the moov box without it.
  • The muxer task now calls sink.Shutdown() on the error path, so the output file handle is no longer leaked until process exit when muxing fails.

Verification

Native binaries are intentionally not included; they can be rebuilt via the Build unienc workflow.

🤖 Generated with Claude Code

On some Windows builds (observed on 26200 with mfmp4srcsnk.dll
10.0.26100.8457) the OS MPEG4 media sink rejects every
IMFStreamSink::PlaceMarker call with MF_E_INVALIDTYPE, which killed the
stream event loop and made export fail with "channel closed" (CyberAgentGameEntertainment#156).

- PlaceMarker(ENDOFSEGMENT) failure is now logged and ignored so
  finalization still runs and writes the moov box.
- The muxer task now calls sink.Shutdown() on the error path so the
  output file handle is not leaked until process exit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ruccho

ruccho commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the report. This indeed seems to be specific to that build... I could not reproduce it with mfmp4srcsnk.dll (10.0.26100.8655) on my Windows 11 (26200.8655) (all PlaceMarker calls succeeded in mp4sink_repro.cpp). Treating PlaceMarker as non-fatal seems fine, so I will go ahead and merge this.

@ruccho
ruccho merged commit efd92ae into CyberAgentGameEntertainment:main Jul 17, 2026
1 check passed
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.

Windows: export always fails with "Failed to complete muxer: channel closed" — OS MPEG4 sink rejects PlaceMarker (MF_E_INVALIDTYPE)

2 participants