Skip to content

fix: keep audio-only containers as sound in PPTX - #2413

Open
mahesh-desu wants to merge 3 commits into
storytold:mainfrom
mahesh-desu:fix/2390-audio-only-container-mime
Open

mahesh-desu wants to merge 3 commits into
storytold:mainfrom
mahesh-desu:fix/2390-audio-only-container-mime

Conversation

@mahesh-desu

@mahesh-desu mahesh-desu commented Nov 27, 2026 •

Copy link
Copy Markdown

Audio-only files now save as sound in a PPTX, not as movies.

Fixes #2390.

What the user saw. Inserting an audio-only .asf through insert.audio reported video: false, but the saved PPTX stored the bytes as ppt/media/media1.wmv; the reference app reopened it as a Movie. A byte-identical .wma copy reopened as Sound.

Cause. content_type classifies an ASF/WMV container from the filename extension and returned video/x-ms-wmv for .asf, even when the probe found only an audio stream. insert.audio stored that MIME on the media item, and the shared PPTX writer chooses the part extension from the MIME (audio/x-ms-wma → .wma, video/x-ms-wmv → .wmv). The MediaClip.video flag was already correct.

What changed. After the probe, insert.audio normalizes the MIME only when the command is audio, the probe found audio and the probe found no video: video/x-ms-wmv becomes audio/x-ms-wma, and the equivalent video/mp4, video/webm, video/ogg and video/quicktime values become their audio MIMEs. Video-bearing containers keep their video/* MIME and insert.video is unchanged. The probe, the media model and the shared writer's MIME table are untouched.

Test. audio_only_asf_saves_as_sound inserts the owned tone.wma fixture under the name tone.asf, asserts the returned content type is audio/x-ms-wma, opens the saved PPTX ZIP to find ppt/media/media1.wma and no .wmv, reopens the deck, and checks video: false, a nonzero duration and the audio content type. audio_content_type_maps_every_audio_only_container pins every mapping arm, including the reporter's audio-only .mp4/.webm follow-up. audio_only_ogv_saves_as_sound inserts the owned tone.ogg under the name tone.ogv, so a real video/ogg container becomes an audio/ogg entry. a_video_container_inserted_as_video_stays_a_movie inserts the owned clip-h264.mp4 through insert.video and checks the reopened shape is still a movie; insert_video_still_rejects_an_audio_only_file keeps the video validator honest, and unreadable_audio_is_still_refused proves the original MIME validation still rejects an unreadable file.

Verification.

  • cargo fmt --all --check — passed.
  • cargo clippy -p deckcraft-engine --all-targets -- -D warnings — passed.
  • cargo test -p deckcraft-engine — 607 lib tests, 6 integration tests and 8 show-paragraph tests passed; 1 ignored; 0 failed.
  • Reference-app MediaType check — not run; the test inspects the saved package and the reopened video flag.

The mapping follows the existing writer table, so no new dependency or craft-libs change is needed.

Summary by CodeRabbit

  • Bug Fixes
    • Audio-only ASF and OGV files are now recognized and saved with the appropriate audio format when inserted into presentations.
    • MP4 files with video content remain classified as video after reopening a presentation.
    • Invalid insertions—such as audio-only content added as video or unreadable content added as audio—are rejected.

Signed-off-by: MaheshDesu <mahesh.desu3@gmail.com>
Signed-off-by: MaheshDesu <mahesh.desu3@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Audio insertion now maps selected detected MIME types to audio MIME types when probing finds audio without video. Tests cover MIME mappings, PPTX persistence, media classification, and invalid inputs.

Changes: Audio MIME handling

Layer / File(s) Summary
Audio MIME mapping and insertion
crates/engine/src/cmd/insert/picture.rs, crates/engine/src/cmd/media.rs
Audio-only media with selected detected MIME types uses the corresponding audio MIME type after validation. Tests cover WMA and Ogg PPTX media entries, MP4 video classification, and errors for invalid audio or video inputs.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: dylanmtaylor, aiongg

Merge Risk: Minimal · up to cf7d3

Audio-only ASF/OGV files inserted as audio are now saved with audio MIME types and sound XML, while video content is unchanged. No concrete merge-blocking risk was found. The external Reference app check was not run.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: keep audio-only containers as sound in PPTX" matches the main change. The PR maps audio-only WMV, MP4, WebM, Ogg, and QuickTime MIME types to audio MIME types when probing finds an aud…
Linked Issues check Passed [#2390] Requirement: a byte-identical audio-only .asf inserted through insert.audio must save as sound, the same as the .wma copy, and a video-bearing WMV/ASF must stay a movie. At the reviewed head, …
Out of Scope Changes check Passed The whole-PR diff against the merge base touches picture.rs only in the reviewed hunks: the audio_content_type() helper, one normalization line in media(), and a unit test module. The summary also lis…
Full details: Title check

Explanation

The title "fix: keep audio-only containers as sound in PPTX" matches the main change. The PR maps audio-only WMV, MP4, WebM, Ogg, and QuickTime MIME types to audio MIME types when probing finds an audio stream and no video stream, so audio-only inserts are saved as Sound objects in PPTX. The title is concise, single-sentence, and specific about the fix and its scope. It does not name the MIME mapping mechanism, but that detail is not required for the title.

Full details: Linked Issues check

Explanation

[#2390] Requirement: a byte-identical audio-only .asf inserted through insert.audio must save as sound, the same as the .wma copy, and a video-bearing WMV/ASF must stay a movie. At the reviewed head, picture.rs adds audio_content_type(), which maps video/x-ms-wmv to audio/x-ms-wma. media() applies this mapping only when !video && has_audio && !has_video. The validation still uses the original ct. The PR therefore sends audio/x-ms-wma to the existing writer path, which the PR states maps that MIME to ppt/media/media1.wma. Video-bearing containers keep video/* MIMEs, so the movie control is preserved. The test audio_only_asf_saves_as_sound checks the saved ZIP entry and the reopened video flag and duration. Limit: the reference-app MediaType check was not run. The PPTX writer MIME table was not inspected directly in this review, so the Sound (2) result relies on the PR's description of that table and on the saved-package test. The acceptance checks are met by the code path and the test evidence.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base touches picture.rs only in the reviewed hunks: the audio_content_type() helper, one normalization line in media(), and a unit test module. The summary also lists media.rs tests for audio-only ASF/OGV save, MP4 video staying a movie, and rejection controls. These tests exercise the same insert.audio/insert.video path that #2390 concerns. The extra mappings for video/mp4, video/webm, video/ogg, and video/quicktime apply the same root cause to other audio-only containers. This is a closely related generalization and not a demonstrated unrelated change. No unrelated files were reported in the diff summary. The PR does not change the probe, the media model, or the writer MIME table.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 62b8306 and cf7d35c.

Files selected for processing: 2

  • crates/engine/src/cmd/insert/picture.rs
  • crates/engine/src/cmd/media.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@autocraft-bot autocraft-bot Bot added the bugfix Fixes something that is broken: wrong result, crash, data loss label Nov 27, 2026

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

bugfix Fixes something that is broken: wrong result, crash, data loss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audio-only .asf saves as video media in PPTX

1 participant