I am streaming audio using FFMPeg and need to mix two audio sources using FFMpeg and set the volume level dynamically. I.e. once the stream starts, I need to be able update the ratio of the two volumes.
Currently, I have the volume mixing and streaming working using the CLI version of FFMPeg but the volume mix ratio is static.
Is there a way to dynamically set the volume ratio using the CLI tool? Perhaps something with an FFMpeg expression?
Or is using the API the only option? If so, can anyone point me towards an example of dynamically mixing audio? I haven't been able to find one.
Edit: here are the params I currently pass to mix audio. Again, this works fine, so not including the log as there is no error to fix. The question is how can I adjust the ratio of the amix
mix after the process has launched. Willing to use the API if need be.
"-f rawvideo" + // container
" -vcodec rawvideo" + // codec
" -s " + width + "x" + height + // input video size, must be correct
" -pix_fmt rgba" + // pixel format
" -framerate " + frameRate +
" -i pipe:0" + // from stdin in via pipe
" -f dshow" +
" -i audio=\"Stereo Mix (Realtek(R) Audio)\"" + //
" -f dshow" +
" -i audio=\"Microphone Array (Xbox NUI Sensor)\"" + //
" -filter_complex \"amix\"" + // mix the two inputs, can added ratio if needed
" -c:v libx264" + // x264 software encoder
" -g " + frameRate *2 +
" -keyint_min " + frameRate +
" -c:a aac" + // audio format
" -b:v 6M -maxrate 2M -bufsize 1M" + // constrain bitrate per twitch
" -f flv" +
" " + address
);