2011年6月14日 星期二

LeopardBoard DM368 HD H.264 encode

With DVSDK working on LeopardBoard DM368, Now let's trying video encode function.

1.Check kernel log to see if the dsplink related modules are loaded.

CMEMK module: built on Jun 14 2011 at 18:02:26
  Reference Linux version 2.6.32
  File /home/gigijoe/LeopardBoard/DM368/original/ti-dvsdk_dm368-evm_4_02_00_06/linuxutils_2_26_01_02/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c
allocated heap buffer 0xc6000000 of size 0x4400000
heap fallback enabled - will try heap if pool buffer is not available
CMEM Range Overlaps Kernel Physical - allowing overlap
CMEM phys_start (0x1000) overlaps kernel (0x80000000 -> 0x83c00000)
cmemk initialized
IRQK module: built on Jun 14 2011 at 18:02:29
  Reference Linux version 2.6.32
  File /home/gigijoe/LeopardBoard/DM368/original/ti-dvsdk_dm368-evm_4_02_00_06/linuxutils_2_26_01_02/packages/ti/sdo/linuxutils/irq/src/module/irqk.c
irqk initialized
EDMAK module: built on Jun 14 2011 at 18:02:30
  Reference Linux version 2.6.32
  File /home/gigijoe/LeopardBoard/DM368/original/ti-dvsdk_dm368-evm_4_02_00_06/linuxutils_2_26_01_02/packages/ti/sdo/linuxutils/edma/src/module/edmak.c

2.If there are errors check /etc/init.d/loadmodule-rc. Below is mine

#!/bin/sh

# Default DM368 EVM Memory Map
#
# Start Addr    Size    Description
# -------------------------------------------
# 0x00001000    32K     ARM TCM memory
# 0x80000000    48 MB   Linux
# 0x83000000    12 MB   Video driver memory (Linux)
# 0x83C00000    68 MB   CMEM
# 0x88000000    BOTTOM  ADDRESS

load () {
    modprobe cmemk phys_start=0x83C00000 phys_end=0x88000000 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672 useHeapIfPoolUnavai
lable=1
    modprobe irqk
    modprobe edmak
    modprobe dm365mmap
    mknod /dev/dm365mmap c `awk "\\$2==\"dm365mmap\" {print \\$1}" /proc/devices` 0
}

unload () {
    rmmod cmemk 2>/dev/null
    rmmod irqk  2>/dev/null
    rmmod edmak 2>/dev/null
    rmmod dm365mmap 2>/dev/null
    rm -f /dev/dm365mmap
}

case "$1" in
      start)
            load
             ;;
       stop)
            unload          
             ;;
       restart)
            unload          
            load
             ;;
        *)
             echo "$0 "
             ;;
esac

3.Decode test to verify if DSP works.

$ cd /usr/share/ti/ti-dmai-apps
$ ./video_decode_io2_dm368.x470MV -c h264dec -e decode -i /usr/share/ti/data/videos/davincieffect.264 -n 30 -o output.yuv
Starting application...
Loader created and primed, entering main loop..
Loaded Frame 1: frame size 401
Loaded Frame 2: frame size 36
Loaded Frame 3: frame size 804
Loaded Frame 4: frame size 844
Loaded Frame 5: frame size 863
Loaded Frame 6: frame size 933
Loaded Frame 7: frame size 1189
Loaded Frame 8: frame size 1253
Loaded Frame 9: frame size 1509
Display Frame 1: Wrote 420P frame size 1382400 (1280x720) to disk
Loaded Frame 10: frame size 1573
Display Frame 2: Wrote 420P frame size 1382400 (1280x720) to disk
Loaded Frame 11: frame size 1829

4.Now, it's time to encode video from camera. I got mt9p031 (LI-BCM5M03).
If you got kernel log below, the camera is ready

...
Leopard: switch to HD imager-MT9P031 video input
mt9p031 1-0048: Detected a MT9P031 chip ID 1801
mt9p031 1-0048: mt9p031 1-0048 decoder driver registered !!
vpfe-capture vpfe-capture: v4l2 sub device mt9p031 registered
...

5.Test if camera works

$ cd /usr/share/ti/ti-dmai-apps
$ ./video_loopback_dm368.x470MV -O component -I camera -y5
davinci_resizer davinci_resizer.2: RSZ_G_CONFIG:0:1:124
vpfe-capture vpfe-capture: IPIPE Chained
vpfe-capture vpfe-capture: Resizer present
Leopard: switch to HD imager-MT9P031 video input
-----Exposure time = 456
-----Exposure time = 456
vpfe-capture vpfe-capture: width = 1920, height = 1080, bpp = 1
vpfe-capture vpfe-capture: adjusted width = 1920, height = 1080, bpp = 1, bytesperline = 1920, sizeimage = 3110400
vpfe-capture vpfe-capture: width = 1920, height = 1080, bpp = 1
vpfe-capture vpfe-capture: adjusted width = 1920, height = 1080, bpp = 1, bytesperline = 1920, sizeimage = 3110400
davinci_v4l2 davinci_v4l2.1: Before finishing with S_FMT:
layer.pix_fmt.bytesperline = 1920,
 layer.pix_fmt.width = 1920,
 layer.pix_fmt.height = 1080,
 layer.pix_fmt.sizeimage =3110400
davinci_v4l2 davinci_v4l2.1: pixfmt->width = 1920,
 layer->layer_info.config.line_length= 1920

6.There's a application can do H.264 RTP which included in my dmai_2_20_00_15 patch called video_encode_rtp.

This application get frames from camera through VPFE then encoded in H.264 format packeted with H264RTP packet then send to network.

From LeopardBoard DM368

