Skip to content

Commit 9735123

Browse files
committed
Special handling for silent programs
1 parent 1cd1363 commit 9735123

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

apps/gif-service/src/gif-generator.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ export class GIFGenerator {
227227
const height = this.decoder.getHeight();
228228
const outPath = join(tmpdir(), `zxplay-${process.pid}-${Date.now()}.mp4`);
229229

230-
// Audio (if any) goes via a temp f32le file as a second ffmpeg input;
231-
// video stays on stdin. Both run frames/50 seconds long, so they align.
232-
const hasAudio = audio.length > 0;
230+
// Only attach an audio track when the program actually made a sound;
231+
// a silent program is encoded video-only (-an), as it was before audio
232+
// support. Audio (when present) goes via a temp f32le file as a second
233+
// ffmpeg input; video stays on stdin. Both are frames/50 seconds long.
234+
const hasAudio = audio.some((a) => !this.isAudioSilent(a.left, a.right));
233235
const audioPath = outPath.replace(/\.mp4$/, '.f32le');
234236
if (hasAudio) {
235237
await writeFile(audioPath, this.interleaveAudio(audio));

0 commit comments

Comments
 (0)