Coowhy的视频均采用ffmpeg来作为视频的转码方案,boss们想要移动端,那么mp4是个不错的选择,但是随之的问题也带来了。
具体安装参考
我是用参数
ffmpeg -i $inFile -ab 128 -acodec libmp3lame -ac 1 -ar 22050 -r 29.97 -qscale 6 -s 640x480 -f mp4 -y $outFile
这样转出来的mp4在android下可以正常播放,但是在IOS系统没有声音,应该是音频编码问题。
编译安装了libfacc后成功解决。
follow me:
安装libfacc:
tar zxvf faac-1.28.tar.gz
./configure and make and make install
遇到的问题
make[3]: *** [3gp.o] Error 1
make[3]: Leaving directory `/root/ffmpeg/faac-1.28/common/mp4v2'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/ffmpeg/faac-1.28/common'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/ffmpeg/faac-1.28'
make: *** [all] Error 2
在老外那里发现的解决的答案
vi common/mp4v2/mpeg4ip.h
删除第126行 char *strcasestr(const char *haystack, const char *needle);
然后 make clean 重新在 make
make install
完成facc的安装。
那么接下来需要重新编译一下ffmpeg 了,按照原来的参数,我在后面添加了--enable-nonfree --enable-libfaac 参数。
ffmpeg 运行时提示
ffmpeg: error while loading shared libraries: libfaac.so.0: cannot open shared object file: No such file or directory
OK Let‘s Go!
find / -name libfaac.so.0
/usr/local/lib/libfaac.so.0
vim /etc/ld.so.conf
新加入一行 /usr/local/lib
执行ldconfig
ffmpeg
然后使用参数
ffmpeg -i $inFile -ab 128 -acodec libfaac -ac 2 -ar 22050 -r 29.97 -qscale 6 -s 640x480 -f mp4 -y $outFile
搞定收工!