在安装 FFmpeg-PHP 时,我收到了这个有趣的错误:
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:
In function
'zim_ffmpeg_movie_getAudioStreamId':
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1051:
error: 'CODEC_TYPE_AUDIO' undeclared
(first use in this function)
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:
In function
'zim_ffmpeg_movie_getAudioChannels':
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1089:
error: 'CODEC_TYPE_AUDIO' undeclared
(first use in this function)
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:
In function
'zim_ffmpeg_movie_getAudioSampleRate':
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1125:
error: 'CODEC_TYPE_AUDIO' undeclared
(first use in this function)
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:
In function
'zim_ffmpeg_movie_getAudioBitRate':
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1161:
error: 'CODEC_TYPE_AUDIO' undeclared
(first use in this function)
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:
In function
'zim_ffmpeg_movie_getVideoBitRate':
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1181:
error: 'CODEC_TYPE_VIDEO' undeclared
(first use in this function)
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:
In function '_php_read_av_frame':
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1204:
error: 'CODEC_TYPE_VIDEO' undeclared
(first use in this function)
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1215:
warning: implicit declaration of
function 'avcodec_decode_video'
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1219:
error: 'PKT_FLAG_KEY' undeclared
(first use in this function)
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:
In function '_php_get_av_frame':
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1246:
error: 'CODEC_TYPE_VIDEO' undeclared
(first use in this function)
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1282:
error: 'AVCodecContext' has no member
named 'hurry_up'
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1284:
error: 'AVCodecContext' has no member
named 'hurry_up'
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:
In function
'_php_get_sample_aspect_ratio':
/usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1443:
error: 'CODEC_TYPE_VIDEO' undeclared
(first use in this function) make: ***
[ffmpeg_movie.lo] Error 1
当我跑步时php -r 'phpinfo();' | grep ffmpeg
,我得到了这个:
PHP Warning: PHP Startup: Unable to
load dynamic library
'/usr/lib/php/modules/ffmpeg.so' -
libavformat.so.52: cannot open shared
object file: No such file or directory
in Unknown on line 0
有什么想法可以修复这个问题吗?我在 Centos 上运行。
提前致谢 :)
答案1
为了这:
PHP Warning: PHP Startup: Unable to
load dynamic library
'/usr/lib/php/modules/ffmpeg.so' -
libavformat.so.52: cannot open shared
object file: No such file or directory
in Unknown on line 0
使用 ffmpeg 配置选项时,你将需要
--enable-shared
如果仍然有问题,请检查路径:
export LD_LIBRARY_PATH=/usr/local/lib/
echo /usr/local/lib > /etc/ld.so.conf.d/custom-libs.conf
ldconfig
跑步:
ldconfig
后
make && make install
答案2
看起来您缺少 libavformat 库。您应该能够通过 yum 包管理器安装它。
yum install ffmpeg
如果还是不行,尝试安装开发库
yum install ffmpeg-devel
答案3
检查您的系统中是否存在 libavcodec/libavformat,它可能只是在您的库路径中缺失,或者您安装的版本与预期不同。
find / -name 'libavformat*.so*' -print
并查看返回的内容,如果您安装的 ffmpeg 预期为 .so.52,但得到的却是 libavformat.so.53,那么这就是问题所在。