pyffmpeg instalação no Ubuntu falha com erros relacionados ao Cython

1

Eu estou falhando em pyffmpeg instalação no Ubuntu.

A instalação Cython parece estar correta:

$ sudo python setup.py install
...
Adding Cython 0.22.1 to easy-install.pth file
Installing cython script to /usr/local/bin
Installing cygdb script to /usr/local/bin
Installing cythonize script to /usr/local/bin
Installed /usr/local/lib/python2.7/dist-packages/Cython-0.22.1-py2.7-linux-x86_64.egg
Processing dependencies for Cython==0.22.1
Finished processing dependencies for Cython==0.22.1

Meu ffmpeg está em:

/usr/bin/ffmpeg

Então, eu mudei o setup.py de pyffmpeg de acordo.

Mas, tentar instalar o pyffmpeg produz esses erros do Cython:

$ sudo python setup.py install
[sudo] password for openstack: 
Remember: Edit at first ffmpegpath within setup.py
running install
running build
running build_ext
cythoning pyffmpeg.pyx to pyffmpeg.c
warning: pyffmpeg.pyx:4295:52: Unreachable code

Error compiling Cython file:
------------------------------------------------------------
...
    cdef AFFMpegReader vr
    cdef int no
    ## cdef AVFormatContext *FormatCtx
    cdef AVCodecContext *CodecCtx
    cdef AVCodec *Codec
    cdef AVOptions *codec_options
        ^
------------------------------------------------------------

pyffmpeg.pyx:3118:9: 'AVOptions' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
            self.CodecCtx.skip_loop_filter = AVDISCARD_NONKEY
            self.CodecCtx.skip_frame = AVDISCARD_NONKEY
            self.CodecCtx.skip_idct = AVDISCARD_NONKEY
            # deprecated
            # 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header
            self.CodecCtx.hurry_up=2  
                        ^
------------------------------------------------------------

pyffmpeg.pyx:3210:25: Object of type 'AVCodecContext' has no attribute 'hurry_up'

Error compiling Cython file:
------------------------------------------------------------
...
        self.Codec = avcodec_find_decoder(self.CodecCtx.codec_id)
        if self.Codec == NULL:
            raise IOError("Unable to get decoder")
        if (self.Codec.capabilities & CODEC_CAP_TRUNCATED) and (self.support_truncated!=0):
            self.CodecCtx.flags = self.CodecCtx.flags | CODEC_FLAG_TRUNCATED
        ret = avcodec_open(self.CodecCtx, self.Codec)
                              ^
------------------------------------------------------------

pyffmpeg.pyx:3303:31: Cannot convert 'AVCodecContext *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
        self.Codec = avcodec_find_decoder(self.CodecCtx.codec_id)
        if self.Codec == NULL:
            raise IOError("Unable to get decoder")
        if (self.Codec.capabilities & CODEC_CAP_TRUNCATED) and (self.support_truncated!=0):
            self.CodecCtx.flags = self.CodecCtx.flags | CODEC_FLAG_TRUNCATED
        ret = avcodec_open(self.CodecCtx, self.Codec)
                                             ^
------------------------------------------------------------

pyffmpeg.pyx:3303:46: Cannot convert 'AVCodec *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
    def set_hurry(self, b=1):
        #if we hurry it we can get bad frames later in the GOP
        if (b) :
            self.CodecCtx.skip_idct = AVDISCARD_BIDIR
            self.CodecCtx.skip_frame = AVDISCARD_BIDIR
            self.CodecCtx.hurry_up = 1
                        ^
------------------------------------------------------------

pyffmpeg.pyx:4034:25: Object of type 'AVCodecContext' has no attribute 'hurry_up'

Error compiling Cython file:
------------------------------------------------------------
...
            self.CodecCtx.hurry_up = 1
            self.hurried_frames = 0
        else:
            self.CodecCtx.skip_idct = AVDISCARD_DEFAULT
            self.CodecCtx.skip_frame = AVDISCARD_DEFAULT
            self.CodecCtx.hurry_up = 0
                        ^
