SoX doesn't work with Opus Audio files
Asked Answered
D

3

10

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?

Dislocate answered 11/3, 2014 at 10:3 Comment(0)
D
16

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

Dislocate answered 13/3, 2014 at 12:24 Comment(4)
To use the opusdec option opus-tool should be installed: sudo apt-get install opus-toolsCottontail
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.Colophon
@Cottontail how does it work with command line once opus tools are installed?Geminate
copy-paste the command as is. The library is called automatically... if that is what you mean...Cottontail
H
0

You can just specify -t opus when running sox

    sox -t opus file.ogg out.wav
Habana answered 17/10, 2020 at 1:8 Comment(2)
I don't know what package you have, but the Debian package fails with: sox FAIL formats: no handler for given file type 'opus'Katzman
I tested it on mac OS (seems like as well as @ryancey) with latest sox from brewHabana
C
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 :)

Consonance answered 6/3, 2022 at 1:48 Comment(2)
im stuck in the same issue can you share the sox application that works with opus filesGeminate
If your distro hasn't compiled with opus then use the opus-tools opusdec pipe as above. Debian can be bad for this as issue raising isn't all that friendly where some maintainers just ignore you. Speex if I remember right is still the RC version before the final and that is years old.Consonance

© 2022 - 2024 — McMap. All rights reserved.