GStreamer i.MX6 Camera Streaming

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GStreamer i.MX6 Camera Streaming

GStreamer i.MX6 Camera Streaming

(DEPRECATED. Please check this document for Real Time Streaming)

A server can be streaming video and a client, in this case a i.MX6 target, is receiving and decoding it. For example, a server with GStreamer and a web camera connected, can be streaming with the following command:

$ # Pipeline 1

$ gst-launch v4l2src ! 'video/x-raw-yuv, format=(fourcc)I420, width=(int)1280, height=(int)800' ! ffenc_mpeg4 ! tcpserversink host=$CLIENT_IP port=$PORT

and on the target, the client receives, decodes and display with

$ # Pipeline 2

$ gst-launch tcpclientsrc host=$SERVER_IP port=$PORT  ! 'video/mpeg, width=(int)1280, height=(int)800, framerate=(fraction)10/1, mpegversion=(int)4, systemstream=(boolean)false' ! vpudec ! mfw_isink

The filter caps between the tcpclientsrc and the decoder (vpudec) depend on the sink caps coming from the server encoder (ffenc_mpeg4), so these may change depending on your needs. Running the above pipelines require the environment variables SERVER_IP, CLIENT_IP and PORT.

In case you want the i.MX6 to act as a server, just change the video source (either mfw_v4lsrc of v4l2src) and the encoder (vpuenc), so

$ # Pipeline 3

$  gst-launch v4l2src  !  'video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(int)480, interlaced=(boolean)false, framerate=(fraction)10/1'  ! vpuenc ! tcpserversink host=$CLIENT_IP port=$PORT


For testing purposes, set SERVER_IP=127.0.0.1, CLIENT_IP=127.0.0.1 and PORT=500, and run pipeline 3 and 2 in two different consoles. Check with 'top' the  CPU usage and see that VPU is actually doing most of the work.

Labels (3)
Comments

