Python3/vlc:如何获取媒体统计信息(函数get_stats)
Python3/vlc: how to get media stats (function get_stats)
我正在尝试在媒体上调用 get_stats()
函数:
>>> instance = vlc.Instance()
>>> media = instance.media_new('song.mp3')
>>> media.get_stats()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: get_stats() missing 1 required positional argument: 'p_stats'
>>> media.get_stats('input_bitrate')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/alain/Audio/vlc.py", line 2517, in get_stats
return libvlc_media_get_stats(self, p_stats)
File "/home/alain/Audio/vlc.py", line 5349, in libvlc_media_get_stats
return f(p_md, p_stats)
ctypes.ArgumentError: argument 2: <class 'TypeError'>: expected LP_MediaStats instance instead of str
预期的参数类型 LP_MediaStats
在 vlc.py
中不存在,但我发现了这个:
class MediaStats(_Cstruct):
_fields_ = [
('read_bytes', ctypes.c_int ),
('input_bitrate', ctypes.c_float),
('demux_read_bytes', ctypes.c_int ),
('demux_bitrate', ctypes.c_float),
('demux_corrupted', ctypes.c_int ),
('demux_discontinuity', ctypes.c_int ),
('decoded_video', ctypes.c_int ),
('decoded_audio', ctypes.c_int ),
('displayed_pictures', ctypes.c_int ),
('lost_pictures', ctypes.c_int ),
('played_abuffers', ctypes.c_int ),
('lost_abuffers', ctypes.c_int ),
('sent_packets', ctypes.c_int ),
('sent_bytes', ctypes.c_int ),
('send_bitrate', ctypes.c_float),
]
有人知道这个功能怎么用吗?
从文档开始 here。它说:
libvlc_media_get_stats(p_md, p_stats)
Get the current statistics
about the media.
Parameters:
p_md - : media descriptor object.
p_stats - : structure
that contain the statistics about the media (this structure must be
allocated by the caller). Returns: true if the statistics are
available, false otherwise \libvlc_return_bool.
根据文档,您应该使用 media descriptor
作为参数。现在我们必须弄清楚如何获取媒体描述符。
我正在尝试在媒体上调用 get_stats()
函数:
>>> instance = vlc.Instance()
>>> media = instance.media_new('song.mp3')
>>> media.get_stats()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: get_stats() missing 1 required positional argument: 'p_stats'
>>> media.get_stats('input_bitrate')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/alain/Audio/vlc.py", line 2517, in get_stats
return libvlc_media_get_stats(self, p_stats)
File "/home/alain/Audio/vlc.py", line 5349, in libvlc_media_get_stats
return f(p_md, p_stats)
ctypes.ArgumentError: argument 2: <class 'TypeError'>: expected LP_MediaStats instance instead of str
预期的参数类型 LP_MediaStats
在 vlc.py
中不存在,但我发现了这个:
class MediaStats(_Cstruct):
_fields_ = [
('read_bytes', ctypes.c_int ),
('input_bitrate', ctypes.c_float),
('demux_read_bytes', ctypes.c_int ),
('demux_bitrate', ctypes.c_float),
('demux_corrupted', ctypes.c_int ),
('demux_discontinuity', ctypes.c_int ),
('decoded_video', ctypes.c_int ),
('decoded_audio', ctypes.c_int ),
('displayed_pictures', ctypes.c_int ),
('lost_pictures', ctypes.c_int ),
('played_abuffers', ctypes.c_int ),
('lost_abuffers', ctypes.c_int ),
('sent_packets', ctypes.c_int ),
('sent_bytes', ctypes.c_int ),
('send_bitrate', ctypes.c_float),
]
有人知道这个功能怎么用吗?
从文档开始 here。它说:
libvlc_media_get_stats(p_md, p_stats)
Get the current statistics about the media.Parameters: p_md - : media descriptor object. p_stats - : structure that contain the statistics about the media (this structure must be allocated by the caller). Returns: true if the statistics are available, false otherwise \libvlc_return_bool.
根据文档,您应该使用 media descriptor
作为参数。现在我们必须弄清楚如何获取媒体描述符。