Reputation: 5581
What gstreamer element(s) will convert a input of audio/mpeg into audio/x-raw?
I am trying to grok how to assemble gstreamer pipelines to extract some audio from a MPEG/TS stream and save it in a wav file. I can save the audio from a transport stream in MPEG audio format using:
gst-launch-1.0 udpsrc port=1235 caps="application/x-rtp" ! rtpjitterbuffer \
! rtpmp2tdepay ! tsdemux program-number=4352 \
! mpegaudioparse ! queue ! filesink location=audio.mp2
>mediainfo audio.mpg
General
Complete name : audio.mpg
Format : MPEG Audio
File size : 169 KiB
Duration : 5 s 400 ms
Overall bit rate mode : Constant
Overall bit rate : 256 kb/s
FileExtension_Invalid : m1a mpa1 mp1 m2a mpa2 mp2 mp3
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 2
Duration : 5 s 400 ms
Bit rate mode : Constant
Bit rate : 256 kb/s
Channel(s) : 2 channels
Sampling rate : 48.0 kHz
Frame rate : 41.667 FPS (1152 SPF)
Compression mode : Lossy
Stream size : 169 KiB (100%)
But I can't quite figure out how to convert the mpeg audio into x-raw/PCM/wav for further manipulation either as part of the original pipeline or via a new one. To my mind it should be something like:
gst-launch-1.0 filesrc location=audio.mp2 ! audio/mpeg ! audioconvert ! wavenc ! filesink location=audio.wav
But audioconvert expects audio/x-raw so this fails with:
WARNING: erroneous pipeline: could not link filesrc0 to audioconvert0, audioconvert0 can't handle caps audio/mpeg
Its not clear to me what elements can accept an audio/mpeg or how to find them. gst-inspect tells you what a plugin does but I need a way to list plugins having a given src or sink type. gst-inspect shows that wavparse can produce audio/mpeg and mad can convert it to mp3 neither of which is helpful.
I am also working under the assumption that a good way to design a gstreamer pipeline is to use gst-launch to quickly create a command line that does the right thing and then translate that into C++. However, most of the documentation and questions here seem to start directly from the C++ instead. Am I missing a trick somewhere?
Upvotes: 0
Views: 3752
Reputation: 5581
A plugin for MPEG audio that works is mpg123audiodec using libmpg123 See - https://gstreamer.freedesktop.org/documentation/plugins.html
>gst-inspect-1.0 mpg123audiodec
[snip]
Pad Templates:
SINK template: 'sink'
Availability: Always
Capabilities:
audio/mpeg
mpegversion: { 1 }
layer: [ 1, 3 ]
rate: { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }
channels: [ 1, 2 ]
parsed: true
[snip]
This was recently moved from the set of 'ugly' plugins to good plugins:
gst-plugins-ugly-1.14.0/NEWS
Plugin and library moves
MPEG-1 audio (mp1, mp2, mp3) decoders and encoders moved to -good
Following the expiration of the last remaining mp3 patents in most
jurisdictions, and the termination of the mp3 licensing program, as well
as the decision by certain distros to officially start shipping full mp3
decoding and encoding support, these plugins should now no longer be
problematic for most distributors and have therefore been moved from
-ugly and -bad to gst-plugins-good. Distributors can still disable these
plugins if desired.
In particular these are:
- mpg123audiodec: an mp1/mp2/mp3 audio decoder using libmpg123
- lamemp3enc: an mp3 encoder using LAME
- twolamemp2enc: an mp2 encoder using TwoLAME
A command line for using this is:
gst-launch-1.0 filesrc location=audio.mp2 ! audio/mpeg ! mpg123audiodec ! wavenc ! filesink location=audio.wav
Upvotes: 1