I need to run an audio filter on a piped input using its own lufs value as a variable, without writing to disk.

I previously bounced the piped input to processedaudio.wav and the command works as:

ffmpeg -i pipe:0 -af $(echo "startofafilter$(echo "$(
ffmpeg -i processedaudio.wav -vn -af ebur128=framelog=verbose -f null - 2>&1 |awk '/I:/{print $2}')")
restofthefilter") -f null - 2>&1);

which pulls the lufs value from processedaudio.wav in that nested ffmpeg command (which is the same as pipe:0), but the value needs to change dynamically with each file. I need it to read from the pipe (or whatever gets me a similar effect) like this:

ffmpeg -i pipe:0 -af $(echo "startofafilter$(echo "$(
ffmpeg -i pipe:0 -vn -af ebur128=framelog=verbose -f null - 2>&1 |awk '/I:/{print $2}')")
restofthefilter") -f null - 2>&1);

where the only change is the nested input, but that command just hangs. Any ideas?

Edit: This is basically the workflow needed: enter image description here

Edit2: Attempting a named pipe seems to cause ffmpeg to hang. Named pipes are working in general:

mkfifo outpipe.wav | ffmpeg -y -i test.mov outpipe.wav | ffmpeg -f wav -i outpipe.wav testout.wav

and this command works with an actual file name:

echo "$(ffmpeg -f wav -i test.wav -vn -af "ebur128=framelog=verbose" -f null - 2>&1 | awk '/I:/{print $2}')"

But it doesn't work with a piped input:

mkfifo outpipe.wav | ffmpeg -y -i test.mov outpipe.wav | echo "$(ffmpeg -f wav -i outpipe.wav -vn -af "ebur128=framelog=verbose" -f null - 2>&1 | awk '/I:/{print $2}')"

At this point, I'm not sure what's going on. Am I missing something? Is this a bug?

  • How are you planning to use the LUFS value?
    – Gyan
    Jan 14, 2020 at 5:32
  • I'm doing some math to it and using that new number as the adjustment value for the audio filter. The files I process have different average levels in every video, mostly voice over at a constant level within each video, so the value must be adjusted up or down as needed. Jan 14, 2020 at 5:51
  • It will eventually be the n value for silencedetect, if that helps. Jan 14, 2020 at 20:20
  • 1
    Make the pipe input available though two named pipes and read through those..
    – Gyan
    Jan 15, 2020 at 5:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.