scenejs-render icon indicating copy to clipboard operation
scenejs-render copied to clipboard

ffmpeg amix inputs causes audio volume issues

Open mhaddon opened this issue 3 years ago • 0 comments

You can see from these threads here:

  • https://stackoverflow.com/questions/35509147/ffmpeg-amix-filter-volume-issue-with-inputs-of-different-duration
  • https://stackoverflow.com/questions/62367391/ffmpeg-amix-filter-always-does-volume-normalization-how-to-prevent-it-and-wha

Basically, if I have one long video, and lots of small audio clips in it, than the long video will have its volume fade up over time, starting at 0%, and ending at 100%.

So you can change this line: https://github.com/daybrush/scenejs-render/blob/master/packages/recorder/src/Recorder.ts#L189

I tried appending ':normalize=0', but it doesnt seem to work with ffmpeg.wasm, but ':dropout_transition=1000,volume=${audiosLength}', does work, even though it is a hack.

So the line becomes:

            "-filter_complex", `amix=inputs=${audiosLength}:duration=longest:dropout_transition=1000,volume=${audiosLength}`,

It might be worth doing a bit of testing though to see if this is not a breaking change.

mhaddon avatar Jan 14 '23 03:01 mhaddon