[我的目标是将opus文件解码为pcm文件。我尝试使用ffmpeg示例[How do I decode opus file to pcm file using libavcodec from ffmpeg?],但没有成功。我了解到libopus也可以从Internet进行操作。所以我下载了libopus [https://opus-codec.org/release/stable/2019/04/12/libopus-1_3_1.html].After,我从opus_demo.c的编译中得到opus_demo,我运行它。
./opus_demo
Usage: ./opus_demo [-e] <application> <sampling rate (Hz)> <channels (1/2)> <bits per second> [options] <input> <output>
./opus_demo -d <sampling rate (Hz)> <channels (1/2)> [options] <input> <output>
application: voip | audio | restricted-lowdelay
options:
-e : only runs the encoder (output the bit-stream)
-d : only runs the decoder (reads the bit-stream as input)
-cbr : enable constant bitrate; default: variable bitrate
-cvbr : enable constrained variable bitrate; default: unconstrained
-delayed-decision : use look-ahead for speech/music detection (experts only); default: disabled
-bandwidth <NB|MB|WB|SWB|FB> : audio bandwidth (from narrowband to fullband); default: sampling rate
-framesize <2.5|5|10|20|40|60|80|100|120> : frame size in ms; default: 20
-max_payload <bytes> : maximum payload size in bytes, default: 1024
-complexity <comp> : complexity, 0 (lowest) ... 10 (highest); default: 10
-inbandfec : enable SILK inband FEC
-forcemono : force mono encoding, even for stereo input
-dtx : enable SILK DTX
-loss <perc> : simulate packet loss, in percent (0-100); default: 0
./opus_demo -d 16000 2 ./test.opus ./outfile.pcm
libopus 1.3.1
Decoding with 16000 Hz output (2 channels)
Invalid payload length: 440786851
bitrate statistics are undefined
我的作品文件是从ffmpeg命令捕获的。
ffmpeg -f avfoundation -i :0 out.opus
ffmpeg -i out.opus -acodec pcm_s16le -f s16le -ac 1 -ar 16000 ./out.pcm
ffplay -ar 16000 -ac 1 -f s16le -i ./out.pcm
我该怎么办?达到我的目标。请帮助我。
这是Ogg Opus文件吗? opus_demo
更像是一个“教程”,从我记忆中可以学习使用libopus
C库进行编程。您可以使用CLI工具进行解码:
$ opusdec music.opus music.wav
https://opus-codec.org/release/dev/2018/09/18/opus-tools-0_2.html