2

when i am trying to play a video with python-vlc in pyqt5 like

import vlc,sys
from PyQt5.QtWidgets import *
app = QApplication([])
window = QWidget()
window.resize(500,500)
window.show()
instance=vlc.Instance()
p=instance.media_player_new()
p.set_hwnd(window.winId())
p.set_media(instance.media_new(path_to_media))
p.play()

sys.exit(app.exec_()) 

It prints lot of errors in console like

[032ac2b0] direct3d11 vout display error: Direct3D11 could not be opened
[032ac2b0] direct3d11 vout display error: SetThumbNailClip failed: 0x800706f4
[0325de20] d3d11va generic error: D3D11CreateDevice failed. (hr=0x80004001)
[0325de20] d3d11va generic error: Failed to create device
[032ac2b0] direct3d9 vout display error: SetThumbNailClip failed: 0x800706f4
[032ad4f8] direct3d11 vout display error: Could not Create the D3D11 device. (hr=0x80004001)
[032ad4f8] direct3d11 vout display error: Direct3D11 could not be opened
[032ad4f8] direct3d11 vout display error: SetThumbNailClip failed: 0x800706f4
[0325e3c0] dxva2 generic error: FindVideoServiceConversion failed
[032ad4f8] direct3d9 vout display error: SetThumbNailClip failed: 0x800706f4
[032acee0] direct3d11 vout display error: Could not Create the D3D11 device. (hr=0x80004001)
[032acee0] direct3d11 vout display error: Direct3D11 could not be opened
[032acee0] direct3d11 vout display error: SetThumbNailClip failed: 0x800706f4

I want to capture one line from all those printed error.and that process has to run all time.cause i dont know when the error line will print. Is there any way ,that i can detect detect?

Edit For Review

I have successfully implemented what discussed in that forum and got the result after little bit modification.Here is the code

import vlc,sys
from PyQt5.QtWidgets import *
import ctypes


# Prepare `vsnprintf` function
if sys.platform.startswith('win'):
    # Note: must use same version of libc as libvlc
    vsnprintf = ctypes.cdll.msvcrt.vsnprintf
else:
    libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))
    vsnprintf = libc.vsnprintf

vsnprintf.restype = ctypes.c_int
vsnprintf.argtypes = (
    ctypes.c_char_p,
    ctypes.c_size_t,
    ctypes.c_char_p,
    ctypes.c_void_p,
)

# Your callback here
@vlc.CallbackDecorators.LogCb
def log_callback(data, level, ctx, fmt, args):
    # Skip if level is lower than warning
    if level < 3:
        return

    # Format given fmt/args pair
    BUF_LEN = 1024
    outBuf = ctypes.create_string_buffer(BUF_LEN)
    vsnprintf(outBuf, BUF_LEN, fmt, args)
    
    # Print it out, or do something else
    print('LOG: ' + outBuf.raw.replace(b"\x00",b"").decode())

# Set callback to the libvlc instance

app = QApplication([])
window = QWidget()
window.resize(500,500)
window.show()
instance=vlc.Instance()
instance.log_set(log_callback, None)
p=instance.media_player_new()
p.set_hwnd(window.winId())
p.set_media(instance.media_new(r"D:\Y2Mate.is - Starla Edney - Queen of Hearts (by Monoir) [Official Video]-o7c5LxzmZvs-480p-1636735291163.mp4"))
p.play()

sys.exit(app.exec_()) 

----OUTPUT-----
LOG: buffer too late (-95361 us): dropped
LOG: buffer too late (-73141 us): dropped
LOG: playback too late (74687): up-sampling
LOG: unsupported control query 3

But the problem arises when i use this inside a class because I want to use a pyqtsignal.

import vlc,sys,ctypes
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

class logPrinter(QObject):
    logerror=pyqtSignal() # I want to use a pyqtsignal after getting a specified error ,so i use Class
    def __init__(self):
        super().__init__()
    @vlc.CallbackDecorators.LogCb
    def log_callback(self,data, level, ctx, fmt, args):
    # Skip if level is lower than warning
        if level < 3:
            return
        # Format given fmt/args pair
        BUF_LEN = 1024
        outBuf = ctypes.create_string_buffer(BUF_LEN)
        vsnprintf(outBuf, BUF_LEN, fmt, args)
        
        # Print it out, or do something else
        print('LOG: ' + outBuf.raw.replace(b"\x00",b"").decode())

    # Set callback to the libvlc instance
class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(500,500)
        instance=vlc.Instance()
        self.log_printer=logPrinter()
        instance.log_set(self.log_printer.log_callback, None)
        p=instance.media_player_new()
        p.set_hwnd(self.winId())
        p.set_media(instance.media_new(path_to_media))
        p.play()
app = QApplication([])
window = Window()
window.show()
sys.exit(app.exec_())

Video is playing but it generating error continuously

Exception ignored on calling ctypes callback function: <function logPrinter.log_callback at 0x02B7BCD0>
TypeError: log_callback() missing 1 required positional argument: 'args'
Exception ignored on calling ctypes callback function: <function logPrinter.log_callback at 0x02B7BCD0>
TypeError: log_callback() missing 1 required positional argument: 'args'
Exception ignored on calling ctypes callback function: <function logPrinter.log_callback at 0x02B7BCD0>
TypeError: log_callback() missing 1 required positional argument: 'args'

I think using that log_callback() inside class causing error for mismatch in method arguments/parameters.

8
  • Python is very friendly language, just open vlc module from site-packages and analyze how and where it prints errors, all you need to know is little bit of ctypes and common programming, and I think you know it already, since you're a hacker. Commented Apr 1, 2022 at 10:51
  • I checked but there is nothing. I think its coming from that libvlc.dll. Cause vlc module is not a concrete module its a wrapper only..So is there any other way to trace it from console...? Commented Apr 1, 2022 at 12:50
  • try libvlc_log_set Commented Apr 1, 2022 at 13:47
  • See this forum.videolan.org/viewtopic.php?f=32&t=131018 Commented Apr 1, 2022 at 14:05
  • thank u @musicamante ,@mugiseyebrows ,but there is a problem after implementing in class.I posted the error for your better understanding in my Original post. I will remove that after u got the point properly. Commented Apr 1, 2022 at 17:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.