Multimedia
GStreamer
Section titled “GStreamer”GStreamer is a powerful pipeline-based multimedia framework. It allows programmers to create a variety of media-handling components, including simple audio playback, audio and video playback, recording, streaming and editing. This is not a GStreamer reference manual but an overview for using it on NeuralPlex. This release uses the gstreamer-imx set of GStreamer 1.0 plugins for NXP’s i.MX platform, which make use of the i.MX multimedia capabilities.
There are two major commands:
gst-inspect - allows you to to get documentation on available elements and detailed information on a specific element.
gst-launch - allows you to create and execute GStreamer pipelines.
root@neuralplex:~# gst-inspect-1.0 | grep sinkpulseaudio: pulsesink: PulseAudio Audio Sinkhls: hlssink2: HTTP Live Streaming sinkhls: hlssink: HTTP Live Streaming sinkbluez: avdtpsink: Bluetooth AVDTP sinkbluez: a2dpsink: Bluetooth A2DP sinkcoreelements: filesink: File Sinkcoreelements: fdsink: Filedescriptor Sinkcoreelements: fakesink: Fake Sinkalsa: alsasink: Audio sink (ALSA)gdkpixbuf: gdkpixbufsink: GdkPixbuf sink...Detailed hlep on specific element:
root@neuralplex:~# gst-inspect-1.0 <name of the element>Here are a couple examples of playing video and audio files:
# Play Videogst-launch-1.0 filesrc location=big_buck_bunny_1080p_h264.mov ! decodebin \ ! imxvideoconvert_g2d ! waylandsink
# Play Audiogst-launch-1.0 filesrc location=Sultans_Of_Swing.mp3 ! decodebin ! alsasink
# Play Video and Audiogst-launch-1.0 filesrc location=big_buck_bunny_1080p_h264.mov ! decodebin name=dec \ ! imxvideoconvert_g2d ! waylandsink dec. ! queue ! audioconvert ! alsasink device=hdmi# Speaker Test (Play 440Hz sin wave)speaker-test -c8 -t sin -f440 -P9 -s7
# Speaker Test (Play wav file on specific speaker output)speaker-test -c8 -t wav -w ~/Welcome_to_the_Jungle.wav -P9 -s7
# Speaker Mapping:s1 = OUT1s2 = OUT5s3 = OUT2s4 = AMP_Ls5 = OUT4s6 = OUT3s7 = AMP_Rs8 = OUT6
# Record Audioarecord -D plughw:0,0 -r 48000 -f S32_LE sample.wav -c4
# Play Audioaplay Sultans_Of_Swing.wavAudio Routing
Section titled “Audio Routing”The NeuralPlex has two amplified speaker outputs for connecting directly to two speakers for stereo audio. These two channels are connected to outputs 7 and 8 on the audio codec. When trying to play an audio file in Qt, this typically defaults to channels 1 and 2. Audio routing enables Qt to play audio on channels 1 and 2, and ALSA knows to re-route the audio to channels 7 and 8 in the backend. To adjust audio routing, edit the /etc/asound.conf and add entries for ttable. As shown below, (index zero-based) channel 0 is re-routed to channel 6 and volume is set to 25%, and channel 1 is re-routed to channel 7 and volume is set to 25%.
pcm.!default { type asym playback.pcm { type plug slave { pcm "hw:PCM3168A,1" rate 48000 format S24_LE channels 8 } # Route audio amp channels 6 and 7 to the # front left and right speakers and attenuate to 25% ttable.0.6 = 0.25 ttable.1.7 = 0.25 } capture.pcm { type plug slave { pcm "hw:PCM3168A,0" rate 48000 format S32_LE channels 6 } }}
# Bluetooth A2DP sinkpcm.bt-sink { type plug slave { pcm "hw:PCM3168A,1" rate 48000 format S24_LE channels 8 } # Route audio amp channels 6 and 7 to the # front left and right speakers and attenuate to 25% ttable.0.6 = 0.25 ttable.1.7 = 0.25}
# HDMI Audio Outputpcm.!hdmi { type plug slave { pcm "hw:imxaudiohdmitx,0" rate 48000 format S32_LE channels 2 }}
ctl.!default { type hw card PCM3168A}Bluetooth Audio
Section titled “Bluetooth Audio”For Bluetooth audio transmission, NeuralPlex uses the BlueALSA backend, enabling audio data exchange via Bluetooth with audio playback/capture devices, such as smartphones, laptops, headsets, and/or speakers.
The following sections have examples of how to use the NeuralPlex as a Bluetooth speaker for your host device
Connect Phone to NeuralPlex
Section titled “Connect Phone to NeuralPlex”-
Make the Board Discoverable and Pairable:
Enter
bluetoothctl:Terminal window root@neuralplex:~# bluetoothctlThen run:
bluetoothctl [bluetooth]# power on[bluetooth]# discoverable on[bluetooth]# pairable on -
Pair and Connect from Your Phone:
On your phone, enable Bluetooth, search for devices, and pair with the NeuralPlex (it should appear as “neuralplex”). While
bluetoothctlis open, you will need to typeyesto authorize multiple services (audio and phone calls) during the pairing process. Once paired, connect the phone to the NeuralPlex as an audio device (A2DP profile). Your phone should show it as connected for media audio. -
Trust device (optional)
If you wish to add your phone to the list of devices to trust, which avoids needing to re-pair each time you connect, make a note of your phone’s MAC address and execute the following command:
bluetoothctl # Use your phone's MAC address (e.g. 00:11:22:33:44:55)[bluetooth]# trust 00:11:22:33:44:55Exit
bluetoothctlwithexitorCtrl+D. -
Play Audio
Before you can play audio from your phone, you will need to ensure that the
bluealsa-aplayservice is running:Enable Bluetooth Audio # Check the status of the blueasla-aplay serviceroot@neuralplex:~# systemctl status bluealsa-aplay# If it's not running, enable and start it:root@neuralplex:~# systemctl enable bluealsa-aplayroot@neuralplex:~# systemctl start bluealsa-aplayPlay an audio file on your phone, and will be streamed to the
bt-sinkprofile in ALSA.
Connect NeuralPlex to phone
Section titled “Connect NeuralPlex to phone”-
Open
bluetoothctlTerminal window root@neuralplex:~# bluetoothctl -
Inside the prompt, power on Bluetooth
bluetoothctl [bluetooth]# power on -
Start scanning for devices
bluetoothctl [bluetooth]# scan on -
Find your device’s MAC address (e.g., 00:11:22:33:44:55)
-
Pair, Trust, and Connect
bluetoothctl [bluetooth]# pair 00:11:22:33:44:55[bluetooth]# trust 00:11:22:33:44:55[bluetooth]# connect 00:11:22:33:44:55 -
Exit
bluetoothctl [bluetooth]# quit