While working with a customer, we found that 1080p encode through the VPU doesn't work directly because of a test in src/video/vpu/src/vpuenc.c in the gst-fsl-plugins-3.0.2 package:

    if ((pad_width % 16) || (pad_height % 16)) {

Removing the restriction on pad_height seems to function.

There's also a way to use the mfw_ipucsc element to stretch things by 8 pixels.

%3CLINGO-SUB%20id%3D%22lingo-sub-1100703%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EGStreamer%20i.MX6%20Camera%20Streaming%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1100703%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSTRONG%20style%3D%22font-size%3A%2018pt%3B%22%3E(DEPRECATED.%20Please%20check%20%3CA%20_jive_internal%3D%22true%22%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fdocs%2FDOC-94646%22%20target%3D%22_blank%22%3Ethis%3C%2FA%3E%20document%20for%20Real%20Time%20Streaming)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EA%20server%20can%20be%20streaming%20video%20and%20a%20client%2C%20in%20this%20case%20a%20i.MX6%20target%2C%20is%20receiving%20and%20decoding%20it.%20For%20example%2C%20a%20server%20with%20GStreamer%20and%20a%20web%20camera%20connected%2C%20can%20be%20streaming%20with%20the%20following%20command%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CBLOCKQUOTE%3E%0A%3CP%3E%24%20%23%20Pipeline%201%3C%2FP%3E%0A%3CP%3E%3CEM%3E%24%20gst-launch%20v4l2src%20!%20'video%2Fx-raw-yuv%2C%20format%3D(fourcc)I420%2C%20width%3D(int)1280%2C%20height%3D(int)800'%20!%20ffenc_mpeg4%20!%20tcpserversink%20host%3D%24CLIENT_IP%20port%3D%24PORT%3C%2FEM%3E%3C%2FP%3E%0A%0A%0A%3C%2FBLOCKQUOTE%3E%3CP%3Eand%20on%20the%20target%2C%20the%20client%20receives%2C%20decodes%20and%20display%20with%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CBLOCKQUOTE%3E%0A%3CP%3E%24%20%23%20Pipeline%202%3C%2FP%3E%0A%3CP%3E%3CEM%3E%20%24%20gst-launch%20tcpclientsrc%20host%3D%24SERVER_IP%20port%3D%24PORT%26nbsp%3B%20!%20'video%2Fmpeg%2C%20width%3D(int)1280%2C%20height%3D(int)800%2C%20framerate%3D(fraction)10%2F1%2C%20mpegversion%3D(int)4%2C%20systemstream%3D(boolean)false'%20!%20vpudec%20!%20mfw_isink%3C%2FEM%3E%3C%2FP%3E%0A%0A%0A%3C%2FBLOCKQUOTE%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20filter%20caps%20between%20the%20%3CEM%3Etcpclientsrc%3C%2FEM%3E%20and%20the%20decoder%20(%3CEM%3Evpudec%3C%2FEM%3E)%20depend%20on%20the%20sink%20caps%20coming%20from%20the%20server%20encoder%20(%3CEM%3Effenc_mpeg4%3C%2FEM%3E)%2C%20so%20these%20may%20change%20depending%20on%20your%20needs.%20Running%20the%20above%20pipelines%20require%20the%20environment%20variables%20SERVER_IP%2C%20CLIENT_IP%20and%20PORT.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIn%20case%20you%20want%20the%20i.MX6%20to%20act%20as%20a%20server%2C%20just%20change%20the%20video%20source%20(either%20mfw_v4lsrc%20of%20v4l2src)%20and%20the%20encoder%20(vpuenc)%2C%20so%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CBLOCKQUOTE%3E%0A%3CP%3E%24%20%23%20Pipeline%203%3C%2FP%3E%0A%3CP%3E%3CEM%3E%24%26nbsp%3B%20gst-launch%20v4l2src%26nbsp%3B%20!%26nbsp%3B%20'video%2Fx-raw-yuv%2C%20format%3D(fourcc)I420%2C%20width%3D(int)640%2C%20height%3D(int)480%2C%20interlaced%3D(boolean)false%2C%20framerate%3D(fraction)10%2F1'%26nbsp%3B%20!%20vpuenc%20!%20tcpserversink%20host%3D%24CLIENT_IP%20port%3D%24PORT%3C%2FEM%3E%3C%2FP%3E%0A%0A%0A%3C%2FBLOCKQUOTE%3E%3CP%3E%3CEM%3E%3CBR%20%2F%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3EFor%20testing%20purposes%2C%20set%20SERVER_IP%3D127.0.0.1%2C%20CLIENT_IP%3D127.0.0.1%20and%20PORT%3D500%2C%20and%20run%20pipeline%203%20and%202%20in%20two%20different%20consoles.%20Check%20with%20'top'%20the%26nbsp%3B%20CPU%20usage%20and%20see%20that%20VPU%20is%20actually%20doing%20most%20of%20the%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1100703%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX6_All%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELinux%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMultimedia%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1100704%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20GStreamer%20i.MX6%20Camera%20Streaming%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1100704%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EWhile%20working%20with%20a%20customer%2C%20we%20found%20that%201080p%20encode%20through%20the%20VPU%20doesn't%20work%20directly%20because%20of%20a%20test%20in%20src%2Fvideo%2Fvpu%2Fsrc%2Fvpuenc.c%20in%20the%20gst-fsl-plugins-3.0.2%20package%3A%3C%2FP%3E%3CPRE%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20if%20((pad_width%20%25%2016)%20%7C%7C%20(pad_height%20%25%2016))%20%7B%0A%3C%2FPRE%3E%3CP%3ERemoving%20the%20restriction%20on%20pad_height%20seems%20to%20function.%3C%2FP%3E%3CP%3EThere's%20also%20a%20way%20to%20use%20the%20%3CTT%3Emfw_ipucsc%3C%2FTT%3E%20element%20to%20stretch%20things%20by%208%20pixels.%3C%2FP%3E%3C%2FLINGO-BODY%3E
No ratings
Version history
Last update:
‎11-15-2012 03:44 PM
Updated by: