I am trying to obtain bitrate, sample rate actual bits per sample of an audio file using python-vlc.
I saw that we can use libvlc_media_tracks_get() to obtain bitrate, but I am not sure how to get the others.
But even if this method can obtain all 3 info, I still can't manage to make the method work. It takes 2 arguments p_md and tracks. I don't understand what is tracks. It says it requires an instance of LP_LP_MediaTrack but I can't somehow find what that means.
Bitrate:
Sample rate (appending the above code):
The main reason I couldn't get the bitrate is because I didn't understand how to get the data type
LP_LP_MediaTrack. This is a double pointer of a MediaTrack instance.When
vlc.libvlc_media_tracks_get(media, ctypes.byref(mediaTrack_pp))runs, I think the library simply sets copies the MediaTrack instance inmediato the actual memory location thatmediaTrack_pppoints toWe can then get the actual object in Python using the
ctypes.cast()method. This algorithm should apply on all Python codes that usesLP_xxxdata types, even for other libraries.With that problem solved, all that left was to crunch the API documentation.
VLC MediaTrack class documentation