8

I am recording input microphone from a web page with WebRTC and process it through SoX.

Problem is, Firefox recordings are in Opus Audio format (according to VLC media informations), in an Ogg container, and SoX doesn't like it : /opt/local/bin/sox FAIL formats: can't open input file `/Users/[...]/public/audio/7a0d13a501.ogg': Input not an Ogg Vorbis audio stream

Is there a way to make it work with SoX? Or should I use another command-line audio tool?

ryancey
  • 1,037
  • 2
  • 11
  • 27

3 Answers3

15

I ended up doing this (either works, don't know which is the fastest):

opusdec --force-wav file.ogg - | sox - file.mp3

or

sox "|opusdec --force-wav file.ogg -" file.mp3

ryancey
  • 1,037
  • 2
  • 11
  • 27
  • 3
    To use the opusdec option opus-tool should be installed: `sudo apt-get install opus-tools` – HelloWorld Dec 06 '16 at 08:24
  • I haven't got the piping to work well yet, but using opusdec and then sox worked for me as well. On OSX brew allows you to install sox with opus support, so the additional step isn't necessary. I am guessing we would need to manually recompile sox with an opus option to get that behavior. – Chris Dec 09 '17 at 12:25
0

You can just specify -t opus when running sox

    sox -t opus file.ogg out.wav
  • 3
    I don't know what package you have, but the Debian package fails with: `sox FAIL formats: no handler for given file type 'opus'` – Tobia Nov 29 '20 at 20:34
  • I tested it on mac OS (seems like as well as @ryancey) with latest sox from brew – Contemplator Feb 03 '21 at 22:30
0

sox -t opus file.ogg out.wav works fine and not sure why opus is not part of the build on debian.

https://github.com/chirlu/sox/blob/master/INSTALL

Don't trust the distro build yourself as sox rox :)