How to play PCM sound file in Ubuntu?

I have a PCM audio file with a sampling frequency of 16000, sample bit 16 and channel 1. I want to play it, but there can be no software. I also tried ffplay like:

ffplay -ar 16000 -ac 1 snake.raw 

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

+6
source share
3 answers

You can use play / sox , which should be standard in 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 
+14
source

To use ffplay with a signed 16-bit small source PCM, specify -f s16le :

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

For a list of supported formats for the -f option, use ffplay -formats . -ar is the sampling rate, and -ac is the number of channels.

+12
source

I tried to do the same with ffplay / avplay , and although this seems possible (at least from the man pages), I could not figure it out, and did not find examples on intercountries.

ffplay and avplay are part of the ffmpeg project, and although you can play audio using ffmpeg , this is not recommended (see this discussion for more).

Decision

This question gave the following for playing raw pcm files from the command line:

 mplayer -rawaudio samplesize=2:channels=1:rate=8000 -demuxer rawaudio msg0001.raw 

Be sure to adjust the parameters, or you will get strange results (for fun, try halving the sampling rate).

mplayer man page

+2
source

Source: https://habr.com/ru/post/959129/


All Articles