Coder Social home page Coder Social logo

python-vlc's Introduction

Python ctypes-based bindings for libvlc

This file documents the bindings generator, not the bindings themselves. For the bindings documentation, see the README.module file.

The bindings generator generates ctypes-bindings from the include files defining the public API. The same generated module should be compatible with various versions of libvlc 2.* and 3.*. However, there may be incompatible changes between major versions. Versioned bindings for 2.2 and 3.0 are provided in the repository.

License

The module generator is licensed under the GNU General Public License version 2 or later. The generated module is licensed, like libvlc, under the GNU Lesser General Public License 2.1 or later.

Building from source

You can get the latest version of the code generator from https://github.com/oaubert/python-vlc/ or http://git.videolan.org/?p=vlc/bindings/python.git.

The code expects to be placed inside a VLC source tree, in vlc/bindings/python, so that it finds the development include files, or to find the installed include files in /usr/include (on Debian, install libvlc-dev).

To generate the vlc.py module and its documentation, for both the development version and the installed VLC version, use

make

If you want to generate the bindings from an installed version of the VLC includes (which are expected to be in /usr/include/vlc), use the 'installed' target:

make installed

To install it for development purposes (add a symlink to your Python library) simply do

python setup.py develop

preferably inside a virtualenv. You can uninstall it later with

python setup.py develop --uninstall

Documentation building needs epydoc. An online build is available at http://olivieraubert.net/vlc/python-ctypes/

Packaging

The generated module version number is built from the VLC version number and the generator version number:

vlc_major.vlc_minor.(1000 * vlc_micro + 100 * generator_major + generator_minor)

so that it shared it major.minor with the corresponding VLC.

To generate the reference PyPI module (including setup.py, examples and metadata files), use

make dist

LibVLC Discord

Join the chat at https://discord.gg/3h3K3JF

python-vlc is part of the LibVLC Discord Community server. Feel free to come say hi!

How to contribute

There are short-terms contributions (reporting and fixing bugs, contributing unit tests, contributing examples). A number of libvlc functions are currently blacklisted (search for _blacklist in the generator code), mostly because of their signature complexity. They would benefit some work.

Longer terms goals include the rewriting of the generator to use a proper parser for the C-syntax (for the moment, the parser relies on regexp-based expression, which works thanks to the coding style applied in the code, but remains very fragile).

python-vlc's People

Contributors

albestro avatar bandit-masked avatar cimbali avatar garfvl avatar geoffsalmon avatar gorb314 avatar hamidb80 avatar hbuschme avatar jonashaag avatar kimwiktoren avatar metakermit avatar mfkl avatar mrjean1 avatar oaubert avatar odinho avatar patinnc avatar phill-85 avatar pjeanjean avatar scamcast avatar smu160 avatar tgc-dk avatar typx avatar xantares avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-vlc's Issues

"error: package directory 'generator/generate' does not exist

Hello,

I tried to install the Python binding library, I had an error message : "error: package directory 'generator/generate' does not exist.

  • image

But I can find the folder and file mentioned:

  • image

I really can't understand why I have this error message.

Would you have an idea? It would really help me. Thanks!

Use of video_set_callbacks

Hello,
i have been trying to get images frame per frame from an rtsp stream.
I can get the stream in vlc window, but i cannot get the frame data.
I read that i should use the video_set_callbacks function; however, instance crash if i set a callback.
This is a part of the code I've been using :

import vlc, ctypes

pl = vlc.MediaPlayer('rtsp://addr')

@vlc.CallbackDecorators.VideoLockCb
def _lockcb(opaque, planes):
        print "lock"
        return ctypes.create_string_buffer('\000')

p = ctypes.POINTER(ctypes.c_int)()
pl.video_set_callbacks(_lockcb, None, None, p)

pl.play()

Did i do something wrong ? Or maybe it isn't supported in the python binding ?

Thanks !

vlc logo

Is there a way to change the logo of already running vlc instance? Thanks.

All threads locked to single CPU core at a time

Hi Oliver,

Firstly - great project. I've been investing a lot of effort into using these bindings.

It'd been fairly smooth sailing until I started playing back some heavier content (h264@2160p). I noticed that there was a considerable performance difference between native VLC and the python bindings.

It turns out that the decoding threads appear limited to one CPU core when ran as part of the bindings. Below are some snippets of the process threads on the two players, native and through the python bindings. Note: I'm running on Windows, but will soon attempt the same on Linux.

eg_nativethreads

eg_pythonthreads

In the first example, you'll see the ffmpeg decoders are spread quite neatly over my four cores. They're utilising roughly 45% of total CPU usage. In the second example, all the heavy lifting is being done by one maxed out core, for a total of 25% total CPU usage.

I've tried to do my homework before creating an issue, and suspect that this might be a product of Python's GIL - but I wasn't sure.

