2011年6月20日 星期一

LeopardBoard DM368 ffmpeg

For the HD video I need libraries to support video / audio file mux. The ffmpeg is a good choice. With ffmpeg I can save H.264 raw data into mp4 file then play video on PC.

1.Download ffmpeg-0.6.1
Download ffmpeg-0.6.1 and put it in ~/LeopardBoard/DM368

2.Cross compile ffmpeg
I will install ffmpeg into the toolchain sub directory for convenience. My toolchain locate at /opt/arm-2009q1

$ cd ~/LeopardBoard/DM368/ffmpeg-0.6.1
$ mkdir build
$ cd build
$ ../configure --target-os=linux --arch=armv --cpu=armv5te --enable-cross-compile --cross-prefix=arm-none-linux-gnueabi- --prefix=/opt/arm-2009q1/arm-none-linux-gnueabi/libc/usr
$ make
$ sudo PATH=$PATH:/opt/arm-2009q1/bin make install

3.Apply patch to fix Makefile to prevent application link error and add new application video_encode_mp4.

ti-dvsdk_dm368-evm_4_02_00_06_dmai_2_20_00_15_ffmpeg.patch

There will be link error while compile application, so I did some modify to dmai_2_20_00_15/packages/ti/sdo/dmai/apps/Makefile.app

The new application is capable to record HD video and save it into mp4 file

4.Recompile DMAI

$ cd ~/LeopardBoard/DM368/original/ti-dvsdk_dm368-evm_4_02_00_06
$ make dmai

The new application video_encode_mp4 is located at dmai_2_20_00_15/packages/ti/sdo/dmai/apps/video_encode_mp4/linux/video_encode_mp4_dm368.x470MV

5.Running
Save 720p video into SD card with file name video_encode.mp4

$ cd /usr/share/ti/ti-dmai-apps
$ ./video_encode_mp4_dm368.x470MV -I camera -y 4 -c h264enc -i /dev/video0 -o /media/mmcblk0p2/video_encode.mp4 -e encode -b 2000000

6.Running with benchmark

$ ./video_encode_mp4_dm368.x470MV -I ca
mera -y 4 -c h264enc -i /dev/video0 -o /media/mmcblk0p2/video_encode.mp4 -e encode -b 8000000 --benchmark
Starting application...
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 = 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
Output #0, mp4, to '/media/mmcblk0p2/video_encode.mp4':
    Stream #0.0: Video: 0x0000, yuv420p, 1280x720, q=2-31, 8000 kb/s, 90k tbn, 15 tbc
No frame read ...
...

Frame 26: Read time: 8431us
[27] Encode: 19808us
File write time: 3915us
Total: 32414us

 Frame 27: Read time: 9166us
[28] Encode: 19778us
File write time: 4592us
Total: 33793us

 Frame 28: Read time: 8517us
[29] Encode: 19796us
File write time: 5055us
Total: 33621us

 Frame 29: Read time: 8097us
[30] Encode: 28264us
File write time: 18042us
Total: 54664us

 Frame 30: Read time: 19820us
[31] Encode: 26007us
File write time: 18879us
Total: 64968us

 Frame 31: Read time: 21273us
[32] Encode: 19804us
File write time: 2930us
Total: 44265us

 Frame 32: Read time: 10147us
[33] Encode: 19743us
File write time: 2517us
Total: 32662us
...

Write file time about 2 ~ 5 ms, there's no need to write file in another thread.



1 則留言:

  1. Hello Sir,

    Im trying to write an encoder application for ti-dvsdk similar to your application video_encode_mp4 but taking input from a file instead of a camera and encoding it into mp4 format.

    I have gone through the video_encode_mp4 application for this purpose and modified the code accordingly.

    Now im not able to compile my application in dvsdk.
    i have placed the application in ti-dvsdk_dm3730-evm_4_01_00_09/dmai_2_20_00_14/packages/ti/sdo/dmai/apps

    how do i get the dvsdk compiler to compile my application..??

    thanking you,
    Shravan Kulkarni
    [版主回覆11/02/2011 16:33:44]The quick way to get application compiled in dvsdk. Just copy folder video_encode_mp4 to a new folder, such as video_encode_XXX. And then copy / replace your source file into new folder.Finally fix all file name inside new folder.

    make dmai

    Good luck

    回覆刪除