Menu

#285 pipe decoded audio from ffmpeg to sox

closed-wont-fix
nobody
pipe (1)
5
2018-04-28
2017-01-03
No

I use sox to generate spectrogram images automatically over plenty of audio files. As sox does not support m4a files I decode these files usinf ffmpeg and pipe them into sox.
My command line is:
"C:\Program Files\ffmpeg-20161217-d8b9bef-win64-shared\bin\ffmpeg.exe" -y -i "my_music.m4a" -f sox - | "d:\down\Programme\sox-14.4.2\sox.exe" -p -n spectrogram -w Hann -o my_music.m4a.png

This results in the generation of a spectrogram image that reports a playtime of the music of about 8 seconds. My m4a file has a duration of a few minutes.
If I alter the command line to have ffmpeg deliver wav, sox eventually reports:
WARN wav: Premature EOF on .wav input file
Modified Command is:
"C:\Program Files\ffmpeg-20161217-d8b9bef-win64-shared\bin\ffmpeg.exe" -y -i "my_music.m4a" -f wav - | "d:\down\Programme\sox-14.4.2\sox.exe" -t wav - -n spectrogram -w Hann -o my_music.m4a.png

As this command results in a working wav file I think sox does not read the pipe correctly.
"C:\Program Files\ffmpeg-20161217-d8b9bef-win64-shared\bin\ffmpeg.exe" -y -i "my_music.m4a" -f wav - >my_music.wav

What is the best way to pipe audio decoded by ffmpeg to sox?

Discussion

  • Mans Rullgard

    Mans Rullgard - 2018-04-28
    • status: open --> closed-wont-fix
     
  • Mans Rullgard

    Mans Rullgard - 2018-04-28

    The spectrogram generator needs to know the length upfront in order to scale the image correctly. If the length is unknown, it arbitrarily uses the first 8 seconds. You can either decode to a temporary file or extract the length by other means and pass it to the spectrogram effect using the -d option.

     

Log in to post a comment.