0

I want to add 'Open_Buffer_Continue' function to the MediaInfoDLL.py ctypes wrapper, the bindings are here and MediaInfoDLL.cs C# binding already implements this function so it's possible.

How do i pass the following:

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

to the mediainfo cpp Open_Buffer_Continue which expects:

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

?

this is what i have so far:

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
  • What's being continued? – Eryk Sun Jun 24 '13 at 19:48
  • process of feeding more data, if function returns 0 it has enough, otherwise it can be run again –  Jun 25 '13 at 16:45
  • @user1434058: `Open_Buffer_Continue` expects a **buffer**, previously associated with a file. e.g. check: http://mediainfococoa.googlecode.com/svn/trunk/Lib/MediaInfo/Reader/Reader_File.cpp So I think there is more work to do like `Open_Buffer_Init` – Pragmateek Jun 25 '13 at 22:00
  • posted what i have so far, Open_Buffer_Continue is the only problem –  Jun 26 '13 at 00:09

1 Answers1

1

I know nothing about mediainfo, but it looks like ZenLib::int8u* is a pointer to bytes, so the best thing to use would be:

MediaInfo_Open_Buffer_Continue.argtype = [c_char_p, c_size_t]

Then read your file into a string and pass it:

with open('./file.avi','rb') as f:
    data = f.read()
MediaInfo_Open_Buffer_Continue(data,len(data))
Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251