------------------------------------------------------------

pyffmpeg.pyx:4039:25: Object of type 'AVCodecContext' has no attribute 'hurry_up'

Error compiling Cython file:
------------------------------------------------------------
...
    # time  related functions
    # #########################################################

    def get_fps(self):
        """ return the number of frame per second of the video """
        return (<float>self.stream.r_frame_rate.num / <float>self.stream.r_frame_rate.den)
                                 ^
------------------------------------------------------------

pyffmpeg.pyx:4104:34: Object of type 'AVStream' has no attribute 'r_frame_rate'

Error compiling Cython file:
------------------------------------------------------------
...
    # time  related functions
    # #########################################################

    def get_fps(self):
        """ return the number of frame per second of the video """
        return (<float>self.stream.r_frame_rate.num / <float>self.stream.r_frame_rate.den)
                                                                       ^
------------------------------------------------------------

pyffmpeg.pyx:4104:72: Object of type 'AVStream' has no attribute 'r_frame_rate'

Error compiling Cython file:
------------------------------------------------------------
...
                av_free_packet(self.packet)
                self.packet=NULL
            if (self.prepacket):
                av_free_packet(self.prepacket)
                self.prepacket=NULL
            av_close_input_file(self.FormatCtx)
                                   ^
------------------------------------------------------------

pyffmpeg.pyx:4252:36: Cannot convert 'AVFormatContext *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
        if (fmt==NULL) or (not (fmt.flags & AVFMT_NOFILE)):
            ret = avio_open(&self.FormatCtx.pb, filename, 0)
            if ret < 0:
                raise IOError("Unable to open file %s (avio_open)" % filename)
            if (buf_size>0):
                url_setbufsize(self.FormatCtx.pb,buf_size)
                                            ^
------------------------------------------------------------

pyffmpeg.pyx:4307:45: Cannot convert 'AVIOContext *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...

        assert(fmt!=NULL)
        self.FormatCtx.iformat=fmt

        if (mode=="r"):
            ret = av_open_input_stream(&self.FormatCtx,self.FormatCtx.pb,filename,self.FormatCtx.iformat,NULL)
                                      ^
------------------------------------------------------------

pyffmpeg.pyx:4328:39: Cannot convert 'AVFormatContext **' to Python object

Error compiling Cython file:
------------------------------------------------------------
...

        assert(fmt!=NULL)
        self.FormatCtx.iformat=fmt

        if (mode=="r"):
            ret = av_open_input_stream(&self.FormatCtx,self.FormatCtx.pb,filename,self.FormatCtx.iformat,NULL)
                                                                    ^
------------------------------------------------------------

pyffmpeg.pyx:4328:69: Cannot convert 'AVIOContext *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...

        assert(fmt!=NULL)
        self.FormatCtx.iformat=fmt

        if (mode=="r"):
            ret = av_open_input_stream(&self.FormatCtx,self.FormatCtx.pb,filename,self.FormatCtx.iformat,NULL)
                                                                                               ^
------------------------------------------------------------

pyffmpeg.pyx:4328:96: Cannot convert 'AVInputFormat *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...

        assert(fmt!=NULL)
        self.FormatCtx.iformat=fmt

        if (mode=="r"):
            ret = av_open_input_stream(&self.FormatCtx,self.FormatCtx.pb,filename,self.FormatCtx.iformat,NULL)
                                                                                                        ^
------------------------------------------------------------

pyffmpeg.pyx:4328:105: Cannot convert 'void *' to Python object
warning: pyffmpeg.pyx:4348:52: Obtaining 'char *' from externally modifiable global Python value

