= Introduction to GStreamer in Buildroot An embedded solution may require a custom multimedia streaming solution. Buildroot and GStreamer makes for an efficient lightweight solution. This guide will walk you through the necessary steps to create a bootable image containing the ability to: - capture/playback/encode/decode Video - capture/playback/encode/decode Audio = Building the demo image == Recommended hardware - Ventana board with video input and video output (ie GW5404) - 1080p HDMI monitor - Mini HDMI cable to HDMI (for connecting the board and monitor together) - Power cables == Building Procedure: {{{#!bash # clone buildroot git clone https://github.com/buildroot/buildroot.git cd buildroot # fetch and apply patch that adds ventana defconfig files wget http://trac.gateworks.com/raw-attachment/wiki/buildroot/gstreamer/0000-package-add-gst-gateworks-apps.patch wget http://trac.gateworks.com/raw-attachment/wiki/buildroot/gstreamer/0001-configs-add-various-Gateworks-Ventana-configs.patch wget http://trac.gateworks.com/raw-attachment/wiki/buildroot/gstreamer/0002-board-gateworks-add-overlay-for-Gateworks-Ventana-bo.patch git am *.patch # build the gwventana-gst image make distclean make imx6-gwventana-gst_defconfig make ls output/images/ }}} The patch adds the following: * board/gateworks/ventana/rootfs_overlay/bin/media-ctl-setup - media-ctl helper script for configuring video capture devices * configs/imx6-gwventana-gst_defconfig - defconfig for GStreamer based image You can use the following filesystem images: * output/images/rootfs.ubi for 2K page size flash geometries (256MB flash or newer 2GiB flash parts) - if you are looking for a ubi image suitable for 4K page size flash geometries (the Micron 2GiB part) change the following via menuconfig: {{{#!bash BR2_TARGET_ROOTFS_UBIFS_LEBSIZE=0x3e000 BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE=0x1000 BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT=8192 BR2_TARGET_ROOTFS_UBI_PEBSIZE=0x40000 BR2_TARGET_ROOTFS_UBI_SUBSIZE=0 }}} * output/images/rootfs.tar - refer to [wiki:/linux/blockdev this page] to create a bootable block storage device using the created tarball * output/images/sdcard.img - disk image suitable for copying to a removalbe block storage device (see [wiki:/linux/blockdev]) = Running the Demos Login as "root" Example Demos: * Video Display of test pattern: {{{#!bash gst-launch-1.0 videotestsrc ! autovideosink }}} * Capture, encode, and stream Analog Video {{{#!bash media-ctl-setup adv7180 > setup . ./setup gst-launch-1.0 v4l2src device=$DEVICE ! \         $GST_CONVERT output-io-mode=dmabuf-import ! \         v4l2h264enc output-io-mode=dmabuf-import ! \         rtph264pay ! udpsink host=$SERVER port=5000 }}} - view on $SERVER with: {{{#!bash gst-launch-1.0 udpsrc port=5000 caps=application/x-rtp,payload=96 ! rtph264depay ! decodebin ! autovideosink }}} * Capture, encode, save Analog audio: {{{#!bash amixer -c 1 sset "Capture Mux" LINE_IN # LINE_IN vs MIC_IN, default MIC_IN amixer -c 1 sset "Capture" 8 # 0-15, default 0 gst-launch-1.0 alsasrc device="sysdefault:CARD=sgtl5000audio" ! audioconvert ! filesink location=file.mp3 }}} * Decode and Playback audio to Analog out: {{{#!bash gst-launch-1.0 filesrc location=file.mp3 ! mpegaudioparse ! mpg123audiodec ! alsasink device="sysdefault:CARD=sgtl5000audio" }}} * Capture, encode, and stream Analog Audio: {{{#!bash amixer -c 1 sset "Capture Mux" LINE_IN # LINE_IN vs MIC_IN, default MIC_IN amixer -c 1 sset "Capture" 8 # 0-15, default 0 gst-launch-1.0 -v alsasrc device="sysdefault:CARD=sgtl5000audio" ! \ audioconvert ! \ lamemp3enc ! \ rtpmpapay ! udpsink host=$SERVER port=5000 }}} - play on $SERVER with: {{{#!bash gst-launch-1.0 udpsrc port=5000 caps=application/x-rtp,payload=96 ! rtpmpadepay ! decodebin ! autoaudiosink }}} * Stream, decode, playback audio: {{{#!bash gst-launch-1.0 playbin uri=http://server/myfavoritesong.mp3 }}} = Conclusion This concludes how to build and install the GStreamer demo in buildroot. Using "make menuconfig" many additional applications and gstreamer plugins can be built into buildroot for other needs.