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: GStreamer encode pipeline can't set video framerate and bitrate

Part Number: AM5728


Tool/software: Linux

hello,

I used this command to capture and encode into a MP4 file from the website:. processors.wiki.ti.com/.../Processor_Training:_Multimedia

gst-launch-1.0 -e v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, 
format=(string)YUY2, width=(int)1280, height=(int)720, framerate=(fraction)30/1' ! vpe num-input-buffers=8 ! 
queue ! ducatimpeg4enc bitrate=4000 ! queue ! mpeg4videoparse ! qtmux ! filesink location=y.mp4

But the properties of the Mp4 file showed that its  framerate was 23.And the bitrate of the file was 4058 kbps.

However, when I used this command:

gst-launch-1.0 videotestsrc num-buffers=500 ! 'video/x-raw,format=(string)YUY2, width=(int)1280, height=(int)720, framerate=(fraction)30/1' ! vpe num-input-buffers=8 ! queue ! ducatimpeg4enc bitrate=4000 ! queue ! mpeg4videoparse ! qtmux ! filesink location=x.mp4

it worked fine and didn't have any problem of its  framerate and  bitrate:

And my camera can provide 1280x720 at 30 fps.And the version of my PSDK is 4.0.

So,could u tell me the reason of the problem and give me some advice to solve this problem.

Thanks&regards!

  • Hello,

    I have suspicious that this is not an encoder problem.
    However, in the gst h264 there is a memory leak issue which is already fixed please refer to this thread and cp the gst lib as is described in the thread and give a try.
    e2e.ti.com/.../620539

    I would recommend you to check this wiki page(Debugging chapter):
    processors.wiki.ti.com/.../Linux_Core_VIP_User's_Guide

    Since the pipeline with videotestsrc is working without a problem, please check is v4l2src dropping frames. I also would recommend you to try with io-mode=2 or auto.

    Hope this helps.

    BR
    Margarita
  • Hello,

    I tried this commmand :gst-launch-1.0 -e v4l2src device=/dev/video1 num-buffers=1000 io-mode=4 ! 'video/x-raw, 
    format=(string)YUY2, width=(int)1280, height=(int)720, framerate=(fraction)5/1' ! vpe num-input-buffers=8 ! 
    queue ! ducatimpeg4enc bitrate=4000 ! queue ! mpeg4videoparse ! qtmux ! filesink location=y.mp4

    But the properties of the Mp4 file showed that its  framerate was also 23.And the bitrate of the file was 3994 kbps rather than 4000.

    And I check the website which  you gave me.

    So  could help  me and give me some another advice .

  • The capture driver is able to capture at the rate the camera is able to stream the video. This can be verified using the Yavta tool -
    yavta -c60 -fYUYV -F/dev/null -s1280x720 /dev/video1.

    The bitrate that you are observing seems fine in the ballpark range you are specifying. Issue is only with the capture rate. It seems that the v4l2src plugin is either not enabling the capture of the video stream at the right rate or not time stamping it properly. The v4l2src plugin is open source and not maintained by TI.
  • The issue seems to be with number of buffers allocated by v4l2src plugin. By default it allocates 4 buffers. We increased it to 8 and it started capturing real time.

    Please find attached v4l2src patch on top of gst 1.6. You can refer to this patch and apply on top of the gst version you are using. 

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/0001_2D00_v4l2src_2D00_Increase_2D00_minimum_2D00_num_2D00_buffers_2D00_by_2D00_4.patch

    You can rebuild the plugin after applying the patch using Yocto build.

  • Hello,
    I'm sorry that I really not understand how to use this patch to rebuild the plugin,could u tell me the details.
    Thanks&best regards!
  • Hello,

    As Manisha said, you should follow this user guide:
    processors.wiki.ti.com/.../Processor_SDK_Building_The_SDK


    The v4l2src is part of gstreamer good plugin.
    So you could use this command MACHINE=am57xx-evm bitbake gstreamer1.0-plugins-good instead of MACHINE=<target-board> bitbake arago-core-tisdk-image which is described in the guide.
    To rebuild the plugin please check "Forced Re-compilation" chapter.

    Hope this helps.

    BR
    Margarita