or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

audio-control.mdcore-playback.mddata-structures.mddiscovery-renderers.mdevent-system.mdindex.mdlow-level-functions.mdmedia-lists.mdvideo-control.md
tile.json

tessl/pypi-python-vlc

VLC bindings for Python providing comprehensive multimedia functionality through LibVLC API.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/python-vlc@3.0.x

To install, run

npx @tessl/cli install tessl/pypi-python-vlc@3.0.0

index.mddocs/

Python-VLC

Comprehensive Python ctypes-based bindings for LibVLC, enabling developers to embed video and audio playback functionality directly into Python applications. Python-VLC provides both high-level wrapper classes with pythonic APIs and low-level direct access to all LibVLC functions for advanced use cases.

Package Information

  • Package Name: python-vlc
  • Language: Python
  • Installation: pip install python-vlc
  • Version: 3.0.21203
  • LibVLC Version: 3.0.21

Core Imports

import vlc

All functionality is available through the vlc module namespace.

Basic Usage

Simple Media Player

import vlc

# Create a media player with a file
player = vlc.MediaPlayer('file:///path/to/video.mp4')
player.play()

# Control playback
player.pause()
player.stop()

# Get playback information
duration = player.get_length()  # in milliseconds
current_time = player.get_time()  # in milliseconds

Using Instance for Advanced Control

import vlc

# Create VLC instance with options
instance = vlc.Instance('--no-audio', '--quiet')

# Create media and player from instance
media = instance.media_new('file:///path/to/video.mp4')
player = instance.media_player_new()
player.set_media(media)

# Start playback
player.play()

# Access metadata
media.parse()
title = media.get_meta(vlc.Meta.Title)
duration = media.get_duration()

Event Handling

import vlc

def media_state_callback(event):
    print(f"Media state changed: {event.u.new_state}")

player = vlc.MediaPlayer()
event_manager = player.event_manager()
event_manager.event_attach(vlc.EventType.MediaPlayerMediaChanged, media_state_callback)

Architecture

Python-VLC provides a layered architecture for maximum flexibility:

  • High-level Wrapper Classes: Pythonic interface (Instance, MediaPlayer, Media, etc.)
  • Low-level Function Access: Direct access to all libvlc_* functions
  • Event System: Comprehensive event handling for media state changes
  • Cross-platform Support: Automatic library discovery on Linux, Windows, and macOS
  • UI Framework Integration: Examples for Qt, GTK, Tkinter, wxPython, and Cocoa

The wrapper classes provide convenient Python idioms while maintaining access to the full LibVLC API for advanced use cases.

Capabilities

Core Media Playback

Essential media playback functionality including media players, media objects, and basic playback control. These classes form the foundation for any media application.

class Instance:
    def __init__(self, *args): ...
    def media_player_new(self, uri=None): ...
    def media_new(self, mrl, *options): ...
    def media_new_path(self, path): ...

class MediaPlayer:
    def __init__(self, *args): ...
    def play(self): ...
    def pause(self): ...
    def stop(self): ...
    def set_media(self, media): ...
    def get_media(self): ...
    def get_time(self): ...
    def set_time(self, time): ...
    def get_length(self): ...
    def add_slave(self, i_type, psz_uri, b_select): ...  # LibVLC 3.0.0+
    def set_renderer(self, p_renderer): ...  # LibVLC 3.0.0+

class Media:
    def parse_with_options(self, parse_flag, timeout): ...  # LibVLC 3.0.0+ [RECOMMENDED]
    def get_parsed_status(self): ...  # LibVLC 3.0.0+
    def parse(self): ...  # [DEPRECATED - use parse_with_options]
    def get_meta(self, meta_type): ...
    def get_duration(self): ...
    def get_mrl(self): ...
    def slaves_add(self, i_type, i_priority, psz_uri): ...  # LibVLC 3.0.0+

Core Media Playback

Audio Control

Comprehensive audio control including volume, equalizer, audio tracks, and audio output device management.

# Audio control methods on MediaPlayer
def audio_get_volume(self): ...
def audio_set_volume(self, volume): ...
def audio_get_track(self): ...
def audio_set_track(self, track): ...
def audio_get_delay(self): ...
def audio_set_delay(self, delay): ...
def audio_output_device_get(self): ...  # LibVLC 3.0.0+

