This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: OpenCV decode issue

Part Number: AM5728


Tool/software: Linux

Hi,

We are going to use opencv API capture() to decode such as .avi or .mp4 in our OPENCV project.

But the performance is bad .Such as 1024x768 avi will take about 30ms to decode 1 frame.

Is there any other efficient ways to decode video ?

  • Hello,

    I am not aware with openCV but gstreamer could be use for decoding avi or mp4 format.
    Here is the multumedia user guide:
    processors.wiki.ti.com/.../Processor_Training:_Multimedia
    Here is example pipelines of avi decoding for example:
    gst-launch-1.0 filesrc location=test.avi ! avidemux ! h264parse ! video/x-h264, stream-format=byte-stream ! ducatih264dec ! vpe ! video/x-raw, format=NV12, width=1280, height=720 ! waylandsink

    BR
    Margarita
  • Hello,

    In additional, we have viddec3test demo also.

    BR
    Margarita
  • Hi,

    Thanks for your reply.

    I know about Gstreamer . But I'm confused about how to use gstreamer in our OPENCV project ? Is there any demo about : gstreamer  ----> opencv  ?

    I have tried to use dmabuftest to capture frames from V4L2 to our OPENCV project.

    I tried to transfer the buffer pointer from v4l2 to opencv Mat class.And use imshow() to display it .

    But the performance is badly than use cv::videocapture .

  • Hello,

    As I said I am not aware with Opencv but it seems that gstreamer pipeline could be open by VideoWriter.
    Hope this helps.

    BR
    Margarita
  • Please check this link 

    Let me know if this helps. If not, I will suggest processing using V4L2, viddec and DRM APIs. 

  • Hi, 

    Thanks for your reply.

    After reference the test.

    I changed my opencv to:

    VideoCapture capture("filesrc location=17.mp4 ! qtdemux ! mpeg4videoparse ! ducatimpeg4dec ! vpe ! 'video/x-raw, format=(string)NV12, width=(int)1024, height=(int)768' ! appsink",CAP_GSTREAMER);

    capture.read(frame);

    imshow("Video", frame);

    Here is the log:

    (VideoCapture:1433): GStreamer-CRITICAL **: gst_element_make_from_uri: assertion 'gst_uri_is_valid (uri)' failed

    (VideoCapture:1433): GLib-GObject-WARNING **: invalid cast from 'GstAppSink' to 'GstBin'

    (VideoCapture:1433): GStreamer-CRITICAL **: gst_bin_iterate_elements: assertion 'GST_IS_BIN (bin)' failed

    (VideoCapture:1433): GStreamer-CRITICAL **: gst_iterator_next: assertion 'it != NULL' failed

    (VideoCapture:1433): GStreamer-CRITICAL **: gst_iterator_free: assertion 'it != NULL' failed


    OpenCV Error: Unspecified error (GStreamer: cannot find appsink in manual pipeline
    ) in cvCaptureFromCAM_GStreamer, file /home/gtbldadm/processor-sdk-linux-morty-build/build-CORTEX_1/arago-tmp-external-linaro-toolchain/work/am57xx_evm-linux-gnueabi/opencv/3.1+gitAUTOINC+4458601eb2-r3.tisdk0/git/modules/videoio/src/cap_gstreamer.cpp, line 757
    terminate called after throwing an instance of 'cv::Exception'
    what(): /home/gtbldadm/processor-sdk-linux-morty-build/build-CORTEX_1/arago-tmp-external-linaro-toolchain/work/am57xx_evm-linux-gnueabi/opencv/3.1+gitAUTOINC+4458601eb2-r3.tisdk0/git/modules/videoio/src/cap_gstreamer.cpp:757: error: (-2) GStreamer: cannot find appsink in manual pipeline
    in function cvCaptureFromCAM_GStreamer

    "GStreamer: cannot find appsink in manual pipeline" show there is no appsink pipline.So what I should add to last pipline in capture("xxx").

    I have check the command "gst-launch-1.0 -v filesrc location=17.mp4 ! qtdemux ! mpeg4videoparse ! ducatimpeg4dec ! vpe ! 'video/x-raw, format=(string)NV12, width=(int)1024, height=(int)768' ! vpe num-input-buffers=8 ! queue ! waylandsink" is work well.

  • Thanks for reply

    I found Makefile in the /build.

    I will try to use viddec3test first .

    But I still want to know how to use gstreamer in opencv.

    Best Regards

  • Hello,

    Try this command :
    MACHINE=am57xx-evm bitbake omapdrmtest --force -c compile
    You could find more information in here chapter Forced Re-compilation:
    processors.wiki.ti.com/.../Processor_SDK_Building_The_SDK

    BR
    Margarita
  • Hello,

    I am closing this thread. Please for new question/issue open a new one.

    BR
    Margarita