I've attempted a couple of things:

  • Utilising different versions of Python.
  • Running the bindings in their purest form.
    vlc.py [content]
  • Emulating the affinity of native VLC to emulate this behaviour - it replicates the results exactly.
  • Forcing multiple threads as a passed parameter.
    --avcodec-threads=

I'm stuck at this point - is this a limitation of the bindings?

Appreciate your time,

Thank you!

Viewpoint FFI Runtime Error

Attempting to create/update a viewpoint with libvlc 3.0.1 results in a runtime error:

import vlc
view = vlc.libvlc_video_new_viewpoint()

Results in:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/me/Projects/vlc.py", line 7131, in libvlc_video_new_viewpoint
return f()
RuntimeError: ffi_prep_cif failed

python vlc can't read webm and 3gp stream

First sorry for all the **** i did by closing and reopening the issue.

I was wondering if it was on purpose or a bug if python-vlc can't read 3gp and webm file on stream while vlc can.

Indeed python-vlc read perfctly mp4 files but when you try to read webm files or gp3 the read crash and have for logs:

[0x2aa45b8] main input error: open of `https://r3---sn-n4g-jqb6.googlevideo.com/videoplayback?itag=17&key=yt6&mime=video%2F3gpp&gir=yes&clen=161008&signature=9DCBA41482947F4FFA589AFDE01E2C0D69B7FE65.C6F4BC9E47C741EFFE6553E504FF77A73F1CA15D&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&source=youtube&expire=1519593014&ipbits=0&lmt=1478874226847504&initcwndbps=598750&ip=77.136.42.117&ms=au%2Crdu&mv=m&mt=1519571288&requiressl=yes&dur=17.043&id=o-ACZWg2uwmoF7F9GVoXWAabQ_Dk478Q_4jg-9TOJi66Ke&mn=sn-n4g-jqb6%2Csn-25glenes&pl=23&mm=31%2C29&fvip=5&ei=1tGSWvnXJsbiW5CYuaAL&c=WEB&ratebypass=yes' failed
[0x2aa45b8] main input error: Your input can't be opened
[0x2aa45b8] main input error: VLC is unable to open the MRL 'https://r3---sn-n4g-jqb6.googlevideo.com/videoplayback?itag=17&key=yt6&mime=video%2F3gpp&gir=yes&clen=161008&signature=9DCBA41482947F4FFA589AFDE01E2C0D69B7FE65.C6F4BC9E47C741EFFE6553E504FF77A73F1CA15D&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&source=youtube&expire=1519593014&ipbits=0&lmt=1478874226847504&initcwndbps=598750&ip=77.136.42.117&ms=au%2Crdu&mv=m&mt=1519571288&requiressl=yes&dur=17.043&id=o-ACZWg2uwmoF7F9GVoXWAabQ_Dk478Q_4jg-9TOJi66Ke&mn=sn-n4g-jqb6%2Csn-25glenes&pl=23&mm=31%2C29&fvip=5&ei=1tGSWvnXJsbiW5CYuaAL&c=WEB&ratebypass=yes'. Check the log for details.

I have 2 questions:

  1. where do you save your log? (i didn't find them in /var/log)
  2. is it an issue, an unimplemented feature or a miss usage of mine.

Regards
GuillaumeMilan

tutorial?

Where can I find a full tutorial/reference for commands/api? cannot find it anywhere. e.g. get the length of music etc

Missing libgcc_s_seh-1.dll

With Win7, running pip install python-vlc and then running the following in ipython:

import vlc
inst = vlc.Instance()

Causes a System Error to popup:

python.exe - System Error

The program can't start because libgcc_s_seh-1.dll is missing from your computer. Try reinstalling the program to fix this problem.

No function error

`root@OpenWrt:/tmp# python
Python 2.7.9 (default, Jan 24 2017, 15:02:15)
[GCC 4.8.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import vlc
vlc.libvlc_get_version()
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/site-packages/python_vlc-1.1.2-py2.7.egg/vlc.py", line 3971, in libvlc_get_version
File "/usr/lib/python2.7/site-packages/python_vlc-1.1.2-py2.7.egg/vlc.py", line 246, in _Cfunction
NameError: no function 'libvlc_get_version'
`

root@OpenWrt:/tmp# ls /usr/lib/libvlc* /usr/lib/libvlc.a /usr/lib/libvlccore.a /usr/lib/libvlc.so /usr/lib/libvlccore.so /usr/lib/libvlc.so.5 /usr/lib/libvlccore.so.8 /usr/lib/libvlc.so.5.5.0 /usr/lib/libvlccore.so.8.0.0

Does any one know why?
Already have vlc 2.2.4 and can use vlc command to play mp3 on board.

audio_output_device_get() returns NameError: no function

import vlc
vlci = vlc.Instance('pathtoplugins')
vlcp = vlci.media_player_new()

vlcp.audio_output_device_get()

gives error:

NameError: no function 'libvlc_audio_output_device_get'

and for the life of me without this working I can't figure out how to get the device id to use in

vlcp.audio_output_device_set(None, 'device id')

Win 10/ latest VLC/PyCharm 5.0.1

Some files sound like white noise

I'm using the latest version of the binding on Raspberry Pi 3. Some files sound like white noise.
Here is example:
http://www.archive.org/download/aesop_fables_volume_one_librivox/fables_01_08_aesop_64kb.mp3
It has the following parameters:
Codec MPEG Audio layer 1/2(mpga)
Channels: Stereo
Sample rate: 22050 Hz
Bitrate: 64 kb/s

Another files with different parameters work fine. For example:
http://www.archive.org/download/aesop_fables_volume_one_librivox/fables_01_09_aesop_64kb.mp3
Codec MPEG Audio layer 1/2(mpga)
Channels: Mono
Sample rate: 44100 Hz
Bitrate: 64 kb/s

I'm just wondering if this is VLC/binding issue or hardware/driver issue while playing files with
sample rate 22050 Hz ?
Thanks!

VLC Import Error

Whenever I try to use python vlc, I get this in my console:

  File "mypythonfile.py", line 11, in <module>
    import vlc
  File "C:\Users\forlo\Miniconda3\lib\site-packages\vlc.py", line 198, in <module>
    dll, plugin_path  = find_lib()
  File "C:\Users\forlo\Miniconda3\lib\site-packages\vlc.py", line 173, in find_lib
    dll = ctypes.CDLL(libname)
  File "C:\Users\forlo\Miniconda3\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

How do I fix this?

Call libvlc_log_get_context invoke exception.

Thanks for great app.

When call libvlc_log_get_context invoke exception.

I think, in below line, ListPOINTER must be replaced with ctypes.POINTER.

https://github.com/oaubert/python-vlc/blob/master/generated/vlc.py#L4363

  • traceback
Traceback (most recent call last):
    File "_ctypes/callbacks.c", line 234, in 'calling callback function'
    File "/Users/m/stream_monitor_client/__vlc_no_audio/test_vlc.py", line 78, in log_handler
        print(vlc.libvlc_log_get_context(ctx))
    File "/Users/m/anaconda3/envs/sm/lib/python3.6/site-packages/vlc.py", line 4344, in libvlc_log_get_context
        None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_uint))
    File "/Users/m/anaconda3/envs/sm/lib/python3.6/site-packages/vlc.py", line 243, in _Cfunction
        f = p((name, dll), flags)
    TypeError: 'out' parameter 2 must be a pointer type, not ListPOINTER

Have a nice day!

Unexpected video_update_viewpoint behavior

I have noticed different behavior when using the video_update_viewpoint() function on a mediaplayer spawned from a specifically created instance vs a directly spawned media player.

for example:
import vlc
p = vlc.MediaPlayer('V1.mp4')
p.play()
v = vlc.libvlc_video_new_viewpoint()
p.video_update_viewpoint(v,True)
while p.get_state() !=6:
continue

Produces a video with a viewpoint altered from the default (though I am still unclear how to control it).

Whereas:
import vlc
i = vlc.Instance()
p = i.media_player_new()
m = i.media_new('V1.mp4')
m.get_mrl()
p.set_media(m)
v = vlc.libvlc_video_new_viewpoint()
p.video_update_viewpoint(v,True)
p.play()
while p.get_state() != 6:
continue

Plays with the default viewpoint().

Is it correct to expect these two approaches to produce the same result?

make fails

Version: 1dd9bf6
Python 2.7.6
Ubuntu 14.04 (LTS)

Steps:

  1. git clone
  2. run "make" inside project root directory

Expected:
2. New vlc.py generated (instructed by README.rst)

Actual:
Error shown: make: *** No rule to make target ../../include/vlc/*.h', needed by generated/vlc.py'. Stop.

Access to currently displayed subtitle path

Hi, thanks for this app!

I can explicitly add a subtitle to a media with media.add_options("sub-file=my_file.ass"). If sub-autodetect is enabled (by default), another subtitle can be displayed instead. It seems there is no way to know which subtitle is currently displayed.

With player.get_media().tracks_get(), I can access to the tracks of the media, but the SubtitleTrack object only contains encoding. Is it possible to access to more information from the track? Ultimately, the path to the subtitle file would be great.

No Access to Pitch / Roll/ Yaw / FOV

After creating a video viewpoint object with:
v = vlc.libvlc_video_new_viewpoint()

To control a 360 video, I should be able to set the pitch, roll, yaw and FOV for the view. According to one of the mods for libvlc, I should just be able to set the variable directly rather than through a separate function.

Looking through the VLC code (specifically /include/vlc_viewpoint.h) it seems like a Viewpoint should initialize all those variables to zero, but I don't see those variables, and if I manually create them, (such as v.yaw = 5) it no affect on the libvlc_video_update_viewpoint() function.

Considering the implementation of the python wrapper, is there any reason to expect that these variables would be accessible in a different way?

vlc.Instance.media_new don't apply options and filters (vlc 2.1.5-5)

import vlc
vlc_instance = vlc.Instance()
player = vlc_instance.media_player_new()
media =vlc_instance.media_new("test.mov", "sub-filter=marq{marquee=Hello}, "vout-filter=invert")
player.set_media(media)
player.start()

show no difference with

media =vlc_instance.media_new("test.mov")

Doc updates for Enums

The documentation for Python _Enums and in the _set and _get functions should be updated. Specifically replace

  • libvlc_audio_output_channel_t with L{AudioOutputChannel}
  • libvlc_media_parse_flag_t with L{MediaParseFlag}
  • libvlc_media_parsed_status_t with L{MediaParsedStatus}
  • libvlc_media_player_role_t with L{MediaPlayerRole}
  • libvlc_state_t with L{State}
  • libvlc_teletext_key_t with L{TeletextKey}
  • libvlc_video_adjust_option_t with L{VideoAdjustOption}
  • libvlc_adjust_enable with L{VideoAdjustOption}.Enable
  • libvlc_video_marquee_int_option_t with L{VideoMarqueeOption}
  • libvlc_video_marquee_string_option_t with L{VideoMarqueeOption}
  • libvlc_marquee_Enable with L{VideoMarqueeOption}.Enable
  • libvlc_video_logo_option_t with L{VideoLogoOption}
  • libvlc_logo_enable with with L{VideoLogoOption}.Enable

and the following if applicable

  • libvlc_event_t with L{EventType}
  • libvlc_media_t with L{MediaType}
  • libvlc_media_type_t with L{MediaType}
  • libvlc_position with L{Position}
  • libvlc_renderer_item_t with
  • vlm_media_t with
  • vlm_media_instance_t with

using just a whole-word replace() call over the generated Python code.

The _Enums are named inconsistently. For example, the VideoAdjustOption names are all capitalized, the VideoMarqueeOption names are mixed camel- and lowercase and the VideoLogoOptions are all lowercase.

Lastly, to find the option value types, it would be helpful to point to this VideoAdjustOption page, this VideoLogoOption (and this Logo Erase?) page and this VideoMarqueeOption page.

Import error on MacOS

Importing libvlc doesn't work on MacOS. When I try to import VLC (using VLC 3.0 RC9) I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/user/miniconda/envs/blah/lib/python3.6/site-packages/vlc.py", line 198, in <module>
    dll, plugin_path  = find_lib()
  File "/Users/user/miniconda/envs/blah/lib/python3.6/site-packages/vlc.py", line 183, in find_lib
    dll = ctypes.CDLL(p)
  File "/Users/user/miniconda/envs/blah/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib, 6): Library not loaded: @rpath/libvlccore.dylib
  Referenced from: /Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib
  Reason: image not found

It looks like libvlccore.dylib needs to be imported first before importing libvlc.dylib.

vlm i_instance parameter not needed

All of the Instance().vlm_get_media_instance_XXX functions require both a psz_name and i_instance. When using vlm for a broadcast or vod, you can play, stop, pause, and change the media with just the psz_name. But to get position, you also need the i_instance (instance id) which can't be gotten from anywhere.

Choose which libvlc to use?

Hi

I have VLC 2.2.4 on my system, using libvlc5. I have also vlmc for testing, using libvlc6 (for VLC 3). The problem is that the Python-VLC binding seems to use the latest libvlc available, which causes some sneaky problems (eg: using libvlc6, instance is None without warnings).

Is there a way to choose the libvlc version to use?

Thanks for your time

Problem with rtsp with python-vlc

Hello @oaubert , I am writing because I have a rather strange problem with vlc.py. I'm connecting with his example "qtvlc.py" to a RTSP cameras. The strange thing is that there are 2 cameras connected to the same DVR and can not see one. The other I can see no problems. If you like and can test yourself directions are:

rtsp://75.149.45.50:554/cam/realmonitor?channel=1&subtype=0&unicast=true&authbasic=YWRtaW46YWRtaW4=

rtsp://75.149.45.50:554/cam/realmonitor?channel=3&subtype=0&unicast=true&authbasic=YWRtaW46YWRtaW4=

​The first is that I can not see and the error is :

"[03215fc4] live555 demux error: Nothing to play for rtsp: //75.149.45.50: 554 / cam / realmonitor channel = 1 & subtype = 0 Unicast = true auth basic = YWRtaW46YWRtaW4 = proto = Onvif "​

But if I can connect to the same camera with vlc media player without problem.

Thank you so much, hope you can help me.

vlc.MediaListPlayer.get_media_player() not implemented?

This method is documented and included in vlc.py, but the binding is broken.

>>> import vlc
>>> mlp = vlc.MediaListPlayer()
>>> mp = mlp.get_media_player()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lethargilistic/Dev/player/vlc.py", line 2681, in get_media_player
    return libvlc_media_list_player_get_media_player(self)
  File "/home/lethargilistic/Dev/player/vlc.py", line 5052, in libvlc_media_list_player_get_media_player
    ctypes.c_void_p, MediaListPlayer)
  File "/home/lethargilistic/Dev/player/vlc.py", line 249, in _Cfunction
    raise NameError('no function %r' % (name,))
NameError: no function 'libvlc_media_list_player_get_media_player'

Clearly, the problem is that libvlc_media_list_player_get_media_player doesn't seem to exist. Has that not been implemented? Was it implemented and then its name changed?

When call `tracks_get`, error `AttributeError: module 'ctypes' has no attribute 'mediaTrack_pp'` occurs.

Hello~
Thanks for awesome works.
When call tracks_get, error AttributeError: module 'ctypes' has no attribute 'mediaTrack_pp' occurs.
Obviously, there is no ctypes.mediaTrack_pp.
I`m not good at ctypes. So can you check this?
Thank you.
Cheers.

sample code

SOURCE = "0.mp4"

import time
import vlc
vlc.libvlc_get_version()
Instance = vlc.Instance('--vout dummy --aout dummy')
player = Instance.media_player_new()
Media = Instance.media_new(SOURCE)
player.set_media(Media)
player.play()
player.get_state()

ms = vlc.MediaStats()
Media.get_stats(ms) and print(ms)

#wait for media open 10 seconds / (also, can use event)
for i in range(0,20):
    if Media.is_parsed():
        break
    time.sleep(0.5)
Media.tracks_get()    

exception

/Users/m/anaconda3/envs/watch_diff/lib/python3.5/site-packages/vlc.py in tracks_get(self)
   2110         mediaTrack_pp = ctypes.POINTER(MediaTrack)()
   2111         n = libvlc_media_tracks_get(self, ctypes.byref(mediaTrack_pp))
-> 2112         info = ctypes.cast(ctypes.mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n))
   2113         return info
   2114 

