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: 1080p Capture using Gstreamer

Part Number: AM5728

Tool/software: Linux

Hi,

I am using AM571x EVM. Using processor SDK 05.01.00.11. I am using gst-launch1.0 to create gstreamer links to capture and display. I am able to capture 720p video using gstreamer using following command:

gst-launch-1.0 -v v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720' ! vpe num-input-buffers=8 ! queue ! kmssink


I am trying to capture 1080p video.

gst-launch-1.0 -v v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! vpe num-input-buffers=8 ! queue ! kmssink

But I am getting following error:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
../../../../gstreamer-1.12.2/libs/gst/base/gstbasesrc.c(2939): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.007080717
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

Should I configure v4l2 to capture 1080p. If required, what are the commands to configure it.

I tried changing the buffers in the above command but no use.

I tired to configure the v4l2 device using following command:

v4l2-ctl -d /dev/video1 --set-fmt-video=width=1920,height=1080,pixelformat='NV12'

I verified the camera and display using following command:

dmabuftest -s 35:1920x1080 -c 1920x1080@NV12 -d /dev/video1

Using above command I am able to capture and display 1080p video. How to do same thing using Gstreamer

Thanks and Regards,

Pranay kumar

  • Hello,

    kashetty pranay kumar said:
    ../../../../gstreamer-1.12.2/libs/gst/base/gstbasesrc.c(2939): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
    streaming stopped, reason not-negotiated (-4)

    From gstreamer point of view streaming task paused, reason not-negotiated (-4) most of the cases means that something is wrong with your caps filter.

    Please provide information about the video source like resolution, format, fps that it supports.

    You could add --gst-debug=2 to the pipeline and share the log.

    You could try to add framerate in the caps filter also .... ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080, framerate=(fraction)30/1' !...

    Please change the framerate value depending of what your video source supports.

    BR
    Margarita

  • Hi Margarita,

    Thanks for the info.

    I gave frame rate in caps filter. Still same issue. I gave gst-debug=2. Following is the log:

    # gst-launch-1.0 -v v4l2src device=/dev/video1 io-mode=4 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080, framerate=(fraction)30/1' ! vpe num-input-buffers=20 ! queue ! kmssink --gst-debug=2

    Setting pipeline to PAUSED ...
    Pipeline is live and does not need PREROLL ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    0:00:01.221123373 1155 0x166a00 WARN basesrc gstbasesrc.c:2939:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
    0:00:01.221207960 1155 0x166a00 WARN basesrc gstbasesrc.c:2939:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
    ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
    Additional debug info:
    ../../../../gstreamer-1.12.2/libs/gst/base/gstbasesrc.c(2939): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
    streaming stopped, reason not-negotiated (-4)
    Execution ended after 0:00:00.007172624
    Setting pipeline to PAUSED ...
    Setting pipeline to READY ...
    Setting pipeline to NULL ...
    Freeing pipeline ...

    Regards,
    Pranay kumar
  • Hello,

    Please provide information about your video source(resolution, format, fps that it supports).
    You could try this:
    gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! kmssink --gst-debug=v4l2src:3

    BR
    Margarita

  • Hello,

    Log the the given command is :

    # gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! kmssink --gst-debug=v4l2src:3
    Setting pipeline to PAUSED ...
    Pipeline is live and does not need PREROLL ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
    Additional debug info:
    ../../../../gstreamer-1.12.2/libs/gst/base/gstbasesrc.c(2939): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
    streaming stopped, reason not-negotiated (-4)
    Execution ended after 0:00:00.006339608
    Setting pipeline to PAUSED ...
    Setting pipeline to READY ...
    Setting pipeline to NULL ...
    Freeing pipeline ...

    As for the camera info, I dont have the camera info right now. But I verified camera capabilities using dmabuftest.

    dmabuftest -s 35:1920x1080 -c 1920x1080@NV12 -d /dev/video1

    Using above command, 1080p video is being captured and displayed over HDMI.

    Regards,
    Pranay kumar
  • Hello,

    kashetty pranay kumar said:
    v4l2-ctl -d /dev/video1 --set-fmt-video=width=1920,height=1080,pixelformat='NV12'


    Are you using a usb camera? I don't think gst takes the config from v4l2-ctl setting.

    kashetty pranay kumar said:
    dmabuftest -s 35:1920x1080 -c 1920x1080@NV12 -d /dev/video1


    Do you see any green on display?

    kashetty pranay kumar said:


    gst-launch-1.0 -v v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720' ! vpe num-input-buffers=8 ! queue ! kmssink


    I am trying to capture 1080p video.

    gst-launch-1.0 -v v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! vpe num-input-buffers=8 ! queue ! kmssink




    The both pipelines seems fine they should work if your video source supports the resolutions and format. But since the first one is working with NV12, I guess the resolution is wrong.
    Please verify that your camera supports 1080p.

    Share the output of this yavta -c20 -fNV12 -F/dev/null -s1920x1080 /dev/video1


    BR

    Margarita
  • Margarita Gashova said:
    Are you using a usb camera? I don't think gst takes the config from v4l2-ctl setting.

    I am not using USB camera. I am working on AM571x Industrial Development kit. Using the camera provided with the kit. Yes, the camera supports 1080p resolution.

    Margarita Gashova said:
    Do you see any green on display?

    No I am not seeing any green display. I am using dmabuftest command to capture 720 and 1080p resolutions. I can visually see the difference. Camera is definitely capable of 1080p capture.

    Margarita Gashova said:
    Share the output of this yavta -c20 -fNV12 -F/dev/null -s1920x1080 /dev/video1

    Output of above command:

    # yavta -c20 -fNV12 -F/dev/null -s1920x1080 /dev/video1
    Device /dev/video1 opened.
    Device `vip' on `platform:vip' is a video output (without mplanes) device.
    Video format set: NV12 (3231564e) 1920x1080 (stride 1920) field none buffer size 3110400
    Video format: NV12 (3231[ 3255.253512] cma: cma_alloc: alloc failed, req-size: 760 pages, ret: -12
    564e) 1920x1080 (stride 1920) field none buffer size 3110400
    [ 3255.263619] vip 48970000.vip: dma_alloc_coherent of size 3112960 failed
    7 buffers requested.
    length: 3110400 offset: 0 timestamp type/source: mono/EoF
    Buffer 0/0 mapped at address 0xb6b57000.
    length: 3110400 offset: 3112960 timestamp type/source: mono/EoF
    Buffer 1/0 mapped at address 0xb685f000.
    length: 3110400 offset: 6225920 timestamp type/source: mono/EoF
    Buffer 2/0 mapped at address 0xb6567000.
    length: 3110400 offset: 9338880 timestamp type/source: mono/EoF
    Buffer 3/0 mapped at address 0xb626f000.
    length: 3110400 offset: 12451840 timestamp type/source: mono/EoF
    Buffer 4/0 mapped at address 0xb5f77000.
    length: 3110400 offset: 15564800 timestamp type/source: mono/EoF
    Buffer 5/0 mapped at address 0xb5c7f000.
    length: 3110400 offset: 18677760 timestamp type/source: mono/EoF
    Buffer 6/0 mapped at address 0xb5987000.
    0 (0) [-] top 0 3110400 B 3255.491798 3255.491833 4.908 fps ts mono/EoF
    1 (1) [-] top 1 3110400 B 3255.560474 3255.560510 14.561 fps ts mono/EoF
    2 (2) [-] top 2 3110400 B 3255.629149 3255.629198 14.561 fps ts mono/EoF
    3 (3) [-] top 3 3110400 B 3255.697822 3255.697853 14.562 fps ts mono/EoF
    4 (4) [-] top 4 3110400 B 3255.766497 3255.766542 14.561 fps ts mono/EoF
    5 (5) [-] top 5 3110400 B 3255.835175 3255.835226 14.561 fps ts mono/EoF
    6 (6) [-] top 6 3110400 B 3255.903848 3255.903878 14.562 fps ts mono/EoF
    7 (0) [-] top 7 3110400 B 3255.972523 3255.972554 14.561 fps ts mono/EoF
    8 (1) [-] top 8 3110400 B 3256.041201 3256.041234 14.561 fps ts mono/EoF
    9 (2) [-] top 9 3110400 B 3256.109874 3256.109909 14.562 fps ts mono/EoF
    10 (3) [-] top 10 3110400 B 3256.178552 3256.178601 14.561 fps ts mono/EoF
    11 (4) [-] top 11 3110400 B 3256.247229 3256.247272 14.561 fps ts mono/EoF
    12 (5) [-] top 12 3110400 B 3256.315900 3256.315940 14.562 fps ts mono/EoF
    13 (6) [-] top 13 3110400 B 3256.384578 3256.384617 14.561 fps ts mono/EoF
    14 (0) [-] top 14 3110400 B 3256.453250 3256.453282 14.562 fps ts mono/EoF
    15 (1) [-] top 15 3110400 B 3256.521930 3256.521968 14.560 fps ts mono/EoF
    16 (2) [-] top 16 3110400 B 3256.590601 3256.590646 14.562 fps ts mono/EoF
    17 (3) [-] top 17 3110400 B 3256.659280 3256.659319 14.560 fps ts mono/EoF
    18 (4) [-] top 18 3110400 B 3256.727952 3256.727992 14.562 fps ts mono/EoF
    19 (5) [-] top 19 3110400 B 3256.796627 3256.796656 14.561 fps ts mono/EoF
    Captured 20 frames in 1.508604 seconds (13.257288 fps, 41235468.650975 B/s).
    7 buffers released.

    From the log, Yavta is able to capture 1920x1080 frames from the input video source.

    Regards,

    Pranay kumar

  • Hello,

    Please share this also:
    yavta -c10 -fYUYV -F/dev/null -s1920x1080 /dev/video1

    BR
    Margarita
  • Hi,

    Margarita Gashova said:
    yavta -c10 -fYUYV -F/dev/null -s1920x1080 /dev/video1

    Output of above command:

    # yavta -c10 -fYUYV -F/dev/null -s1920x1080 /dev/video1
    Device /dev/video1 opened.
    Device `vip' on `platform:vip' is a video output (without mplanes) device.
    Video format set: YUYV (56595559) 1920x1080 (stride 3840) field none buffer size 4147200
    Video format: YUYV (5659[ 5592.650043] cma: cma_alloc: alloc failed, req-size: 1013 pages, ret: -12
    5559) 1920x1080 (stride 3840) field none buffer size 4147200
    [ 5592.660645] vip 48970000.vip: dma_alloc_coherent of size 4149248 failed
    5 buffers requested.
    length: 4147200 offset: 0 timestamp type/source: mono/EoF
    Buffer 0/0 mapped at address 0xb6a41000.
    length: 4147200 offset: 4149248 timestamp type/source: mono/EoF
    Buffer 1/0 mapped at address 0xb664c000.
    length: 4147200 offset: 8298496 timestamp type/source: mono/EoF
    Buffer 2/0 mapped at address 0xb6257000.
    length: 4147200 offset: 12447744 timestamp type/source: mono/EoF
    Buffer 3/0 mapped at address 0xb5e62000.
    length: 4147200 offset: 16596992 timestamp type/source: mono/EoF
    Buffer 4/0 mapped at address 0xb5a6d000.
    0 (0) [-] top 0 4147200 B 5592.820157 5592.820212 7.403 fps ts mono/EoF
    1 (1) [-] top 1 4147200 B 5592.888828 5592.888858 14.562 fps ts mono/EoF
    2 (2) [-] top 2 4147200 B 5592.957507 5592.957556 14.560 fps ts mono/EoF
    3 (3) [-] top 3 4147200 B 5593.026182 5593.026232 14.561 fps ts mono/EoF
    4 (4) [-] top 4 4147200 B 5593.094854 5593.094899 14.562 fps ts mono/EoF
    5 (0) [-] top 5 4147200 B 5593.163533 5593.163568 14.560 fps ts mono/EoF
    6 (1) [-] top 6 4147200 B 5593.232208 5593.232256 14.561 fps ts mono/EoF
    7 (2) [-] top 7 4147200 B 5593.300880 5593.300927 14.562 fps ts mono/EoF
    8 (3) [-] top 8 4147200 B 5593.369555 5593.369601 14.561 fps ts mono/EoF
    9 (4) [-] top 9 4147200 B 5593.438233 5593.438282 14.561 fps ts mono/EoF
    Captured 10 frames in 0.753204 seconds (13.276611 fps, 55060762.143948 B/s).
    5 buffers released.

    Thanks,

    Pranay

  • Hello,

    In the both yavta logs I see this : [ 3255.263619] vip 48970000.vip: dma_alloc_coherent of size 3112960 failed

    Please could you try to increase cma in bootarg. You could try to increase it to 128MB.

    First way to increase it is in uEnv.txt file.

    Second way is in u-boot
    => setenv optargs cma=128MiB
    => saveenv

    Then you could check the boot log you should see something like:
    cma: Reserved 128 MiB at 0x00000000f7c00000
    You could execute " cat /proc/cmdLine" to know the current CMA reservation, when the fs is loaded.

    After that please try these pipelines:

    gst-launch-1.0 v4l2src device=/dev/video1 io-mode=4 ! 'video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080' ! vpe num-input-buffers=8 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! fakesink

    gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! fakesink



    BR
    Margarita
  • Hi Margarita,

    I have increased the CMA size. Verified it using cat /proc/cmdline

    Still the above commands does n't work. Same error like the earlier command.


    # cat /proc/cmdline
    console=ttyO2,115200n8 cma=128MiB root=PARTUUID=72eff479-02 rw rootfstype=ext4 rootwait


    # gst-launch-1.0 v4l2src device=/dev/video1 io-mode=4 ! 'video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080' ! vpe num-input-buffers=8 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! fakesink
    Setting pipeline to PAUSED ...
    Pipeline is live and does not need PREROLL ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
    Additional debug info:
    ../../../../gstreamer-1.12.2/libs/gst/base/gstbasesrc.c(2939): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
    streaming stopped, reason not-negotiated (-4)
    Execution ended after 0:00:00.005711389
    Setting pipeline to PAUSED ...
    Setting pipeline to READY ...
    Setting pipeline to NULL ...
    Freeing pipeline ...


    # gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! fakesink
    Setting pipeline to PAUSED ...
    Pipeline is live and does not need PREROLL ...
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
    Additional debug info:
    ../../../../gstreamer-1.12.2/libs/gst/base/gstbasesrc.c(2939): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
    streaming stopped, reason not-negotiated (-4)
    Execution ended after 0:00:00.004295864
    Setting pipeline to PAUSED ...
    Setting pipeline to READY ...
    Setting pipeline to NULL ...
    Freeing pipeline ...

    Regards,
    Pranay kumar
  • Hello,

    But when you try yavta again is the vip: dma_alloc_coherent error disappear?
    Could you try to add framerate=(fraction)15/1 in the caps filter in both pipelines.

    As I said, this error v4l2src0:streaming stopped, reason not-negotiated (-4) something is not correct set in the capsfileter.

    BR
    Margarita
  • Hi,

    Yes the allocation error has gone.

    Tried reducing frame rate to 15. still same error. I think the problem is related to some buffers in gstreamer. Are there any buffer size to allocate or any special settings to work on 1080p streams using gstreamer ?

    Regards.
    Pranay
  • Hello,

    Check this thread:
    e2e.ti.com/.../626562
    and try to apply the patch manually. Let me know if this helps.

    BR
    Margarita
  • Hi Margarita,

    I will try applying the patch.

    I have other question.

    What is the encoding capabilites of AM5728. In the TRM it is mentioned as follows:

    • 4K @ 15fps encode and decode support for H.264 CODEC
    • Other CODECs up to 1080p60

    4kp15 encode and decode simultaneously or individual.

    My requirement needs simultaneous 1080p60 encode and decode. Is it possible with AM5728 ?


    Regards,
    Pranay
  • Hello,

    Please open a new topic about this question.

    BR
    Margarita
  • Hi Margarita,

    I downloaded the patch. But I am unable to download gstreamer software from the link given in the answer you have suggested. Where can I get gstreamer source code to apply patch.

    Given gstreamer link is: www.ti.com/.../gstreamer

    I am unable to download gstreamer using the Get software link

    Regards,
    Pranay kumar
  • Hello,

    V4l2src element is part of good plugin.
    MACHINE=am57xx-evm bitbake gstreamer1.0-plugins-good

    this is the command that you must use instead of MACHINE=am57xx-evm bitbake arago-base-tisdk-image as in the guide.

    Please follow these steps just replace the last one:
    software-dl.ti.com/.../Overview_Building_the_SDK.html
    Please do not forget to execute the command from "Prerequisites" chapter.

    BR
    Margarita
  • Hello,

    I am sorry I forgot in this guide please refer the chapter how to recompile after code modifications.

    BR
    Margarita
  • Hi Margarita,

    I have applied patch, compiled and generated new v4l2src ipk. Installed it. Still unable to get 1080p resolution using gstreamer. Still showing same issue.

    Regards,
    Pranay

  • Hello,

    Could you try this:
    gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=1000 io-mode=5 ! 'video/x-raw, format=(string)NV12, width=(int)1920, height=(int)1080' ! kmssink
    I would recommend you to increase the v4l2 debug level to 6.
    The error is related with the capsfilter and vl42src.

    BR
    Margarita