class AudioEqualizer:
    def __init__(self): ...
    def set_preamp(self, preamp): ...
    def get_preamp(self): ...
    def set_amp_at_index(self, amp, band): ...
    def get_amp_at_index(self, band): ...
    def release(self): ...

Audio Control

Video Control

Video control capabilities including video tracks, aspect ratio, cropping, subtitle management, video effects, and display settings.

# Video control methods on MediaPlayer
def video_get_width(self): ...
def video_get_height(self): ...
def video_get_aspect_ratio(self): ...
def video_set_aspect_ratio(self, ratio): ...
def video_get_crop_geometry(self): ...
def video_set_crop_geometry(self, geometry): ...
def video_take_snapshot(self, num, filepath, width, height): ...
def video_get_spu(self): ...
def video_set_spu(self, spu): ...
def video_set_subtitle_file(self, filename): ...

Video Control

Media Lists and Playlists

Media list management for creating and controlling playlists with sequential or custom playback modes.

class MediaList:
    def __init__(self, instance=None): ...
    def add_media(self, media): ...
    def insert_media(self, media, index): ...
    def remove_index(self, index): ...
    def count(self): ...
    def item_at_index(self, index): ...

class MediaListPlayer:
    def __init__(self, instance=None): ...
    def set_media_list(self, media_list): ...
    def play(self): ...
    def pause(self): ...
    def stop(self): ...
    def next(self): ...
    def previous(self): ...
    def set_playback_mode(self, mode): ...

Media Lists and Playlists

Event System

Comprehensive event handling system for responding to media state changes, playback events, and user interactions.

class EventManager:
    def event_attach(self, event_type, callback, user_data=None): ...
    def event_detach(self, event_type): ...

class EventType:
    MediaMetaChanged = ...
    MediaPlayerTimeChanged = ...
    MediaPlayerPositionChanged = ...
    MediaPlayerPlaying = ...
    MediaPlayerPaused = ...
    MediaPlayerStopped = ...
    # ... many more event types

Event System

Media Discovery and Renderers

Network media discovery, renderer discovery for casting, and media library management capabilities.

class MediaDiscoverer:
    def __init__(self, instance, service_name): ...
    def start(self): ...
    def stop(self): ...
    def media_list(self): ...

class RendererDiscoverer: 
    def start(self): ...
    def stop(self): ...
    def event_manager(self): ...
    def release(self): ...

class Renderer:
    def name(self): ...
    def type(self): ...
    def flags(self): ...
    def icon_uri(self): ...
    def hold(self): ...
    def release(self): ...

Media Discovery and Renderers

Low-Level LibVLC Functions

Direct access to all LibVLC C API functions for advanced use cases and maximum control.

# Core functions (400+ available in LibVLC 3.0)
def libvlc_new(argc, argv): ...
def libvlc_release(instance): ...
def libvlc_media_new_location(instance, mrl): ...
def libvlc_media_new_callbacks(instance, open_cb, read_cb, seek_cb, close_cb, opaque): ...  # 3.0.0+
def libvlc_media_player_play(player): ...
def libvlc_media_player_set_renderer(player, renderer): ...  # 3.0.0+
def libvlc_audio_set_volume(player, volume): ...
def libvlc_video_get_size(player, num): ...
def libvlc_renderer_discoverer_new(instance, service_name): ...  # 3.0.0+
# ... hundreds more libvlc_* functions

Low-Level LibVLC Functions

Data Structures and Enums

Complete type definitions, enumerations, and data structures used throughout the API.

class State:
    NothingSpecial = 0
    Opening = 1
    Buffering = 2
    Playing = 3
    Paused = 4
    Stopped = 5
    Ended = 6
    Error = 7

class Meta:
    Title = 0
    Artist = 1
    Genre = 2
    Copyright = 3
    Album = 4
    # ... more metadata types

class MediaType:
    Unknown = 0
    File = 1
    Directory = 2
    Disc = 3
    Stream = 4
    Playlist = 5

Data Structures and Enums