[Python] Using mediainfo.dll to get file's metadata

程式碼參考了MediaInfo.DLL壓縮檔案內的MediaInfoDLL.py。
MediaInfoDLL.py已經把mediainfo.dll包好了,不過我只需要取得全部的資訊,class有太多東西都用不到,所以就自己寫了一個簡易版本的。

from ctypes import *

_mlib = windll.LoadLibrary("mediainfo.dll")

def getAllInform(filename):
    handle = c_void_p(_mlib.MediaInfo_New())
    _mlib.MediaInfo_Open(handle, c_wchar_p(filename))
    info = c_wchar_p(_mlib.MediaInfo_Inform(handle, c_size_t(0)))    
    return info.value

Reference:

沒有留言:

張貼留言