CM-T3530: Linux: Video playback

From Wiki

Jump to: navigation, search

Contents

Introduction

The OMAP3530 includes a built-in TMS320C64X+ DSP Core that provides advanced hardware acceleration support for media encoding / decoding.
For further details, refer to the OMAP35x Technical Reference Manual.

GStreamer TI Plugin

GStreamer is a pipeline-based multimedia framework that allows to create a variety of media-handling software components. GStreamer TI Plugin for OMAP3 platform enables DSP hardware utilisation for accelerating streaming audio and video processing and image manipulation by using TI DSP codecs. The plugin contains GstTIPlugin Elements for decoding/encoding audio, video and image and for displaying the video using fbdev.

Video formats.

Gstreamer TI and TI OMAP35x codecs currently support playback of VGA videos of quality up to 480p @ 30 fps of the following formats:

  • VGA .AVI VGA file with MPEG-2 or MPEG-4 Video and MP1L2 or MP3 Audio.
  • VGA .AVI VGA file with H.264 Video and AAC Audio.
  • VGA .MP4 file with MPEG-2/MPEG-4/H.264 Video and MP1L2/MP3/AAC Audio.
  • VGA .TS file with H.264 Video and MP1L2 or MP3 Audio.

Only baseline profile of H.264 and simple profile of MPEG4 formats are supported. Please refer to the TI H.264 and MPEG-4 codecs Data Sheets.

Kernel modules

OMAP3530 SoC requires the following modules for video playback:

  • digital signal processor (DSP) core driver modules
  • 2D/3D graphics accelerator (SGX) driver modules

The run-time demo Angstrom Linux filesystem including the video modules was created using OpenEmbedded framework. If the CM-T3530 Linux kernel image is built outside the OpenEmbedded framework, the pre-built DSP and SGX modules must be installed onto the filesystem separately:

  1. Build Linux kernel as described in CM-T3530: Linux: Kernel article.
  2. Copy the pre-built DSP and SGX video modules from the CM-T3530 Linux package to the kernel modules directory (e.g. /home/development/cm-t35/rootfs/lib/modules/<kernel version>/).
  3. Put the depmod.sh script from the CM-T3530 Linux package into the /etc/init.d/ directory on the root file system.
  4. Install the depmod.sh to the required runlevel using update-rc.d utility. Note, that the Angstrom Linux filesystem provided in CM-T3530 Linux package has the script already installed.

Kernel parameters

In order to make the GStreamer-TI package work, please ensure that the framebuffer plains 1 and 2 are enabled in your kernel command line:

vram=18M omapfb.vram=0:6M,1:6M,2:6M

Additionally, cmemk kernel module requires a "window" in the kernel memory. It allocates a heap buffer at 0xc9000000 of size 0x53d000. You can leave this memory free by adding for example the following option to the kernel command line:

mem=99M@0x80000000

Playback pipeline examples

Below examples illustrate how to play video samples using GStreamer-TI. For more info please refer to GStreamer Pipelines Examples for OMAP35x.

  • VGA .AVI file with MPEG-2 or MPEG-4 Video and MP1L2 or MP3 Audio.
gst-launch -v filesrc location=sample.avi ! avidemux name=demux demux.audio_00 ! \
  queue max-size-buffers=1200 max-size-time=0 max-size-bytes=0 ! mad !  alsasink demux.video_00 ! \
  queue ! TIViddec2 ! queue max-size-buffers=2 max-size-time=0 max-size-bytes=0 ! omapdmaifbsink max-lateness=50000
  • VGA .AVI file with H.264 Video and AAC Audio.
gst-launch -v filesrc location=sample.avi ! avidemux name=demux demux.audio_00 ! \
  queue max-size-buffers=8000 max-size-time=0 max-size-bytes=0 ! TIAuddec1 ! alsasink demux.video_00 ! \
  queue ! TIViddec2 ! omapdmaifbsink max-lateness=50000
  • VGA .MP4 file with H.264 Video and MP1L2 or MP3 Audio:
gst-launch -v filesrc location=sample.mp4 ! qtdemux name=demux demux.audio_00 ! \
  queue max-size-buffers=8000 max-size-time=0 max-size-bytes=0 ! mad ! alsasink demux.video_00 ! \
  queue ! TIViddec2 ! omapdmaifbsink max-lateness=50000
  • VGA .MP4 file with H.264 Video and AAC Audio:
gst-launch -v filesrc location=sample.mp4 ! qtdemux name=demux demux.audio_00 ! \
  queue max-size-buffers=8000 max-size-time=0 max-size-bytes=0 ! TIAuddec1 ! alsasink demux.video_00 ! \
  queue ! TIViddec2 ! omapdmaifbsink max-lateness=50000
  • VGA .TS file with H.264 Video and MP1L2 or MP3 Audio:
gst-launch filesrc location=sample.ts ! typefind ! mpegtsdemux name=demux demux. ! \
  queue max-size-buffers=1200 max-size-time=0 max-size-bytes=0 ! typefind ! mad ! alsasink demux. ! \
  typefind ! TIViddec2 ! queue max-size-buffers=2 max-size-time=0 max-size-bytes=0 ! omapdmaifbsink max-lateness=50000

Creating Videos

Example video clips can be downloaded from Apple trailers. Use Quicktime Pro to download and save the trailer videos. Use the ffmpeg application to convert the videos to the GStreamer TI compatible formats. Refer to enabling MP3, MPEG4, AAC, in FFmpeg on Ubuntu.

  • Encoding to .AVI file H.264 Video and AAC Audio:
ffmpeg -i test.mov -f avi -r 30 -b 1200kb -s 720x480 -vcodec libx264 -vpre hq -vpre baseline \
  -me_range 8 -crf 22 -acodec aac -ar 22050 -ac 2 -threads 0 test.avi

Creates a video file with size 720x480, 30 fps, bitrate 1200 kbps, 2 channels audio with 22050 Hz frequency.

  • Encoding to .MP4 file with MPEG-4 Video and MP3 Audio:
ffmpeg -i test.mov -r 30 -f mp4  -b 1200kb -s 720x480  -vcodec mpeg4 -flags +aic+cbp+mv0+mv4 \
  -profile 0 -level 2 -trellis 2 -mbd 2 -cmp 2 -subcmp 2 -g 250 -maxrate 2.5M -bufsize 2M  \
  -acodec libmp3lame -ar 22050 -ac 2 -threads 0 test.mp4

Parameters explanation

-f 
container format
-b 
video bitrate
-s 
video size
-r 
frames per second
-ar 
audio frequency
-ac 
audio channels
-threads 0 
indicates that the algorithm should choose the number of threads to be used.


H264 specific options - please refer for more info to the x264 encoding guide and ffmpeg to libx264 options mapping.

-vpre libx264 presets
-me_range
-crf

MPEG-4 specific options - please refer for some explanations here.

-profile  -level  :
- Simple Profile level 0, corresponds to "-profile 0 - level 8"
- Simple Profile level 1, corresponds to "-profile 0 - level 1"
- Simple Profile level 2, corresponds to "-profile 0 - level 2"

-flags

-trellis

-mbd

-cmp

-subcmp

-g

-maxrate

-bufsize

Troubleshooting

Videos not playing

Try to add to your gstreamer command line the debugging option that will display all warnings regarding the TI elements.

-v --gst-debug=TI*:2

If there are no errors shown, but the player still doesn't show up, check if the video is of a compatible format and size (should be up to 480p).

Personal tools