How to capture at 1080p with LeopardBoard DM36x

From RidgeRun Developer Connection
Revision as of 10:37, 17 January 2013 by Tfischer (Talk | contribs)

Jump to: navigation, search


This whitepapers explains briefly how to configure your LeopardBoard DM368 to capture at 1080p.

Hardware needed

  • LeopardBoard DM36x
  • LI-5M03 camera module with MT9P031 sensor.

SDK Configuration

1. Select the MT9P031 driver to support your camera module

      Prompt: mt9p031 support
       -> Kernel configuration                                                                                    
         -> Device Drivers                                                                                        
           -> Multimedia support (MEDIA_SUPPORT [=y])                                                             
             -> Video capture adapters (VIDEO_CAPTURE_DRIVERS [=y])

2. Configure your SDK in order to be able to capture at 1080p as is shown below:

     Architecture configurations
           Video Output (Component)  --->                                                   
           Component Standard (1080I-30)  --->                                          
           Maximum Video Output Buffer Size (720P)  --->                            
           Maximum Video Input Buffer Size (1080P)  --->

3. Increase the reserved memory and the CMEM space to allocate the 1080p buffers.

    Proprietary Software
        [*] Reserve memory from the kernel for codec engine and friends automatically          
        (0x2bf7000) Amount of reserved memory from the kernel                     
        [*] Automatically setup CMEM at the beggining of the reserved memory area     
        (0x17f7000) Amount of reserved memory for cmemk 

4. If your target format is H264 and you are using an EVAL version of the SDK you will need to do the following modification into you MT9P031 driver:

Index: kernel/linux-
--- kernel.orig/linux-	2012-08-10 09:44:39.763840232 -0700
+++ kernel/linux-	2012-08-10 09:45:20.195126497 -0700
@@ -204,7 +204,7 @@
     /* 1080P-HDTV */
-    .framesize = { 1920, 1080},
+    .framesize = { 1920, 1088},
     .frameintervals = {
         {  .numerator = 1, .denominator = 31 },

This modification will allow use 1080p with the H264 encoder.

5. Re-built your SDK and install it into your board.

Use GStreamer to capture from the camera at 1080p

MJPEG Encoding

The following pipeline will capture a 1080p image and will encode it in JPEG to be saved to a file.


 gst-launch -e v4l2src num-buffers=1 always-copy=false ! 'video/x-raw-yuv,format=(fourcc)NV12, width=1920,height=1080' ! queue ! dmaiaccel ! dmaienc_mjpeg ! filesink location=$IMAGE_FILE

H264 Encoding

The following pipeline captures 1080p video and encode it in H264 to be saved into a file.


gst-launch -e v4l2src always-copy=false ! 'video/x-raw-yuv,format=(fourcc)NV12, width=1920,height=1088' ! queue ! dmaiaccel ! dmaienc_h264 encodingpreset=2 ratecontrol=2 ! qtmux ! filesink location=$VIDEO_FILE

NOTE: Due to codec limitations it is necessary to use 1920x1088 image size instead of 1920x1080. A specific modification must me done to accomplish this feature in the EVAL version (See previous section).

Live preview while saving to a file

Use case is a device that is capturing video with a camera, having an HD Monitor (HD 1080p TV) showing a live preview of the video being captured, along with the video being saved to file. A simple gst-launch type command is shown below. For a real product, you might want to consider using GStreamer daemon so that you can start and stop the recording.

Hardware is LeopardBoard 368 + L1-5M03 (MT9P031) Camera sensor board using SD card on leo368 and using leo368 component output.

H264ENC_PARMS="encodingpreset=2 ratecontrol=2 intraframeinterval=23 idrinterval=46 targetbitrate=3000000 profile=100 level=50 entropy=1 t8x8inter=true t8x8intra=true single-nalu=true"

gst-launch -e v4l2src input-src=camera chain-ipipe=true always-copy=false num-buffers=3000 ! 'video/x-raw-yuv,format=(fourcc)NV12,width=1280,height=720' ! dmaiaccel ! \ 
               tee name=t1 ! TIDmaiVideoSink enable-last-buffer=false videoStd=720P_60 videoOutput=COMPONENT \
            t1. ! queue ! dmaienc_h264 $H264ENC_PARMS ! queue ! dmaiperf print-arm-load=true ! qtmux ! queue ! \
                         filesink location=test.mp4 sync=false enable-last-buffer=false