Linux 如何在 Ubuntu 中播放 PCM 声音文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20314739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:29:59  来源:igfitidea点击:

how to play PCM sound file in Ubuntu?

linuxpcm

提问by socket

I have a PCM sound file with sample rate 16000, sample bit 16 and channel 1. I want to play it , but there's no software can do. I also tried ffplay like :

我有一个采样率为 16000、采样位为 16 和通道 1 的 PCM 声音文件。我想播放它,但没有软件可以做到。我也试过 ffplay 像:

ffplay -ar 16000 -ac 1 snake.raw

But still failed. How to play the PCM sound file in Ubuntu?

但还是失败了。如何在 Ubuntu 中播放 PCM 声音文件?

回答by sanette

You can use play/sox, which should be standard in ubuntu

您可以使用play/ sox,这在 ubuntu 中应该是标准的

play -t raw -r 16k -e signed -b 16 -c 1 snake.raw 

-r = sampling rate
-b = sampling precision (bits)
-c = number of channels

回答by mark4o

To use ffplaywith signed 16-bit little endian raw PCM, specify -f s16le:

ffplay与带符号的 16 位小端原始 PCM 一起使用,请指定-f s16le

ffplay -f s16le -ar 16k -ac 1 snake.raw

For a stereo, 32-bit floating-point, 48,000 file specify:

对于立体声、32 位浮点、48,000 文件,请指定:

ffplay -f f32le -ar 48000 -ac 2 snake.raw

For a list of supported formats for the -foption, use ffplay -formats. -aris the sample rate and -acis the number of channels.

有关该-f选项支持的格式列表,请使用ffplay -formats. -ar是采样率,-ac是通道数。