我想将'Open_Buffer_Continue'函数添加到MediaInfoDLL.py ctypes包装器中,绑定是here和 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
答案 0 :(得分: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))