0

我想将“Open_Buffer_Continue”函数添加到 MediaInfoDLL.py ctypes 包装器中,绑定在这里,MediaInfoDLL.cs C# 绑定已经实现了这个函数,所以它是可能的。

我如何通过以下内容:

file = open('./file.avi', 'rb')

到 mediainfo cpp Open_Buffer_Continue期望:

(   const ZenLib::int8u *   Buffer,
    size_t                  Buffer_Size 
) 

?

这是我到目前为止所拥有的:

MediaInfo_Open_Buffer_Init = MediaInfoDLL_Handler.MediaInfo_Open_Buffer_Init
MediaInfo_Open_Buffer_Init.argtype = [c_size_t, c_size_t]
MediaInfo_Open_Buffer_Init.restype = None

MediaInfo_Open_Buffer_Continue = MediaInfoDLL_Handler.MediaInfo_Open_Buffer_Continue
MediaInfo_Open_Buffer_Continue.argtype = [c_size_t, c_size_t]  # NOT SURE HERE var 1
MediaInfo_Open_Buffer_Continue.restype = c_size_t

MediaInfo_Open_Buffer_Finalize = MediaInfoDLL_Handler.MediaInfo_Open_Buffer_Finalize
MediaInfo_Open_Buffer_Finalize.argtype = [c_void_p]
MediaInfo_Open_Buffer_Finalize.restype = None
4

1 回答 1

1

我对此一无所知mediainfo,但它看起来像是ZenLib::int8u*一个指向字节的指针,所以最好使用的是:

MediaInfo_Open_Buffer_Continue.argtype = [c_char_p, c_size_t]

然后将您的文件读入一个字符串并传递它:

with open('./file.avi','rb') as f:
    data = f.read()
MediaInfo_Open_Buffer_Continue(data,len(data))
于 2013-06-27T09:15:22.017 回答