fix(stablediffusion-ggml): mux LTX-2 audio into output MP4#9990
Merged
Conversation
sd.cpp's generate_video now returns a sd_audio_t* alongside the video frames for models with an audio VAE (LTX-2.3). Our gosd wrapper was already collecting that pointer but immediately freed it without ever muxing it into the output, so LTX-2 generations landed as silent MP4s even though the audio VAE decode succeeded. Stage the planar float32 waveform to a temp WAV (IEEE float, header hand-built; samples interleaved on the fly), then add it as a second ffmpeg input with -c:a aac -map 0:v:0 -map 1:a:0 -shortest. The temp WAV is cleaned up unconditionally after ffmpeg exits, including on the write/waitpid error paths. Non-LTX models (Wan i2v / FLF2V) keep their current behaviour: audio arg is nullptr, the audio-related ffmpeg flags are not added, and no temp file is created. Assisted-by: Claude:claude-opus-4-7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generate_video()returns audio alongside frames for LTX-2.3 (audio VAE produces a waveform), but our gosd wrapper was collecting thesd_audio_t*and immediately freeing it without muxing — every LTX-2 generation landed as a silent MP4.-c:a aac -b:a 192k -map 0:v:0 -map 1:a:0 -shortest.unlink()'d on all ffmpeg exit paths (success, write error, waitpid error).audio == nullptr→have_audiostays false → no audio flags added to ffmpeg argv, no temp file created.Test plan
make libgosd-fallback.sobuilds cleanly with the change;gen_videoandload_modelsymbols are still exported.ltx-2.3-22b-distilled-ggml, POST/videowith a non-trivial prompt andnum_frames >= 25, download the resulting MP4 and confirmffprobereports a streamingaacaudio track alongsideh264video./videocall againstwan-2.1-i2v-14b-480p-ggmlshould still produce a single-stream h264 MP4 (no audio, no errors).Assisted-by: Claude:claude-opus-4-7