Entretoize
Entretoize

Reputation: 2251

How to get media bitrate with Libvlc

I'm using libvlc to play video files while downloading them. My problem is that libvlc_media_player_get_length returns nothing. Also I thought about calculating an approximation using the bitrate and the file size, but I don't find how to get the bitrate with libvlc.

Is there a function for that ?

Thanks

Upvotes: 0

Views: 1881

Answers (2)

caprica
caprica

Reputation: 4146

libvlc_media_tracks_get returns one or more structures containing track information.

If the track type is audio or video there is libvlc_audio_track_t.i_bitrate or libvlc_video_track_t.i_bitrate accordingly.

This API was added at version 2.1.0 of LibVLC, see http://git.videolan.org/?p=vlc.git;a=commit;h=cd5345a00009f2fc571c23509a025331ad24fc87.

VLC 2.1.0 was released in September 2013.

Upvotes: 0

Entretoize
Entretoize

Reputation: 2251

I finaly find this way:

libvlc_media_stats_t stats;
if (libvlc_media_get_stats(vlcmedia, &stats))
{
    long p=libvlc_media_player_get_time(vlcmediaplayer);

    if (p)
        bitrate=stats.i_read_bytes/p;
}

Upvotes: 1

Related Questions