BabitMF / bmf

Cross-platform, customizable multimedia/video processing framework. With strong GPU acceleration, heterogeneous design, multi-language support, easy to use, multi-framework compatible and high performance, the framework is ideal for transcoding, AI inference, algorithm integration, live video streaming, and more.
https://babitmf.github.io/
Apache License 2.0
773 stars 65 forks source link

RuntimeError: require false at /root/bmf/bmf/hml/src/imgproc/imgproc.cpp:154, Unsupport PixelInfo #54

Closed liujiachang closed 11 months ago

liujiachang commented 1 year ago

There was a problem when I used the bmf/test/generator/test_generator.py for read stream testing.

# bmf/test/generator/test_generator.py
for i, pkt in enumerate(pkts):
    # convert frame to a nd array
    if pkt.is_(bmf.VideoFrame):
        vf = pkt.get(bmf.VideoFrame)
        rgb = mp.PixelInfo(mp.kPF_RGB24)
        np_vf = vf.reformat(rgb).frame().plane(0).numpy()  # <------ RuntimeError: require false at /root/bmf/bmf/hml/src/imgproc/imgproc.cpp:154, Unsupport PixelInfo
        # we can add some more processing here, e.g. predicting
        print("frame", i, "shape", np_vf.shape)
    else:
        break

I also tried the method in the document, but it seems to be incorrect.

# https://babitmf.github.io/docs/bmf/multiple_features/graph_mode/generatemode/
for i, frame in enumerate(frames):
     # convert frame to a nd array
     if frame is not None:
         np_frame = frame.to_ndarray(format='rgb24')    # <------ AttributeError: 'bmf.lib._bmf.sdk.Packet' object has no attribute 'to_ndarray'

         # we can add some more processing here, e.g. predicting
         print('frame', i, 'shape', np_frame.shape)
     else:
         break

What is Unsupport PixelInfo? Or do I have any other methods to process the stream like OpenCV into video frames that can be read iteratively?

HuHeng commented 1 year ago

Sorry,the content in the documentation has expired. We will update it. It is possible that the issue is due to your input video source being in 10-bit format. You can try this approach if your bmf with ffmpeg enabled:

from bmf.lib._bmf.sdk import ffmpeg
np_vf = ffmpeg.reformat(vf, "rgb24").frame().plane(0).numpy()
liujiachang commented 1 year ago

I used your method to obtain the video frame, but the following warning occurred:

[swscaler @ 0x2e2aec0] deprecated pixel format used, make sure you did set range correctly.
[swscaler @ 0x2e2a240] No accelerated colorspace conversion found from yuv420p to bgr24.

Can I ignore it, or is there any way to fix it

HuHeng commented 1 year ago

I used your method to obtain the video frame, but the following warning occurred:

[swscaler @ 0x2e2aec0] deprecated pixel format used, make sure you did set range correctly.
[swscaler @ 0x2e2a240] No accelerated colorspace conversion found from yuv420p to bgr24.

Can I ignore it, or is there any way to fix it

Using the related pixelformat "yuvj420p" of ffmpeg can trigger the first warning, typically when encoding or decoding JPEG. The second warning may be due to the lack of ASM support of ffmpeg. Both warnings can be ignored.

liujiachang commented 1 year ago

How can I set ffmpeg -loglevel quiet in the code,I set bmf.Log.set_log_level(bmf.LogLevel.ERROR) but it didn't ignore these warning.

taoboyang commented 1 year ago

For the log from FFmpeg, please inject loglevel into the option of the module,as for:

    graph = bmf.graph()

    # decode
    video = graph.decode({
        "loglevel" : "quiet",
        "input_path": input_video_path
    })

For the log from BMF, it's set to INFO default, if you want to modify, please use the ENV: export BMF_LOG_LEVEL=WARNING/ERROR/FATAL/DISABLE