Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Gstreamer

Ilya Melnikov edited this page · 6 revisions

some simple gstreamer examples (assuming that the v4l2loopback-device is /dev/video1)
you might need to upgrade to a recent version of GStreamer (>=0.10.27) for full support (note that version of Ubuntu-Maverick (0.10.25) might be too old)

test

feed a test image to a loopback device and read it

producer

videotestsrc

gst-launch videotestsrc ! v4l2sink device=/dev/video1

Different videotestsrc patterns with different resolutions:

gst-launch -v videotestsrc pattern=snow ! "video/x-raw-yuv,width=640,height=480,framerate=15/1,format=(fourcc)YUY2" ! v4l2sink device=/dev/video1
gst-launch -v videotestsrc pattern=ball ! "video/x-raw-yuv,width=800,height=600,framerate=30/1,format=(fourcc)YUY2" ! v4l2sink device=/dev/video1
gst-launch -v videotestsrc pattern=smpte horizontal-speed=1 ! "video/x-raw-yuv,width=1280,height=720,framerate=30/1,format=(fourcc)YUY2" ! v4l2sink device=/dev/video1

Desktop capture as producer

gst-launch -v ximagesrc startx=0 starty=0 endx=1279 endy=1023 ! ffmpegcolorspace ! "video/x-raw-yuv,width=1280,height=1024,framerate=10/1" ! v4l2sink device=/dev/video1

Video file as producer

gst-launch -v filesrc location=test.avi ! avidemux ! ffdec_huffyuv ! ffmpegcolorspace ! v4l2sink device=/dev/video1

Video file "test.avi" must be encoded with huffyuv codec.
Producer is not infinite. When file ends then producer stops.

Separate PNG frames as infinite producer

Create frames (in this example video file "test.avi" was encoded with huffyuv codec):

mkdir test
gst-launch -v filesrc location=test.avi ! avidemux ! ffdec_huffyuv ! ffmpegcolorspace ! pngenc snapshot=false ! multifilesink location=test/%05d.png

Use frames as infinite producer:

gst-launch -v multifilesrc location=test/%05d.png loop=1 caps="image/png,framerate=30/1" ! pngdec ! ffmpegcolorspace ! "video/x-raw-yuv,format=(fourcc)YUY2" ! videorate ! v4l2sink device=/dev/video1

When producing frames to v4l2sink, framerate can differ from framerate of the original video file. It can be set freely (60, 30, 15, 10, 5 or any other). This allows to produce different framerates with the same frame set.
Decoding PNG can consume much CPU time. To reduce the load on the processor use raw YUV frames.

Separate YUV frames as infinite producer

Create frames (in this example video file "test.avi" was encoded with huffyuv codec with 640x480@30):

mkdir test
gst-launch -v filesrc location=test.avi ! avidemux ! ffdec_huffyuv ! ffmpegcolorspace ! "video/x-raw-yuv,width=640,height=480,framerate=30/1,format=(fourcc)YUY2" ! multifilesink location=test/%05d.yuv

Use frames as infinite producer:

gst-launch -v multifilesrc location=test/%05d.yuv loop=1 caps="video/x-raw-yuv,width=640,height=480,framerate=30/1,format=(fourcc)YUY2" ! videorate ! v4l2sink device=/dev/video1

When producing frames to v4l2sink, framerate can differ from framerate of the original video file. It can be set freely (60, 30, 15, 10, 5 or any other). This allows to produce different framerates with the same frame set.
Decoding YUV frames does not consume much CPU time. But YUV frames consumes much disk space and memory.

consumer

$ gst-launch v4l2src device=/dev/video1 ! xvimagesink

Something went wrong with that request. Please try again.