oaubert / python-vlc

Python vlc bindings
GNU Lesser General Public License v2.1
381 stars 108 forks source link

Lag + Errors When Opening Video File and Skipping Video Playback Position #241

Open hhaudio opened 1 year ago

hhaudio commented 1 year ago

Hi, I'm working on a project making a semi-randomized video player on the Raspberry Pi 4 (64-bit OS with Desktop) using Python-VLC. I have a proof of concept working, but I get some strange error messages whenever I open a new video file or skip the playback position.

Here is the error when a new file is opened:

    [0000007f680013e0] mmal_xsplitter vout display error: Failed to open Xsplitter:opengles2 module
    [0000007f680013e0] mmal_xsplitter vout display error: Failed to open Xsplitter:mmal_vout module
    [0000007f6c013b10] avcodec decoder: Using DRM Video Accel for hardware decoding

Here is the error when I skip playback position:

    [0000007f6c013b10] main decoder error: Timestamp conversion failed for 315848867: no reference clock
    [0000007f6c013b10] main decoder error: Could not convert timestamp 0 for FFmpeg

The program seems to work in spite of these, but there's some minor lag I'd like to get rid of, and I want to make sure a problem doesn't arise from these errors piling up since I plan on running this program continuously for long periods of time.

Can anyone help explain what these errors mean and how I can get rid of them?

Here is the code I am using:

import vlc
import RPi.GPIO as GPIO
import time
import pygame
import random

def mute():
    media_player.get_media_player().audio_set_volume(0)

opin = 2
ipin = 4

pos = [0, 0]
index = 0

GPIO.setmode(GPIO.BCM)
GPIO.setup(opin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(ipin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

player = vlc.Instance("--no-xlib")

media_player = player.media_list_player_new()

media_list = player.media_list_new()

media = player.media_new("/home/hhaudio/Desktop/Malice.mp4")
media_list.add_media(media)

media = player.media_new("/home/hhaudio/Desktop/Croc.mp4")
media_list.add_media(media)

media_player.set_media_list(media_list)
media_player.play_item_at_index(0)

mute()

print("hello!")

nextvid = 1

while True:

    if GPIO.input(opin) == 0:
        print("exit")
        exit()
        break
    if GPIO.input(ipin) == 0 and nextvid == 1:
        print("ipin")
        media_player.get_media_player().set_position(random.random())
    nextvid = GPIO.input(ipin)
    time.sleep(0.001)
oaubert commented 1 year ago

This is not a python-vlc issue, since it also happens with other bindings (libvlc-go). Did you just do a web search? The first result I found is https://github.com/RPi-Distro/vlc/issues/30 which gave a possible solution.

hhaudio commented 1 year ago

I did a web search but the results I found were unhelpful. I actually found this exact post previously.

When I add --vout mmal_vout to the options the program fails altogether. I get an error: "main video output error: video output creation failed" "main decoder error: failed to create video output"

hhaudio commented 1 year ago

Apologies if this is the wrong place to bring up this issue. Is there a VLC repo where I should be bringing up this issue instead?