There is nothing wrong with the original PCM file, but in practical applications, some business scenarios require specific PCM audio specifications. For example, a manufacturer's speech recognition engine requires only 16-bit PCM data input, but the standard MP3 audio uses 32-bit sampling, so you have to find a way to convert 32-bit MP3 audio to 16-bit PCM audio.
Considering that it is more convenient to use FFmpeg's command line conversion, the following ffmpeg format conversion command is executed on the console to convert the sample frequency and number of channels together with the number of sample bits.
The console outputs the following error message "pcm_s16le codec not supported", meaning that the 16-bit PCM encoder is not supported.
Gee, how could FFmpeg not support such a basic PCM encoder? Go ahead and execute the following encoder view command:
The following pcm_s16le message appears in the output query, indicating that FFmpeg already supports this encoder by default.
So why does the ffmpeg command line not convert the sample bits of PCM audio properly?
searched around and found that there is no use of ffmpeg successful conversion of the number of samples of the case, had to first convert the original audio to 32-bit samples of the PCM file, the conversion command is shown below:
Next, in addition to writing the code to convert the number of bits of audio samples, the code content is shown below:
Save the code and then execute the following compile command.
The compilation is complete, then execute the following sample bit conversion command.
The output_16.pcm generated is now the 16-bit sampled PCM file that can be used for speech recognition.
For more details on FFmpeg development see