How to get codec info using Python binding?

This forum is about all development around libVLC.
peppy.player
Blank Cone
Blank Cone
Posts: 38
Joined: 10 Nov 2017 00:07

How to get codec info using Python binding?

Postby peppy.player » 12 Feb 2023 23:17

Hi,

Using the Python binding I need to get the codec info about HTTP stream. In the VLC UI it looks like this:

Image

Using this Python code:

Code: Select all

track_info = self.media.get_tracks_info()
I can get the following information which includes: channels, codec (fourcc string) and rate:

Image

Where can I get such info as 'Bits per sample' and 'Bitrate'?

Thank you!

peppy.player
Blank Cone
Blank Cone
Posts: 38
Joined: 10 Nov 2017 00:07

Re: How to get codec info using Python binding?

Postby peppy.player » 22 Feb 2023 02:10

^^^ Any Python binding expert here who could answer the question? Thank you!

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: How to get codec info using Python binding?

Postby mfkl » 22 Feb 2023 07:55

https://mfkl.github.io

peppy.player
Blank Cone
Blank Cone
Posts: 38
Joined: 10 Nov 2017 00:07

Re: How to get codec info using Python binding?

Postby peppy.player » 09 Mar 2023 03:44


Thank you! I was able to get the bitrate using the referenced MediaStats object:

Code: Select all

media_stats = MediaStats() if self.media.get_stats(media_stats): bitrate = round(media_stats.demux_bitrate * 8000)

The only missing parameter is 'Bits per sample'. The MediaStats doesn't have it. Any idea where that could be?

Thank you!

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: How to get codec info using Python binding?

Postby Rémi Denis-Courmont » 09 Mar 2023 19:22

Bits per sample are useless. It's almost always 32 since VLC almost always decodes to single precision.

And if you were hoping it meant something else, well, it doesn't.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

peppy.player
Blank Cone
Blank Cone
Posts: 38
Joined: 10 Nov 2017 00:07

Re: How to get codec info using Python binding?

Postby peppy.player » 10 Mar 2023 07:15

Bits per sample are useless. It's almost always 32 since VLC almost always decodes to single precision.

OK, but it's not hard-coded, right? I hope there should be some object in the Python bindings from which it could be fetched.
Thank you!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 16 guests