我正在尝试从 pypi 安装 FFVideo 包。我已安装此处列出的所有依赖项:https://pypi.org/project/FFVideo/ 现在我收到以下错误。
$ pip install -U FFVideo
Collecting FFVideo
Using cached https://files.pythonhosted.org/packages/00/88/1837ebf7d023f03ecfcad0d49e95102969c4d0f631efcc137f2611500770/FFVideo-0.0.13.tar.gz
Building wheels for collected packages: FFVideo
Running setup.py bdist_wheel for FFVideo ... error
Complete output from command /home/kuba/.local/share/virtualenvs/myproject-Wt0aku_V/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-wkJ7XB/FFVideo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-OmIzSN --python-tag cp27:
running bdist_wheel
running build
running build_ext
building 'ffvideo' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/ffvideo
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/ffmpeg -I/home/kuba/.pyenv/versions/2.7.14/include/python2.7 -c ffvideo/ffvideo.c -o build/temp.linux-x86_64-2.7/ffvideo/ffvideo.o
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream___cinit__’:
ffvideo/ffvideo.c:1581:25: warning: implicit declaration of function ‘avcodec_alloc_frame’; did you mean ‘avcodec_send_frame’? [-Wimplicit-function-declaration]
__pyx_v_self->frame = avcodec_alloc_frame();
^~~~~~~~~~~~~~~~~~~
avcodec_send_frame
ffvideo/ffvideo.c:1581:23: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
__pyx_v_self->frame = avcodec_alloc_frame();
^
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream_2__init__’:
ffvideo/ffvideo.c:1886:5: warning: ‘codec’ is deprecated [-Wdeprecated-declarations]
__pyx_t_3 = ((__pyx_v_self->format_ctx->streams[__pyx_v_i])->codec->codec_type == AVMEDIA_TYPE_VIDEO);
^~~~~~~~~
In file included from ffvideo/ffvideo.c:259:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here
AVCodecContext *codec;
^~~~~
ffvideo/ffvideo.c:1998:3: warning: ‘codec’ is deprecated [-Wdeprecated-declarations]
__pyx_t_10 = __pyx_v_self->stream->codec;
^~~~~~~~~~
In file included from ffvideo/ffvideo.c:259:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here
AVCodecContext *codec;
^~~~~
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream_4__dealloc__’:
ffvideo/ffvideo.c:2344:5: warning: ‘av_free_packet’ is deprecated [-Wdeprecated-declarations]
av_free_packet((&__pyx_v_self->packet));
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4650:6: note: declared here
void av_free_packet(AVPacket *pkt);
^~~~~~~~~~~~~~
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream_8__decode_next_frame’:
ffvideo/ffvideo.c:2636:13: warning: ‘avcodec_decode_video2’ is deprecated [-Wdeprecated-declarations]
__pyx_v_ret = avcodec_decode_video2(__pyx_v_self->codec_ctx, __pyx_v_self->frame, (&__pyx_v_frame_finished), (&__pyx_v_self->packet));
^~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4993:5: note: declared here
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
^~~~~~~~~~~~~~~~~~~~~
ffvideo/ffvideo.c:2668:9: warning: ‘av_free_packet’ is deprecated [-Wdeprecated-declarations]
av_free_packet((&__pyx_v_self->packet));
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4650:6: note: declared here
void av_free_packet(AVPacket *pkt);
^~~~~~~~~~~~~~
ffvideo/ffvideo.c:2742:5: warning: ‘av_free_packet’ is deprecated [-Wdeprecated-declarations]
av_free_packet((&__pyx_v_self->packet));
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4650:6: note: declared here
void av_free_packet(AVPacket *pkt);
^~~~~~~~~~~~~~
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream_12current’:
ffvideo/ffvideo.c:2989:24: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
__pyx_v_scaled_frame = avcodec_alloc_frame();
^
ffvideo/ffvideo.c:3024:3: warning: ‘avpicture_get_size’ is deprecated [-Wdeprecated-declarations]
__pyx_v_buflen = avpicture_get_size(__pyx_v_self->ffmpeg_frame_mode, __pyx_v_self->frame_width, __pyx_v_self->frame_height);
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5653:5: note: declared here
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
^~~~~~~~~~~~~~~~~~
ffvideo/ffvideo.c:3045:51: warning: passing argument 2 of ‘PyObject_AsCharBuffer’ from incompatible pointer type [-Wincompatible-pointer-types]
__pyx_t_3 = PyObject_AsCharBuffer(__pyx_v_data, (&__pyx_v_data_ptr), (&__pyx_v_buflen)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^
In file included from /home/kuba/.pyenv/versions/2.7.14/include/python2.7/Python.h:133:0,
from ffvideo/ffvideo.c:4:
/home/kuba/.pyenv/versions/2.7.14/include/python2.7/abstract.h:476:22: note: expected ‘const char **’ but argument is of type ‘char **’
PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
^~~~~~~~~~~~~~~~~~~~~
ffvideo/ffvideo.c:3068:9: warning: ‘avpicture_fill’ is deprecated [-Wdeprecated-declarations]
avpicture_fill(((struct AVPicture *)__pyx_v_scaled_frame), ((__pyx_t_6ffmpeg_uint8_t *)__pyx_v_data_ptr), __pyx_v_self->ffmpeg_frame_mode, __pyx_v_self->frame_width, __pyx_v_self->frame_height);
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5638:5: note: declared here
int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
^~~~~~~~~~~~~~
ffvideo/ffvideo.c:3086:44: warning: passing argument 2 of ‘sws_scale’ from incompatible pointer type [-Wincompatible-pointer-types]
sws_scale(__pyx_v_img_convert_ctx, __pyx_v_self->frame->data, __pyx_v_self->frame->linesize, 0, __pyx_v_self->height, __pyx_v_scaled_frame->data, __pyx_v_scaled_frame->linesize);
^~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:261:0:
/usr/include/x86_64-linux-gnu/libswscale/swscale.h:217:5: note: expected ‘const uint8_t * const* {aka const unsigned char * const*}’ but argument is of type ‘uint8_t ** {aka unsigned char **}’
int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
^~~~~~~~~
ffvideo/ffvideo.c: In function ‘initffvideo’:
ffvideo/ffvideo.c:6432:30: error: ‘PIX_FMT_RGB24’ undeclared (first use in this function); did you mean ‘AV_PIX_FMT_RGB24’?
__pyx_t_2 = PyInt_FromLong(PIX_FMT_RGB24); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^~~~~~~~~~~~~
AV_PIX_FMT_RGB24
ffvideo/ffvideo.c:6432:30: note: each undeclared identifier is reported only once for each function it appears in
ffvideo/ffvideo.c:6444:30: error: ‘PIX_FMT_GRAY8’ undeclared (first use in this function); did you mean ‘AV_PIX_FMT_GRAY8’?
__pyx_t_2 = PyInt_FromLong(PIX_FMT_GRAY8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^~~~~~~~~~~~~
AV_PIX_FMT_GRAY8
ffvideo/ffvideo.c:6456:30: error: ‘PIX_FMT_YUV420P’ undeclared (first use in this function); did you mean ‘AV_PIX_FMT_YUV420P’?
__pyx_t_2 = PyInt_FromLong(PIX_FMT_YUV420P); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^~~~~~~~~~~~~~~
AV_PIX_FMT_YUV420P
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for FFVideo
Running setup.py clean for FFVideo
Failed to build FFVideo
Installing collected packages: FFVideo
Running setup.py install for FFVideo ... error
Complete output from command /home/kuba/.local/share/virtualenvs/myproject-Wt0aku_V/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-wkJ7XB/FFVideo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-6GrcYv/install-record.txt --single-version-externally-managed --compile --install-headers /home/kuba/.local/share/virtualenvs/myproject-Wt0aku_V/include/site/python2.7/FFVideo:
running install
running build
running build_ext
building 'ffvideo' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/ffvideo
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/ffmpeg -I/home/kuba/.pyenv/versions/2.7.14/include/python2.7 -c ffvideo/ffvideo.c -o build/temp.linux-x86_64-2.7/ffvideo/ffvideo.o
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream___cinit__’:
ffvideo/ffvideo.c:1581:25: warning: implicit declaration of function ‘avcodec_alloc_frame’; did you mean ‘avcodec_send_frame’? [-Wimplicit-function-declaration]
__pyx_v_self->frame = avcodec_alloc_frame();
^~~~~~~~~~~~~~~~~~~
avcodec_send_frame
ffvideo/ffvideo.c:1581:23: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
__pyx_v_self->frame = avcodec_alloc_frame();
^
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream_2__init__’:
ffvideo/ffvideo.c:1886:5: warning: ‘codec’ is deprecated [-Wdeprecated-declarations]
__pyx_t_3 = ((__pyx_v_self->format_ctx->streams[__pyx_v_i])->codec->codec_type == AVMEDIA_TYPE_VIDEO);
^~~~~~~~~
In file included from ffvideo/ffvideo.c:259:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here
AVCodecContext *codec;
^~~~~
ffvideo/ffvideo.c:1998:3: warning: ‘codec’ is deprecated [-Wdeprecated-declarations]
__pyx_t_10 = __pyx_v_self->stream->codec;
^~~~~~~~~~
In file included from ffvideo/ffvideo.c:259:0:
/usr/include/x86_64-linux-gnu/libavformat/avformat.h:893:21: note: declared here
AVCodecContext *codec;
^~~~~
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream_4__dealloc__’:
ffvideo/ffvideo.c:2344:5: warning: ‘av_free_packet’ is deprecated [-Wdeprecated-declarations]
av_free_packet((&__pyx_v_self->packet));
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4650:6: note: declared here
void av_free_packet(AVPacket *pkt);
^~~~~~~~~~~~~~
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream_8__decode_next_frame’:
ffvideo/ffvideo.c:2636:13: warning: ‘avcodec_decode_video2’ is deprecated [-Wdeprecated-declarations]
__pyx_v_ret = avcodec_decode_video2(__pyx_v_self->codec_ctx, __pyx_v_self->frame, (&__pyx_v_frame_finished), (&__pyx_v_self->packet));
^~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4993:5: note: declared here
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
^~~~~~~~~~~~~~~~~~~~~
ffvideo/ffvideo.c:2668:9: warning: ‘av_free_packet’ is deprecated [-Wdeprecated-declarations]
av_free_packet((&__pyx_v_self->packet));
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4650:6: note: declared here
void av_free_packet(AVPacket *pkt);
^~~~~~~~~~~~~~
ffvideo/ffvideo.c:2742:5: warning: ‘av_free_packet’ is deprecated [-Wdeprecated-declarations]
av_free_packet((&__pyx_v_self->packet));
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:4650:6: note: declared here
void av_free_packet(AVPacket *pkt);
^~~~~~~~~~~~~~
ffvideo/ffvideo.c: In function ‘__pyx_pf_7ffvideo_11VideoStream_12current’:
ffvideo/ffvideo.c:2989:24: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
__pyx_v_scaled_frame = avcodec_alloc_frame();
^
ffvideo/ffvideo.c:3024:3: warning: ‘avpicture_get_size’ is deprecated [-Wdeprecated-declarations]
__pyx_v_buflen = avpicture_get_size(__pyx_v_self->ffmpeg_frame_mode, __pyx_v_self->frame_width, __pyx_v_self->frame_height);
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5653:5: note: declared here
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
^~~~~~~~~~~~~~~~~~
ffvideo/ffvideo.c:3045:51: warning: passing argument 2 of ‘PyObject_AsCharBuffer’ from incompatible pointer type [-Wincompatible-pointer-types]
__pyx_t_3 = PyObject_AsCharBuffer(__pyx_v_data, (&__pyx_v_data_ptr), (&__pyx_v_buflen)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^
In file included from /home/kuba/.pyenv/versions/2.7.14/include/python2.7/Python.h:133:0,
from ffvideo/ffvideo.c:4:
/home/kuba/.pyenv/versions/2.7.14/include/python2.7/abstract.h:476:22: note: expected ‘const char **’ but argument is of type ‘char **’
PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
^~~~~~~~~~~~~~~~~~~~~
ffvideo/ffvideo.c:3068:9: warning: ‘avpicture_fill’ is deprecated [-Wdeprecated-declarations]
avpicture_fill(((struct AVPicture *)__pyx_v_scaled_frame), ((__pyx_t_6ffmpeg_uint8_t *)__pyx_v_data_ptr), __pyx_v_self->ffmpeg_frame_mode, __pyx_v_self->frame_width, __pyx_v_self->frame_height);
^~~~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:258:0:
/usr/include/x86_64-linux-gnu/libavcodec/avcodec.h:5638:5: note: declared here
int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
^~~~~~~~~~~~~~
ffvideo/ffvideo.c:3086:44: warning: passing argument 2 of ‘sws_scale’ from incompatible pointer type [-Wincompatible-pointer-types]
sws_scale(__pyx_v_img_convert_ctx, __pyx_v_self->frame->data, __pyx_v_self->frame->linesize, 0, __pyx_v_self->height, __pyx_v_scaled_frame->data, __pyx_v_scaled_frame->linesize);
^~~~~~~~~~~~
In file included from ffvideo/ffvideo.c:261:0:
/usr/include/x86_64-linux-gnu/libswscale/swscale.h:217:5: note: expected ‘const uint8_t * const* {aka const unsigned char * const*}’ but argument is of type ‘uint8_t ** {aka unsigned char **}’
int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
^~~~~~~~~
ffvideo/ffvideo.c: In function ‘initffvideo’:
ffvideo/ffvideo.c:6432:30: error: ‘PIX_FMT_RGB24’ undeclared (first use in this function); did you mean ‘AV_PIX_FMT_RGB24’?
__pyx_t_2 = PyInt_FromLong(PIX_FMT_RGB24); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^~~~~~~~~~~~~
AV_PIX_FMT_RGB24
ffvideo/ffvideo.c:6432:30: note: each undeclared identifier is reported only once for each function it appears in
ffvideo/ffvideo.c:6444:30: error: ‘PIX_FMT_GRAY8’ undeclared (first use in this function); did you mean ‘AV_PIX_FMT_GRAY8’?
__pyx_t_2 = PyInt_FromLong(PIX_FMT_GRAY8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^~~~~~~~~~~~~
AV_PIX_FMT_GRAY8
ffvideo/ffvideo.c:6456:30: error: ‘PIX_FMT_YUV420P’ undeclared (first use in this function); did you mean ‘AV_PIX_FMT_YUV420P’?
__pyx_t_2 = PyInt_FromLong(PIX_FMT_YUV420P); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
^~~~~~~~~~~~~~~
AV_PIX_FMT_YUV420P
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/home/kuba/.local/share/virtualenvs/myproject-Wt0aku_V/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-wkJ7XB/FFVideo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-6GrcYv/install-record.txt --single-version-externally-managed --compile --install-headers /home/kuba/.local/share/virtualenvs/myproject-Wt0aku_V/include/site/python2.7/FFVideo" failed with error code 1 in /tmp/pip-install-wkJ7XB/FFVideo/
我发现了这一点:https://bitbucket.org/zakhar/ffvideo/issues/14/mac-osx-support
但我无法安装旧版本的 ffmpeg(目前为 3.4.2-2)。我在 Ubuntu 18.04 上
答案1
您可以尝试这样的操作,它似乎可以安装和导入而没有任何错误。
#download FFVideo without installing
pip download FFVideo
#unpack tar file
tar -xvf FFVideo-0.0.13.tar.gz
#replace deprecated references
sed -i -e 's/avcodec_alloc_frame/av_frame_alloc/g' FFVideo-0.0.13/ffvideo/ffvideo.c
sed -i -e 's/PIX_FMT_RGB24/AV_PIX_FMT_RGB24/g' FFVideo-0.0.13/ffvideo/ffvideo.c
sed -i -e 's/PIX_FMT_GRAY8/AV_PIX_FMT_GRAY8/g' FFVideo-0.0.13/ffvideo/ffvideo.c
sed -i -e 's/PIX_FMT_YUV420P/AV_PIX_FMT_YUV420P/g' FFVideo-0.0.13/ffvideo/ffvideo.c
#pack it
tar -zcvf FFVideo-0.0.13.tar.gz FFVideo-0.0.13
#install
pip install --upgrade FFVideo-0.0.13.tar.gz
答案2
首先使用 pip 下载 ffvideo
pip download ffvideo
tar -xf FFVideo-0.0.13.tar.gz
cd FFVideo-0.0.13
python setup.py install
答案3
先前接受的答案需要额外替换 AV_CODEC_FLAG_GRAY 才能工作。
# download FFVideo without installing
pip download FFVideo
# unpack tar file
tar -xvf FFVideo-0.0.13.tar.gz
# replace deprecated references
sed -i -e 's/avcodec_alloc_frame/av_frame_alloc/g' FFVideo-0.0.13/ffvideo/ffvideo.c
sed -i -e 's/PIX_FMT_RGB24/AV_PIX_FMT_RGB24/g' FFVideo-0.0.13/ffvideo/ffvideo.c
sed -i -e 's/PIX_FMT_GRAY8/AV_PIX_FMT_GRAY8/g' FFVideo-0.0.13/ffvideo/ffvideo.c
sed -i -e 's/PIX_FMT_YUV420P/AV_PIX_FMT_YUV420P/g' FFVideo-0.0.13/ffvideo/ffvideo.c
# additional reference missing from previous answer
sed -i -e 's/CODEC_FLAG_GRAY/AV_CODEC_FLAG_GRAY/g' FFVideo-0.0.13/ffvideo/ffvideo.c
# pack it
tar -zcvf FFVideo-0.0.13.tar.gz FFVideo-0.0.13
# install
pip install --upgrade FFVideo-0.0.13.tar.gz