$ cd /usr/share/ti/ti-dmai-apps
$ ./video_encode_rtp_dm368.x470MV -I camera -y 4 -c h264enc -i /dev/video0 -o 192.168.168.72 -p 1234 -e encode -b 2000000

-I camera = camera input
-y 4 = 720P,
-o 192.168.168.72 = Send to 192.168.168.72
-p 1234 = port 1234
-b 2000000 = Bit rate 2000000

I'm decoding the video stream with gstreamer on PC Ubuntu.

$ gst-launch udpsrc port=1234 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" ! gstrtpjitterbuffer latency=100 ! rtph264depay ! ffdec_h264 ! xvimagesink

If the video frame sometimes droped, try larger gstrtpjitterbuffer latency = 200 / 300 / 500.

7.Full HD

From LeopardBoard DM368

-y 5 = 1080P

$ ./video_encode_rtp_dm368.x470MV -I camera -y 5 -c h264enc -i /dev/video0 -o 192.168.168.72 -p 1234 -e encode -b 2000000



6 則留言:

  1. Hi, I just saw your Leopard 368 HD encoding article, very helpful and interesting!

    I have 100% same hardware and software setting as yours, want to do a HD 1080p recording to the SD.

    Followed your steps, but failed to do the step3: I got the following when I type:

    $ cd /usr/share/ti/ti-dmai-apps
    $ ./video_decode_io2_dm368.x470MV -c h264dec -e decode -i /usr/share/ti/data/videos/davincieffect.264 -n 30 -o output.yuv

    Starting application...
    Loader created and primed, entering main loop..

    Then the program hang there without out any frame output like yours.

    I got same result from steps 1,2,4,5 as yours, so what would be wrong thus I can't get the DSP working?

    Could you tell me more?

    Sorry about English as I am a Taiwanese in Australia but haven't figure out how to input chinese  on Ubutu.

    Thanks for your help!!!

    [版主回覆09/10/2011 07:08:21]I got similar problem before :)
    Please rebuild DVSDK (I mean make clean; make) and rebuild SD card.
    Yes, it's voodoo programming, but does solve the DSP hang probleam.

    Good luck

    回覆刪除
  2. Thanks!

    I tried to remake the DVSDK, but still no luck.

    Do you have any other clues?

    I have one thing might be problem but not sure. I didn't include the "GStreamer" package into the build as I met a configure problem when I compile the GStreamer plugin.


    回覆刪除
  3. Hi,

    I am trying to run TI's encode demo on the Leopard 368 board with Component input. Got error message "Unable to configure resizer", so the Capture_create() failed. The code in DMAI is

        if (attrs->onTheFly == TRUE) {
            hCapture->resizerFd = Resizer_continuous_config();
            if(hCapture->resizerFd <= 0) {
                Dmai_err0("Unable to configure Resizer\n");
                cleanup(hCapture);
                return NULL;
            }

            hCapture->previewerFd = Previewer_continuous_config(attrs->videoInput
                == Capture_Input_CAMERA ? 1 : 0);
            if(hCapture->previewerFd <= 0) {
                Dmai_err0("Unable to configure Resizer\n");
                cleanup(hCapture);
                return NULL;
            }
        }

    I have both imp_rsz_driver and imp_prev_driver loaded. Pls help.

    回覆刪除
  4. 您好,

    我用和您相同的硬件, Leopard DM368, 也是相同的TI SDK版本,打了您贴出的4个patch。
    运行

    ./video_encode_rtp_dm368.x470MV -I camera -y 4 -c h264enc -i /dev/video0 -o 192.168.168.72 -p 1234 -e encode -b 2000000

    出现No Frame Read, 然后就停在那里了。

    运行
    ./video_decode_io2_dm368.x470MV -c h264dec -e decode -i /usr/share/ti/data/videos/davincieffect.264 -n 30 -o output.yuv

    出现
    Starting application...
    Loader created and primed, entering main loop..

    也停在那里了。

    请问这是上面的一样的问题么?

    谢谢。

    回覆刪除
  5. Hi, I got a TI DM368EVM board, with MT9P031 sensor, I follow your steps, and video_loopback_dm368.x470MV program working properly, then when I do rtp steaming, it prints out below messages:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Starting application...
    davinci_resizer davinci_resizer.2: RSZ_G_CONFIG:0:1:124
    davinci_previewer davinci_previewer.2: ipipe_set_preview_config
    davinci_previewer davinci_previewer.2: ipipe_set_preview_config
    vpfe-capture vpfe-capture: IPIPE Chained
    vpfe-capture vpfe-capture: Resizer present
    dm365evm_enable_pca9543a
    dm365evm_enable_pca9543a, status = -121
    EVM: switch to HD imager video input
    -----Exposure time = 2f2
    -----Exposure time = 2f2
    vpfe-capture vpfe-capture: width = 1280, height = 720, bpp = 1
    vpfe-capture vpfe-capture: adjusted width = 1280, height = 720, bpp = 1, bytesperline = 1280, sizeimage = 1382400
    vpfe-capture vpfe-capture: width = 1280, height = 720, bpp = 1
    vpfe-capture vpfe-capture: adjusted width = 1280, height = 720, bpp = 1, bytesperline = 1280, sizeimage = 1382400
    Trying 192.168.1.117:11086
    No frame read ...
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    And I am not able to play video in another machine, can you please share the output of your video_encode_rtp_dm368.x470MV program?

    Thanks
    Tim

    回覆刪除
  6. Hi Steven,

    冒昧請問: 您是否有接 DM368 專案 ? 或有 F/W 人員可介紹 ?
    若方便可用 email 聯絡. 謝謝 !
    打擾之處請見諒.

    Kevin
    yunnlai@gmail.com

    回覆刪除