简单介绍用ffmpeg将PCMA转PCM

最近遇到一个问题,需要将pcma格式的wav文件转成16K 16BIT的PCM格式的wav文件。

于是召唤万能的ffmpeg,用它完成这个任务。

如果服务器上没有ffmpeg工具,请先安装ffmpeg。ffmpeg请自行搜索,本章就不赘述了。

ffmpeg -i  A101001892_2.wav -acodec pcm_s16le -ac 1 -ar 16000 86800205.wav -y
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers

其中:A101001892_2.wav是等待转换的源wav文件。-acodec pcm_s16le是指定转换格式为PCM。 -ac 1是指单声道。 -ar 16000 采样率16000。86800205.wav -y输出的文件名是 86800205.wav。

wenet@asrcent8 ~]$ ffmpeg -i  A101001892_2.wav -acodec pcm_s16le -ac 1 -ar 16000 86800205.wav -y
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (GCC)
  configuration: --disable-x86asm
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from 'A101001892_2.wav':
  Duration: 00:00:27.38, bitrate: 64 kb/s
    Stream #0:0: Audio: pcm_alaw ([6][0][0][0] / 0x0006), 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_alaw (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to '86800205.wav':
  Metadata:
    ISFT            : Lavf58.29.100
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
    Metadata:
      encoder         : Lavc58.54.100 pcm_s16le
size=     856kB time=00:00:27.38 bitrate= 256.0kbits/s speed=1.8e+03x    
video:0kB audio:856kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.008902%

使用ffmpeg查看转码后的格式,ffmpeg -i 86800205.wav

[wenet@asrcent8 ~]$ ffmpeg -i 86800205.wav
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (GCC)
  configuration: --disable-x86asm
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from '86800205.wav':
  Metadata:
    encoder         : Lavf58.29.100
  Duration: 00:00:27.38, bitrate: 256 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
At least one output file must be specified

你可能感兴趣的:(shell基础知识及技巧,ffmpeg,pcm,音视频)