AttributeError: module 'ctypes' has no attribute 'mediaTrack_pp'

Get a snapshot of current video

Excuse me, I am wondering if there is any possibility to get a snapshot of current video(Webcam or Ipcam)
without use MediaPlayer?

Player State Error not captured with VLC 3.0.0

I am experimenting the (beta) 3.0.0 version of VLC with this (cool) Python wrapper.

When an error occurs (eg: file not found, file empty), player.get_state() (with player = vlc.Instance().media_player_new()) is never equal to vlc.State.Error, but to vlc.State.Ended instead.

Maybe the error is on vlc 3.0.0's side, but...

add_slave Media_Player and slaves_add Media

psz_uri = ''
try:
self.media_player.add_slave('mySrt.srt', psz_uri, True)
except Exception as e:
print('{}: {}'.format(type(e), e))
<class 'NameError'>: no function 'libvlc_media_player_add_slave'`

Function libvlc_video_set_adjust_float produces no changes

Using commands such as:

vlc.libvlc_video_set_adjust_float(p, 2, 0)

Do not alter the brightness, nor have I been able to alter any of the other VideoAdjustOption variables.

I've tried several permutations of the command, for instance:

vlc.libvlc_video_set_adjust_int(p, 0, True)
vlc.libvlc_video_set_adjust_float(p, 2, 200)

The first command (of which I tried variations) was an attempt to set "Enable" to true, but it doesn't seem to make a difference.

I've also tried

vlc.libvlc_video_set_adjust_float(p, 'Brightness', 0)

To no effect.

Is there an error in my syntax or perhaps a bug in the code?

Can't reset the media without re-initializing the media player

Hi,

I want to use the event manager to play the next item of a list but only the first item is being played,
to get the rest of the list to play i need to re initialize the media player object every time I set the new media

import vlc
import time

class player:
	def __init__(self):
		self.items = ['/home/mohammad/foo.wav',
		'/home/mohammad/bar.wav',
		'/home/mohammad/egg.wav']
		self.libvlc_Instance = vlc.Instance('--verbose 2')
		self.libvlc_player = self.libvlc_Instance.media_player_new()

	def play_next(self,num):
		self.play_item(num)

	def play_item(self,num=0):
		print(num)

		self.libvlc_player_event_manager = self.libvlc_player.event_manager()
		self.libvlc_list_player = self.libvlc_Instance.media_list_player_new()
		self.libvlc_Media_list = self.libvlc_Instance.media_list_new()
		self.libvlc_list_player.set_media_player(self.libvlc_player)
		media=self.libvlc_Instance.media_new(self.items[num])
		self.libvlc_Media_list.add_media(media)
		self.libvlc_list_player.set_media_list(self.libvlc_Media_list)
		self.libvlc_list_player.play_item(media)
		if num < len(self.items)-1:
			self.libvlc_player_event_manager.event_attach(
				vlc.EventType.MediaPlayerEndReached, lambda event :self.play_next(num+1))

	def is_playing(self):
		if self.libvlc_player.get_state()==vlc.State.Opening or self.libvlc_player.get_state()== vlc.State.Playing:
			return True

mpl=player()
mpl.play_item(0)

while mpl.is_playing():
	time.sleep(1)

so the above code plays the first item and then exits, but if i move the line where i create the media player object to inside the play_item function (so the object get's created every time) the code wil work and items will be played sequentially, like so:

import vlc
import time

class player:
	def __init__(self):
		self.items = ['/home/mohammad/foo.wav',
		'/home/mohammad/bar.wav',
		'/home/mohammad/egg.wav']
		self.libvlc_Instance = vlc.Instance('--verbose 2')


	def play_next(self,num):
		self.play_item(num)

	def play_item(self,num=0):
		print(num)
		self.libvlc_player = self.libvlc_Instance.media_player_new()
		self.libvlc_player_event_manager = self.libvlc_player.event_manager()
		self.libvlc_list_player = self.libvlc_Instance.media_list_player_new()
		self.libvlc_Media_list = self.libvlc_Instance.media_list_new()
		self.libvlc_list_player.set_media_player(self.libvlc_player)
		media=self.libvlc_Instance.media_new(self.items[num])
		self.libvlc_Media_list.add_media(media)
		self.libvlc_list_player.set_media_list(self.libvlc_Media_list)
		self.libvlc_list_player.play_item(media)
		if num < len(self.items)-1:
			self.libvlc_player_event_manager.event_attach(
				vlc.EventType.MediaPlayerEndReached, lambda event :self.play_next(num+1))

	def is_playing(self):
		if self.libvlc_player.get_state()==vlc.State.Opening or self.libvlc_player.get_state()== vlc.State.Playing:
			return True

mpl=player()
mpl.play_item(0)

while mpl.is_playing():
	time.sleep(1)

So why can't I use the same media player and change the media ?!

Python Bindings newbie

Hello,
I started with Python Bindings for the first time with:
operating system- ubuntu 14.04
vlc-1.1.2 and python-2.7.6
Here is the sample code I am working on

`

