在上篇文章[明明是mp4文件却在html中不显示图像](https://www.yuanchengzhushou.cn/article/8113.html)中我们讲了如何转码
如何将别的编码的mp4文件转换为h264编码的mp4文件,以便于在html页面中播放
但是当我在输入命令
>ffmpeg -i input.mp4 -vcodec h264 output.mp4
出现了错误,错误代码如下
>ffmpegtest /usr/local/bin/ffmpeg -i input.mp4 -vcodec h264 output.mp4
ffmpeg version 3.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
configuration:
libavutil 55. 27.100 / 55. 27.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 40.101 / 57. 40.101
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 46.102 / 6. 46.102
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.65.101
Duration: 00:00:03.01, start: 0.000000, bitrate: 505 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 960x400 [SAR 1:1 DAR 12:5], 413 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 84 kb/s (default)
Metadata:
handler_name : SoundHandler
Unknown encoder 'h264'
这个时候如何处理
```
ffmpeg -h encoder=libx264
git clone git://git.videolan.org/x264.git
cd x264
./configure --enable-shared --enable-pthread --enable-pic --disable-asm
make
make install
cd FFmpeg
./configure --enable-libfreetype --enable-avfilter --disable-x86asm --enable-indev=alsa --enable-outdev=alsa --enable-libx264 --enable-gpl --enable-static --enable-shared
make && make install
修改文件:/etc/ld.so.conf
在文件尾添加一行:
/usr/local/lib
然后执行命令:
ldconfig
ffmpeg -encoders | grep x264
```