CentOS7.4 yum和源码安装ffmpeg 将amr格式音频转码为mp3

源码安装:

安装依赖:

# yum install nasm yasm

安装依赖:

# wget https://nchc.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz

# tar -zxvf lame-3.100.tar.gz 

# cd lame-3.100

# ./configure 

# make

# make install

添加软连接,不然转码的时候要报 ffmpeg: error while loading shared libraries: libmp3lame.so.0: cannot open shared object file: No such file or directory:

扫描二维码关注公众号,回复: 12679013 查看本文章

ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib64/libmp3lame.so.0

安装ffmpeg:

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg

# cd ffmpeg

# ./configure  --enable-libmp3lame

# make && make install

转码测试:

[root@iZ2ze9jbuu3xabz2yumb7sZ ~]# ffmpeg -i test.amr test.mp3

ffmpeg version N-89404-gdc7d5f9 Copyright (c) 2000-2017 the FFmpeg developers

  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)

  configuration: –enable-libmp3lame

  libavutil      56.  5.100 / 56.  5.100

  libavcodec     58.  6.103 / 58.  6.103

  libavformat    58.  2.103 / 58.  2.103

  libavdevice    58.  0.100 / 58.  0.100

  libavfilter     7.  7.100 /  7.  7.100

  libswscale      5.  0.101 /  5.  0.101

  libswresample   3.  0.101 /  3.  0.101

[amr @ 0x2ad4360] Estimating duration from bitrate, this may be inaccurate

Input #0, amr, from 'test.amr':

  Duration: 00:03:01.14, bitrate: 12 kb/s

    Stream #0:0: Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt

Stream mapping:

  Stream #0:0 -> #0:0 (amr_nb (amrnb) -> mp3 (libmp3lame))

Press [q] to stop, [?] for help

Output #0, mp3, to 'test.mp3':

  Metadata:

    TSSE            : Lavf58.2.103

    Stream #0:0: Audio: mp3 (libmp3lame), 8000 Hz, mono, fltp

    Metadata:

      encoder         : Lavc58.6.103 libmp3lame

size=     177kB time=00:03:01.15 bitrate=   8.0kbits/s speed= 139x    

video:0kB audio:177kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.143412%

[root@iZ2ze9jbuu3xabz2yumb7sZ ~]# ll

total 1964

drwxr-xr-x 19 root root    4096 Dec  7 11:30 ffmpeg

drwxr-xr-x 15 1001 1001    4096 Dec  7 11:16 lame-3.100

-rw-r–r–  1 root root 1524133 Oct 14 04:33 lame-3.100.tar.gz

-rw-r–r–  1 root root  289830 Dec  6 16:33 test.amr

-rw-r–r–  1 root root  181556 Dec  7 11:57 test.mp3

2017.12.28 更新:

由于我们是调用微信的录音接口来做的,转为MP3后音质很不理想,与源amr录音相差有点大,所以研究转码参数后又做了进一步的调整,加上下面的参数进行转码:

ffmpeg -i source.amr -acodec libmp3lame -ar 24000 -vol 500 target.vol500.mp3

-acodec 指定编解码方式

-ar 24000 采样率设为24000

-vol 声音加大为500

其他参数参考:

http://blog.csdn.net/sunbingzibo/article/details/1649137

猜你喜欢

转载自blog.csdn.net/luoxiping1/article/details/83589399