| | 1 | = Introduction to GStreamer in Buildroot |
| | 2 | |
| | 3 | An embedded solution may require a custom multimedia streaming solution. Buildroot and GStreamer makes for an efficient lightweight solution. |
| | 4 | |
| | 5 | This guide will walk you through the necessary steps to create a bootable image containing the ability to: |
| | 6 | - capture/playback/encode/decode Video |
| | 7 | - capture/playback/encode/decode Audio |
| | 8 | |
| | 9 | = Building the demo image |
| | 10 | |
| | 11 | == Recommended hardware |
| | 12 | |
| | 13 | - Ventana board with video input and video output (ie GW5404) |
| | 14 | - 1080p HDMI monitor |
| | 15 | - Mini HDMI cable to HDMI (for connecting the board and monitor together) |
| | 16 | - Power cables |
| | 17 | |
| | 18 | |
| | 19 | == Building |
| | 20 | Procedure: |
| | 21 | {{{#!bash |
| | 22 | # clone buildroot |
| | 23 | git clone https://github.com/buildroot/buildroot.git |
| | 24 | cd buildroot |
| | 25 | # fetch and apply patch that adds ventana defconfig files |
| | 26 | wget http://trac.gateworks.com/raw-attachment/wiki/buildroot/gstreamer/0001-configs-add-various-Gateworks-Ventana-configs.patch |
| | 27 | wget http://trac.gateworks.com/raw-attachment/wiki/buildroot/gstreamer/0002-board-gateworks-add-overlay-for-Gateworks-Ventana-bo.patch |
| | 28 | git am *.patch |
| | 29 | # build the gwventana-gst image |
| | 30 | make distclean |
| | 31 | make imx6-gwventana-gst_defconfig |
| | 32 | make |
| | 33 | ls output/images/ |
| | 34 | }}} |
| | 35 | |
| | 36 | The patch adds the following: |
| | 37 | * board/gateworks/ventana/rootfs_overlay/bin/media-ctl-setup - media-ctl helper script for configuring video capture devices |
| | 38 | * configs/imx6-gwventana-gst_defconfig - defconfig for GStreamer based image |
| | 39 | |
| | 40 | You can use the following filesystem images: |
| | 41 | * output/images/rootfs.ubi for 2K page size flash geometries (256MB flash or newer 2GiB flash parts) |
| | 42 | - if you are looking for a ubi image suitable for 4K page size flash geometries (the Micron 2GiB part) change the following via menuconfig: |
| | 43 | {{{#!bash |
| | 44 | BR2_TARGET_ROOTFS_UBIFS_LEBSIZE=0x3e000 |
| | 45 | BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE=0x1000 |
| | 46 | BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT=8192 |
| | 47 | BR2_TARGET_ROOTFS_UBI_PEBSIZE=0x40000 |
| | 48 | BR2_TARGET_ROOTFS_UBI_SUBSIZE=0 |
| | 49 | }}} |
| | 50 | * output/images/rootfs.tar - refer to [wiki:/linux/blockdev this page] to create a bootable block storage device using the created tarball |
| | 51 | * output/images/sdcard.img - disk image suitable for copying to a removalbe block storage device (see [wiki:/linux/blockdev]) |
| | 52 | |
| | 53 | |
| | 54 | = Running the Demos |
| | 55 | |
| | 56 | Login as "root" |
| | 57 | |
| | 58 | Example Demos: |
| | 59 | * Video Display of test pattern: |
| | 60 | {{{#!bash |
| | 61 | gst-launch-1.0 videotestsrc ! autovideosink |
| | 62 | }}} |
| | 63 | * Capture, encode, and stream Analog Video |
| | 64 | {{{#!bash |
| | 65 | media-ctl-setup adv7180 > setup |
| | 66 | . ./setup |
| | 67 | gst-launch-1.0 v4l2src device=$DEVICE ! \ |
| | 68 | $GST_CONVERT output-io-mode=dmabuf-import ! \ |
| | 69 | v4l2h264enc output-io-mode=dmabuf-import ! \ |
| | 70 | rtph264pay ! udpsink host=$SERVER port=5000 |
| | 71 | }}} |
| | 72 | - view on $SERVER with: |
| | 73 | {{{#!bash |
| | 74 | gst-launch-1.0 udpsrc port=5000 caps=application/x-rtp,payload=96 ! rtph264depay ! decodebin ! autovideosink |
| | 75 | }}} |
| | 76 | * Capture, encode, save Analog audio: |
| | 77 | {{{#!bash |
| | 78 | amixer -c 1 sset "Capture Mux" LINE_IN # LINE_IN vs MIC_IN, default MIC_IN |
| | 79 | amixer -c 1 sset "Capture" 8 # 0-15, default 0 |
| | 80 | gst-launch-1.0 alsasrc device="sysdefault:CARD=sgtl5000audio" ! audioconvert ! filesink location=file.mp3 |
| | 81 | }}} |
| | 82 | * Decode and Playback audio to Analog out: |
| | 83 | {{{#!bash |
| | 84 | gst-launch-1.0 filesrc location=file.mp3 ! mpegaudioparse ! mpg123audiodec ! alsasink device="sysdefault:CARD=sgtl5000audio" |
| | 85 | }}} |
| | 86 | * Capture, encode, and stream Analog Audio: |
| | 87 | {{{#!bash |
| | 88 | amixer -c 1 sset "Capture Mux" LINE_IN # LINE_IN vs MIC_IN, default MIC_IN |
| | 89 | amixer -c 1 sset "Capture" 8 # 0-15, default 0 |
| | 90 | gst-launch-1.0 -v alsasrc device="sysdefault:CARD=sgtl5000audio" ! \ |
| | 91 | audioconvert ! \ |
| | 92 | lamemp3enc ! \ |
| | 93 | rtpmpapay ! udpsink host=$SERVER port=5000 |
| | 94 | }}} |
| | 95 | - play on $SERVER with: |
| | 96 | {{{#!bash |
| | 97 | gst-launch-1.0 udpsrc port=5000 caps=application/x-rtp,payload=96 ! rtpmpadepay ! decodebin ! autoaudiosink |
| | 98 | }}} |
| | 99 | * Stream, decode, playback audio: |
| | 100 | {{{#!bash |
| | 101 | gst-launch-1.0 playbin uri=http://server/myfavoritesong.mp3 |
| | 102 | }}} |
| | 103 | |
| | 104 | = Conclusion |
| | 105 | 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. |