Error compiling Cython file:
------------------------------------------------------------
...
        # Guess file format with file extention
        oc.oformat = av_guess_format(NULL, filename_, NULL)
        if (oc.oformat==NULL):
            raise Exception, "Unable to find output format for %s\n"
        # Alloc priv_data for format
        oc.priv_data = av_mallocz(oc.oformat.priv_data_size)
                                           ^
------------------------------------------------------------

pyffmpeg.pyx:4352:44: Object of type 'AVOutputFormat' has no attribute 'priv_data_size'
warning: pyffmpeg.pyx:4369:35: Obtaining 'char *' from externally modifiable global Python value

Error compiling Cython file:
------------------------------------------------------------
...
        cdef int ret
        cdef int i

        if (track_selector==None):
            track_selector=TS_VIDEO
        ret = av_find_stream_info(self.FormatCtx)
                                     ^
------------------------------------------------------------

pyffmpeg.pyx:4385:38: Cannot convert 'AVFormatContext *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
                self.packet=NULL
            if (self.prepacket):
                av_free_packet(self.prepacket)
                self.prepacket=NULL
            self.tracks=[] # break cross references
            av_close_input_file(self.FormatCtx)
                                   ^
------------------------------------------------------------

pyffmpeg.pyx:4478:36: Cannot convert 'AVFormatContext *' to Python object

Error compiling Cython file:
------------------------------------------------------------
...
            if (ct.no==self.packet.stream_index):
                #ct.process_packet(self.packet)
                ## I don't know why it seems that Windows Cython have problem calling the correct virtual function
                ##
                ##
                if ct.CodecCtx.codec_type==CODEC_TYPE_VIDEO:
                                        ^
------------------------------------------------------------

pyffmpeg.pyx:4560:41: Invalid types for '==' (AVMediaType, CodecType)

Error compiling Cython file:
------------------------------------------------------------
...
                ##
                if ct.CodecCtx.codec_type==CODEC_TYPE_VIDEO:
                    processed=True
                    vt=ct
                    vt.process_packet(self.packet)
                elif ct.CodecCtx.codec_type==CODEC_TYPE_AUDIO:
                                          ^
------------------------------------------------------------

pyffmpeg.pyx:4564:43: Invalid types for '==' (AVMediaType, CodecType)

Error compiling Cython file:
------------------------------------------------------------
...
        ret = av_seek_frame(self.FormatCtx,-1,byte,  AVSEEK_FLAG_BACKWARD|AVSEEK_FLAG_BYTE)#|AVSEEK_FLAG_ANY)
        if ret < 0:
            raise IOError("Unable to seek: %d" % (ret,))
        if (self.io_context!=NULL):
            # used to have & here
            avio_seek(self.FormatCtx.pb, self.FormatCtx.data_offset, SEEK_SET)
                                                      ^
------------------------------------------------------------

pyffmpeg.pyx:4738:55: Object of type 'AVFormatContext' has no attribute 'data_offset'
building 'pyffmpeg' extension
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC

compile options: '-I/usr/bin/ffmpeg/include -I/usr/include -I./include -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
x86_64-linux-gnu-gcc: pyffmpeg.c
cc1: error: /usr/bin/ffmpeg/include: Not a directory
cc1: error: /usr/bin/ffmpeg/include: Not a directory
error: Command "x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/bin/ffmpeg/include -I/usr/include -I./include -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c pyffmpeg.c -o build/temp.linux-x86_64-2.7/pyffmpeg.o" failed with exit status 1

O que posso alterar para poder instalar pyffmpeg ?

    
por boardrider 02.08.2015 / 18:18

1 resposta

0

O caminho que está sendo solicitado para o ffmpeg é para os bibliotecários, não para o binário. Deve ser um pouco mais claro a esse respeito, mas o fato de que mostra "Não é um diretório" é o que é ajudado a resolver esse erro específico.

E, isso parece desatualizado em comparação com as bibliotecas ffmpeg e pode não funcionar com versões mais recentes que as mencionadas no README.

    
por 11.04.2017 / 21:52