import vlc 
instance = vlc.Instance()
media_ply = instance.media_player_new()
media_ply.set_mrl("test1.mp3")
media_ply.play()

`
When I execute this code I get the error message as

`

 Traceback (most recent call last):
 File "vlc1.py", line 3, in <module>
 instance = vlc.Instance()
 File "/home/ankita/env2/mmenv5/local/lib/python2.7/site-packages/vlc.py", line 1551, in __new__
 return libvlc_new(len(args), args)
 File "/home/ankita/env2/mmenv5/local/lib/python2.7/site-packages/vlc.py", line 3903, in libvlc_new
 ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
 File "/home/ankita/env2/mmenv5/local/lib/python2.7/site-packages/vlc.py", line 246, in _Cfunction
 raise NameError('no function %r' % (name,))
 NameError: no function 'libvlc_new'

`
Did I do something wrong?

Can't play mp3 file

Hi ,

I try to use vlc module to play mp3 file.
But have error message in below, anyone know why?
PS. use aplay to play wav file is fine.

python

Python 2.7.6 (default, Nov 16 2016, 11:18:53)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import vlc
i = vlc.Instance()
p = vlc.MediaPlayer()
p.set_media(i.media_new("/media/python_nfs/AlexaPi/src/resources/alexayes.mp3"))
p.play()
0
[005b4740] alsa audio output error: cannot estimate delay: Broken pipe
[005b4740] alsa audio output error: cannot estimate delay: Broken pipe
[005b4740] alsa audio output error: cannot estimate delay: Broken pipe
[005b4740] alsa audio output error: cannot estimate delay: Broken pipe
[005b4740] alsa audio output error: cannot estimate delay: Broken pipe
[005b4740] alsa audio output error: cannot estimate delay: Broken pipe
[005b4740] alsa audio output error: cannot estimate delay: Broken pipe

Missing event for metadata change

While playing web radio stream there is no event issued indicating the change of Meta.NowPlaying which is usually track title. There is a workaround - attach callback for MediaPlayerTimeChanged and call media.get_meta(Meta.NowPlaying). But this is unnecessary polling.

how to put this VLC embedded into grid for show many screen in python

i read example code, the instance open a new window , but not embedded to grid,

it seems that there is grid attribute

import vlc
from Tkinter import *
import os
import sys
import ttk

import Tkinter as tk

class SampleApp(tk.Frame):
    def __init__(self, parent, title=None):
        #def __init__(self, *args, **kwargs):
        #tk.Tk.__init__(self, *args, **kwargs)        
        tk.Frame.__init__(self, parent)
        self.parent = parent
        self.parent.title("video")
        self.player = None
        self.Instance = vlc.Instance('--no-audio')
        self.player = self.Instance.media_player_new()
        #self.player.set_xwindow(ttk.Frame(self.parent).winfo_id())
        p=self.Instance.media_player_new()
        m=self.Instance.media_new('file:///home/martin/Downloads/autoweb.mp4')
        p.set_media(m)
        p.play()
        #self.videopanel = 
        #p=vlc.MediaPlayer('file:///home/martin/Downloads/autoweb.mp4')
        #p.play()
        self.register(self, parent)
        #self.player.grid(row=1,column=1)
    
    #def GetHandle(self):
        #return self.videopanel.winfo_id()

root = Tk()
for r in range(2):
    for c in range(1):
        termf = Frame(root, height=200, width=300)
        termf.pack(fill=BOTH, expand=YES)
        wid = termf.winfo_id()
        #player = Player()
        SampleApp(root, title="tkinter vlc").grid(row=r,column=c)
        #os.system('xterm -into %d -geometry 40x20 -sb &' % wid)
        #os.system('vlc --no-fullscreen "file:///home/martin/Downloads/autoweb.mp4" -into %d -geometry 100x200 -sb &' % wid)

root.mainloop()

wxplayer example errors

Hello,
I am running python 3.5.2 on windows 10. VLC version 2.2.4 Weatherwax.
Tried out your wxplayer example but didn't work so well.
The audio files come through but the video doesn't. The following error pops up:

core video output error: video output creation failed
core decoder error: failed to create video output

Any ideas? I imagine it has something to do with the type of video output

log methods signature mismatch

Version: 1dd9bf6
Python 2.7.6
Ubuntu 14.04 (LTS)

Generated vlc.py (tried both the one available in /generated/ dir and the one re-created by generate.py script) contains method definitions:
https://github.com/oaubert/python-vlc/blob/master/generated/vlc.py#L1841
https://github.com/oaubert/python-vlc/blob/master/generated/vlc.py#L4402

that do not match actual library signature: http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__log.html#ga67e824ebbd01c037fd877fba5fa4131c

and do not match the code:
https://github.com/oaubert/python-vlc/blob/master/generated/vlc.py#L4398-L4399

Actual params: (cb, data, p_instance)
Expected params: (p_instance, cb, data)

Automaticaly accept new certificate (and add them to VLC)

Symptoms
I was trying to open a youtube video into the python-vlc lib. But to achieve that I get the direct stream url from google which look like:

https://r1---sn-n4g-jqbl.googlevideo.com/videoplayback?requiressl=yes&lmt=1523380160555008&itag=22&key=yt6&ip=77.136.17.225&dur=685.267&ratebypass=yes&sparams=dur,ei,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire&source=youtube&id=o-ALAAmkgmLk2GaUtdlTX0Wyoy2BbHMYWHN_tGdES895WP&c=WEB&mm=31,29&mn=sn-n4g-jqbl,sn-25glenes&pl=16&mime=video/mp4&fvip=2&expire=1523417206&signature=4FC8D51BCF1FD50D5B746C8AFA7AC1B30A3A10EA.47CF7A7AFF72B5855C05836DF3D13A86A52C55A0&ei=FizNWs3yAomF0wXlybGQAg&ipbits=0&ms=au,rdu&mt=1523395509&initcwndbps=692500&mv=m

And I had trouble with gnutls security checking. I had the following log:

0x7ff924050de8] gnutls tls session error: Certificate verification failure (0x0042)
[0x7ff924050de8] gnutls tls session error:  * Certificate not verified
[0x7ff924050de8] gnutls tls session error:  * Signer not found
[0x7ff924050de8] main tls session error: TLS client session handshake error
[0x7ff9240011a8] access_http access error: cannot establish HTTP/TLS session
[0x23689f8] main input error: open of `https://r1---sn-n4g-jqbl.googlevideo.com/videoplayback?requiressl=yes&lmt=1523380160555008&itag=22&key=yt6&ip=77.136.17.225&dur=685.267&ratebypass=yes&sparams=dur,ei,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire&source=youtube&id=o-ALAAmkgmLk2GaUtdlTX0Wyoy2BbHMYWHN_tGdES895WP&c=WEB&mm=31,29&mn=sn-n4g-jqbl,sn-25glenes&pl=16&mime=video/mp4&fvip=2&expire=1523417206&signature=4FC8D51BCF1FD50D5B746C8AFA7AC1B30A3A10EA.47CF7A7AFF72B5855C05836DF3D13A86A52C55A0&ei=FizNWs3yAomF0wXlybGQAg&ipbits=0&ms=au,rdu&mt=1523395509&initcwndbps=692500&mv=m' failed
[0x23689f8] main input error: Your input can't be opened
[0x23689f8] main input error: VLC is unable to open the MRL 'https://r1---sn-n4g-jqbl.googlevideo.com/videoplayback?requiressl=yes&lmt=1523380160555008&itag=22&key=yt6&ip=77.136.17.225&dur=685.267&ratebypass=yes&sparams=dur,ei,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire&source=youtube&id=o-ALAAmkgmLk2GaUtdlTX0Wyoy2BbHMYWHN_tGdES895WP&c=WEB&mm=31,29&mn=sn-n4g-jqbl,sn-25glenes&pl=16&mime=video/mp4&fvip=2&expire=1523417206&signature=4FC8D51BCF1FD50D5B746C8AFA7AC1B30A3A10EA.47CF7A7AFF72B5855C05836DF3D13A86A52C55A0&ei=FizNWs3yAomF0wXlybGQAg&ipbits=0&ms=au,rdu&mt=1523395509&initcwndbps=692500&mv=m'. Check the log for details.

