Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Auto-Narration Without FFmpeg

Auto-Narration Without FFmpeg go-pptx Tech Blog · Part 6: Media, Playback Timing, and Auto-Narration — A Pure Go Approach Without FFmpeg Series: go-pptx Tech Blog (10 parts) Baseline: v2.4.4 Keywords: WAV/MP3/MP4/WebM probing, duration state, media deduplication, playback tree, PlanTimingSync, narrate 1. Why "auto-narrating a PPT" needs media probing The typical pipeline for "auto-narration"…

Auto-narration for PowerPoint presentations can be accomplished without relying on FFmpeg by parsing container headers in pure Go. This approach determines the duration of audio files such as WAV, MP3, and MP4, allowing for accurate playback timing without external dependencies.

WAV files are analyzed by walking the top-level chunk linked list, reading sample rate, channels, bit depth, and byte rate from the fmt block. For MP3 files, the ID3v2 header, ID3v1 trailer, MPEG frame header, and various VBR headers are handled. The duration is computed in order of FrameScanned, HeaderDerived, and finally DurationUnknown if not found.

The go-pptx library handles video probing for MP4 and WebM formats. MP4 files are identified using the ftyp box, and duration is returned as DurationUnknown, relying on the caller to provide an accurate value. WebM/Matroska files are identified via the EBML header signature, with duration also returned as DurationUnknown.

The library deduplicates media content by computing a content-hash (SHA-256) and caching results per revision to avoid recomputation. When embedding media, the library adds the media Part, updates slide relationships, and writes shape fragments in a single transaction to ensure data integrity.

Audio shapes default to 1in x 1in size positioned at the bottom-right corner of the page. The playback tree includes an AudioRole enumeration with Narration, Background, and Effect roles, where only Narration tracks with OnSlideEnter trigger participate in timing calculations.

The AdvanceAfter formula calculates the maximum end time of participating tracks, adding TailPadding. PlanTimingSync outputs a TimingPlan, including base revision, per-page advance time, participating tracks, and duration state. If any page fails to generate a plan due to unknown durations, the entire batch is rejected, ensuring reliable auto-narration without external tools.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

More from Dev.to on urgent.news

Get the news by email. Yesterday's most-covered stories, every morning.

See today's edition · More options

More in Tech

More from Sunday, 6 December 2026 →