Skip to content

[BUG] video_set_format_callbacks cannot negotiate chroma #294

Description

@sxsong1207

I have struggled on this problem for about 1 day. I tried so hard on many ways, like this, but I still cannot make it use RV24 chroma.

@vlc.CallbackDecorators.VideoSetupCb  
def setup_cb(opaque, chroma, width, height, pitch, lines):
    _ctx = ct.cast(opaque, ct.POINTER(VideoContext)).contents
    
    w = width.contents.value
    h = height.contents.value
    
    # Try to negotiate RV24
    requested_chroma = b'RV24'
    
    # Check if RV24 is supported by trying to set it
    chroma.contents = ct.c_char_p(requested_chroma)
    
    # Configure for RV24
    pitch[0] = w * 3  # 3 bytes per pixel for RGB24
    lines[0] = h
    
    _ctx.width = w
    _ctx.height = h
    
    print(f"Negotiated format: {requested_chroma} {w}x{h}")
    return 1

When i compare the c api and python api. I noticed that, ctypes.c_char_p is interpreted by python with bytes class. With bytes, I cannot pass my message back to VLC. Thats why it doesn't know what I want.

    VideoFormatCb = ctypes.CFUNCTYPE(
        ctypes.c_uint,
        ctypes.POINTER(ctypes.c_void_p),
        ctypes.c_char_p,
        ctypes.POINTER(ctypes.c_uint),
        ctypes.POINTER(ctypes.c_uint),
        ctypes.POINTER(ctypes.c_uint),
        ctypes.POINTER(ctypes.c_uint),
    )

=> I have tried to modify the callback type, but unfortunately, it still not working as expected.

VideoFormatCb = ctypces.CFUNCTYPE(
        ctypes.c_uint,
        ctypes.POINTER(ctypes.c_void_p),
        ctypes.POINTER(ctypes.c_char),
        ctypes.POINTER(ctypes.c_uint),
        ctypes.POINTER(ctypes.c_uint),
        ctypes.POINTER(ctypes.c_uint),
        ctypes.POINTER(ctypes.c_uint),
    )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions