Page 1 of 1

How to get codec info using Python binding?

Posted: 12 Feb 2023 23:17
by peppy.player
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!

Re: How to get codec info using Python binding?

Posted: 22 Feb 2023 02:10
by peppy.player
^^^ Any Python binding expert here who could answer the question? Thank you!

Re: How to get codec info using Python binding?

Posted: 22 Feb 2023 07:55
by mfkl

Re: How to get codec info using Python binding?

Posted: 09 Mar 2023 03:44
by peppy.player

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!

Re: How to get codec info using Python binding?

Posted: 09 Mar 2023 19:22
by RĂ©mi Denis-Courmont
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.

Re: How to get codec info using Python binding?

Posted: 10 Mar 2023 07:15
by peppy.player
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!