File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( / \. m p 4 $ / , '.f32le' ) ;
234236 if ( hasAudio ) {
235237 await writeFile ( audioPath , this . interleaveAudio ( audio ) ) ;
You can’t perform that action at this time.
0 commit comments