To fix my problem I had to open the video in VLC, And accept the security certificate. Then the video was able to run into python-vlc

Question: Is there a way to automatically accept certificate? Or at least ask to the user if it can accept the new certificate. And then add to the VLC certificate base.

Cannot parse a media

My purpose

is to get an audio file length without using the vlc player (because it may be playing another file).

So I want to parse the media, so I can call get_duration (without parsing, it returns -1, as expected).

But:

My config

VLC version 2.2.4 Weatherwax (2.2.4-0-g888b7e89)
Windows 8
Compiler: gcc version 4.9.2

Python 2.7.13

vlc.py: version = "N/A"
build_date = "Wed Mar 1 18:03:15 2017"

A sample of code to ease

import vlc
i = vlc.Instance()
media = i.media_new("C:\\a.flac")
media.get_duration()
-1L  

=> OK, because not parsed yet

media.parse() 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Media' object has no attribute 'parse'

=> "OK", not in the bindings.

media.parse_with_options(0, 0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "vlc.py", line 2455, in parse_with_options
    return libvlc_media_parse_with_options(self, parse_flag, timeout)
  File "vlc.py", line 5224, in libvlc_media_parse_with_options
    ctypes.c_int, Media, MediaParseFlag, ctypes.c_int)
  File "vlc.py", line 254, in _Cfunction
    raise NameError('no function %r' % (name,))
