Version 3 (modified by 5 years ago) ( diff ) | ,
---|
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:
# clone buildroot git clone https://github.com/buildroot/buildroot.git cd buildroot # fetch and apply patches wget http://trac.gateworks.com/zip-attachment/wiki/buildroot/gstreamer/ -O patches.zip unzip patches.zip 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:
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
- if you are looking for a ubi image suitable for 4K page size flash geometries (the Micron 2GiB part) change the following via menuconfig:
- output/images/rootfs.tar - refer to 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 linux/blockdev)
Running the Demos
Login as "root"
Example Demos:
- Video Display of test pattern:
gst-launch-1.0 videotestsrc ! autovideosink
- Capture, encode, and stream Analog Video
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:
gst-launch-1.0 udpsrc port=5000 caps=application/x-rtp,payload=96 ! rtph264depay ! decodebin ! autovideosink
- view on $SERVER with:
- Capture, encode, save Analog audio:
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:
gst-launch-1.0 filesrc location=file.mp3 ! mpegaudioparse ! mpg123audiodec ! alsasink device="sysdefault:CARD=sgtl5000audio"
- Capture, encode, and stream Analog Audio:
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:
gst-launch-1.0 udpsrc port=5000 caps=application/x-rtp,payload=96 ! rtpmpadepay ! decodebin ! autoaudiosink
- play on $SERVER with:
- Stream, decode, playback audio:
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.
Note:
See TracWiki
for help on using the wiki.