Difference between revisions of "Jetson/H264 Codec"

From eLinux.org
Jump to: navigation, search
m (gst capturing live stream from usb camera)
m (added toc)
Line 1: Line 1:
 +
__FORCETOC__
 
== About the codec ==
 
== About the codec ==
  

Revision as of 04:49, 24 July 2014

About the codec

Although commonly referred to as the H.264 codec, Tegra K1's high-definition video hardware supports encoding and decoding formats in addition to H.264, including VC-1, VP8, MPEG-4 basic, MPEG-2, and JPEG. The driver for the codec hardware is an OpenMAX IL implementation, a standard media streaming interface used by mobile SoCs, and is accessible through gstreamer using the nv_omx_h264enc and nv_omx_h264dec elements. Visit here if you are new to using gstreamer.

From the command line

Any easy way to get started with the codec is launch some gstreamer pipelines from the terminal.

  • Recieve a RAW RTP video stream over the network and encode it as H.264 to disk:
 gst-launch -e udpsrc host=<IP> port=5004 caps="application/x-rtp, media=(string)video, 
 clock-rate=(int)90000,encoding-name=(string)RAW, sampling=(string)YCbCr-4:2:2, 
 depth=(string)8, width=(string)<WIDTH>, height=(string)<HEIGHT>, payload=(int)96" 
 ! gstrtpjitterbuffer ! rtpvrawdepay ! queue ! video/x-raw-yuv ! nvvidconv 
 ! 'video/x-nvrm-yuv, format=(fourcc)I420' ! nv_omx_h264enc quality-level=2 
 ! video/x-h264 ! matroskamux ! queue ! filesink location=<FILENAME>.mkv

(the <IP>, <WIDTH>, <HEIGHT>, and <FILENAME> parameters are to be provided by user)

  • Capture live video stream from usb camera, encode and store it to local filesystem:
 gst-launch -e v4l2src ! 'video/x-raw-yuv,width=<FRAME_WIDTH>,height=<FRAME_HEIGHT>,framerate=<FRAME_RATE>/1' 
 ! nv_omx_h264enc quality-level=2 ! mp4mux ! filesink location=<FILE_PATH>

e.g. gst-launch -e v4l2src ! 'video/x-raw-yuv,width=1280,height=720,framerate=30/1' ! nv_omx_h264enc quality-level=2 ! mp4mux ! filesink location=/home/room/family.mp4

  • Decode the H.264 file from disk and stream it out over the network:
 gst-launch filesrc location=<FILENAME>.mkv ! matroskademux ! queue ! h264parse ! nv_omx_h264dec 
 ! ffmpegcolorspace ! 'video/x-raw-yuv, format=(fourcc)UYVY' ! rtpvrawpay mtu=1472 
 ! queue ! udpsink host=<IP> port=5004 loop=false
  • Examine the properties & settings of elements using gst-inspect:
 gst-inspect nv_omx_h264enc

From within your application

Using the gstreamer-defined appsrc and appsink elements, it's possible to efficiently send application data into a local gstreamer pipeline running in the application's userspace. For example using appsrc a CUDA video processing application could send it's image buffers into gstreamer to be encoded, and then retrieve the H.264-encoded data from gstreamer using appsink. Code sample using nv_omx_h264enc/nv_omx_h264dec coming soon!