NameError: no function 'libvlc_media_parse_with_options'

=> Why? And how to parse the media to have its duration.

Many thanks

For this python binding and all your work (API doc, ...) it's so easy to play music. Thanks guys!

Cannot import vlc after installing VLC 3.0.0

After I install the vlc 3.0.0 on ubuntu, an error occur when I try to import vlc

>>> import vlc
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/vlc.py", line 112, in find_lib
    dll = ctypes.CDLL(p)
  File "/usr/lib/python3.5/ctypes/__init__.py", line 347, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/libvlc.so.5: undefined symbol: libvlc_MetaRequest

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/vlc.py", line 173, in <module>
    dll, plugin_path  = find_lib()
  File "/usr/local/lib/python3.5/dist-packages/vlc.py", line 114, in find_lib
    dll = ctypes.CDLL('libvlc.so.5')
  File "/usr/lib/python3.5/ctypes/__init__.py", line 347, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/libvlc.so.5: undefined symbol: libvlc_MetaRequest
>>> 

but the vlc 2.2.2 works well with me, any idea why it happens?

segfault on garbage collector

I'm building a software for on stage performance and I use vlc pyhton binding to play 2 synchronised videos and switch from a media to an other with a websocket interface.

https://github.com/davidonet/cas1soft/tree/master/server

