Differenze tra le versioni di "Ottenere il bitrate di un file mp3 con le funzioni esterne del API di VLC"
Da Gambas-it.org - Wikipedia.
Riga 47: | Riga 47: | ||
Repeat | Repeat | ||
l = libvlc_media_get_duration(m) / 1000 | l = libvlc_media_get_duration(m) / 1000 | ||
+ | Wait 0.01 | ||
Until l > 0 | Until l > 0 | ||
Versione delle 20:47, 26 set 2022
Per ottenere il bitrate di un file mp3 con le funzioni esterne del API di VLC, si potrà utilizzare il seguente codice:
Library "libvlc:5.6.0" Private Enum libvlc_media_parse_local = 0, libvlc_media_parse_network, libvlc_media_fetch_local, libvlc_media_fetch_network = 4, libvlc_media_do_interact = 8 ' libvlc_instance_t * libvlc_new (int argc, const char *const *argv) ' Create And initialize a libvlc instance. Private Extern libvlc_new(argc As Integer, argv As String[]) As Pointer ' libvlc_media_t * libvlc_media_new_path (libvlc_instance_t *p_instance, const char *path) ' Create a media for a certain file path. Private Extern libvlc_media_new_path(p_instance As Pointer, path As String) As Pointer ' int libvlc_media_parse_with_options (libvlc_media_t *p_md, libvlc_media_parse_flag_t parse_flag, int timeout) ' Parse the media asynchronously with options. Private Extern libvlc_media_parse_with_options(p_md As Pointer, parse_flag As Integer, timeout As Integer) As Integer ' libvlc_time_t libvlc_media_get_duration(libvlc_media_t *p_md) ' Get duration (in ms) of media descriptor object item. Private Extern libvlc_media_get_duration(p_md As Pointer) As Long ' void libvlc_media_release (libvlc_media_t *p_md) ' Decrement the reference count of a media descriptor object. Private Extern libvlc_media_release(p_md As Pointer) ' libvlc_release (libvlc_instance_t * p_instance) ' Decrement the reference count of a libvlc instance, and destroy it if it reaches zero. Private Extern libvlc_release(p_instance As Pointer) Public Sub Main() Dim s As String Dim vlc, m As Pointer Dim lu, l As Long s = "/percorso/del/file.mp3" lu = Stat(s).Size vlc = libvlc_new(0, Null) m = libvlc_media_new_path(vlc, s) libvlc_media_parse_with_options(m, libvlc_media_parse_local, 0) Repeat l = libvlc_media_get_duration(m) / 1000 Wait 0.01 Until l > 0 Print "File audio: "; s Print "Dimensione: "; lu; " byte" Print "\nDurata: "; Time(0, 0, 0, l * 1000), "\e[1mBitrate: \e[31m"; ((lu * 8) \ l) \ 1000; "Kbps" libvlc_media_release(m) libvlc_release(vlc) End