I run this:
import vlc
import time
player = vlc.MediaPlayer('rtsp://NNNNNNNNNNNNNN')
player.play()
period = 2 # Every 2 seconds I got new screenshot from camera
while True:
time.sleep(period)
player.video_take_snapshot(0, 'screenshot-tmp.png', 0, 0)
Once I delete player.play() - it does not work anymore. No screenshoots.
What the problem?
I don't need to open VLC player, just need to taking screens and work with them
Try creating your
playerthis way:(based on this)
You can't remove
player.play()because this call is required for the media to start actually playing.How the code above works? To get rid of the GUI we can use the
--voutVLC CLI argument described in the docs as a way to control the video output method. We choose a special one –vdummy– so the video output is faked.CLI-like arguments can be provided when a "libvlc instance" is created, so we do it manually (otherwise you had the default one created automatically, without the
--vout=vdummy).Then
media_player_new(uri)creates a newMediaPlayerobject off that "libvlc instance". It can be used like any otherMediaPlayer, but its behavior will be affected by the CLI args we provided to theInstance.