I use callback to methods to get position and mediaend reached
I got segfault on media change after a few minute

Program received signal SIGSEGV, Segmentation fault.
0x0000003fc9a05cd1 in ffi_closure_unix64_inner () from /usr/lib64/libffi.so.5

I've investigated the problem and found this info : JohannesBuchner/PyMultiNest#5

So I tried a case that "segfault" all the time

player.pause()
gc.collect()
player.pause()

leads to segfault in libvlc

The workaround I found is to

  • deactivate automatic garbage collector
  • call gc.collect() after player.stop() and before player.set_media(...)

https://github.com/davidonet/cas1soft/blob/master/server/cas1server.py#L88

Consistant segmentation faults for vlc.Media.set_meta()

I've encountered segmentation faults while trying to set AlbumArtist, DiscNumber, and DiscTotal.

python-vlc (master) » python3                                ~/Dev/python-vlc  
Python 3.5.1+ (default, Mar 30 2016, 22:46:26) 
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import vlc
>>> m = vlc.Media("file://./assets/ChopinOp9No2.mp3")
>>> m.set_meta(vlc.Meta.AlbumArtist, 'AlbumArtist')
[1]    15685 segmentation fault  python3
>>> import vlc
>>> m = vlc.Media("file://./assets/ChopinOp9No2.mp3")
>>> m.set_meta(vlc.Meta.DiscNumber, 'DiscNumber')
[1]    15739 segmentation fault  python3
>>> import vlc
>>> m = vlc.Media("file://./assets/ChopinOp9No2.mp3")
>>> m.set_meta(vlc.Meta.DiscTotal, 'DiscTotal')
[1]    15555 segmentation fault  python3

how to debug

Hi ,

I porting vlc library to mips platform and use vlc.py to test.
But have some error.

python vlc.py

Usage: vlc.py [options] <movie_filename>
Once launched, type ? for help.

Build date: Fri Oct 7 12:04:48 2016 (0x0)
Error: no function 'libvlc_get_version'

Could any one suggest me how to debug?
I have confirm libvlc.so have libvlc_get_version function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.