gstreamer 将 audio/mpeg 转换为 audio/x-raw
gstreamer convert audio/mpeg to audio/x-raw
哪些 gstreamer 元素会将 audio/mpeg 的输入转换为 audio/x-raw?
背景
我正在尝试了解如何 assemble gstreamer 管道从 MPEG/TS 流中提取一些音频并将其保存在 wav 文件中。
我可以使用 MPEG 音频格式从传输流中保存音频:
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%)
但我不太清楚如何将 mpeg 音频转换为 x-raw/PCM/wav 以便作为原始管道的一部分或通过新管道进行进一步操作。
在我看来应该是这样的:
gst-launch-1.0 filesrc location=audio.mp2 ! audio/mpeg ! audioconvert ! wavenc ! filesink location=audio.wav
但是 audioconvert 期望 audio/x-raw 所以这失败了:
WARNING: erroneous pipeline: could not link filesrc0 to audioconvert0, audioconvert0 can't handle caps audio/mpeg
我不清楚哪些元素可以接受 audio/mpeg 或者如何找到它们。 gst-inspect 告诉您插件的作用,但我需要一种方法来列出具有给定 src 或接收器类型的插件。
gst-inspect表明wavparse可以产生audio/mpeg和mad 可以将其转换为 mp3,但两者都无济于事。
我还假设设计 gstreamer 管道的一个好方法是使用 gst-launch 快速创建一个执行正确操作的命令行,然后将其翻译成 C++。然而,这里的大部分文档和问题似乎都是直接从 C++ 开始的。我是不是漏掉了什么技巧?
一个适用于 MPEG 音频的插件是 mpg123audiodec,使用 libmpg123
参见 - 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]
这是最近从 'ugly' 插件组移至好的插件:
gst-plugins-ugly-1.14.0/新闻
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
使用它的命令行是:
gst-launch-1.0 filesrc location=audio.mp2 ! audio/mpeg ! mpg123audiodec ! wavenc ! filesink location=audio.wav
哪些 gstreamer 元素会将 audio/mpeg 的输入转换为 audio/x-raw?
背景
我正在尝试了解如何 assemble gstreamer 管道从 MPEG/TS 流中提取一些音频并将其保存在 wav 文件中。 我可以使用 MPEG 音频格式从传输流中保存音频:
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%)
但我不太清楚如何将 mpeg 音频转换为 x-raw/PCM/wav 以便作为原始管道的一部分或通过新管道进行进一步操作。 在我看来应该是这样的:
gst-launch-1.0 filesrc location=audio.mp2 ! audio/mpeg ! audioconvert ! wavenc ! filesink location=audio.wav
但是 audioconvert 期望 audio/x-raw 所以这失败了:
WARNING: erroneous pipeline: could not link filesrc0 to audioconvert0, audioconvert0 can't handle caps audio/mpeg
我不清楚哪些元素可以接受 audio/mpeg 或者如何找到它们。 gst-inspect 告诉您插件的作用,但我需要一种方法来列出具有给定 src 或接收器类型的插件。 gst-inspect表明wavparse可以产生audio/mpeg和mad 可以将其转换为 mp3,但两者都无济于事。
我还假设设计 gstreamer 管道的一个好方法是使用 gst-launch 快速创建一个执行正确操作的命令行,然后将其翻译成 C++。然而,这里的大部分文档和问题似乎都是直接从 C++ 开始的。我是不是漏掉了什么技巧?
一个适用于 MPEG 音频的插件是 mpg123audiodec,使用 libmpg123 参见 - 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]
这是最近从 'ugly' 插件组移至好的插件:
gst-plugins-ugly-1.14.0/新闻
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
使用它的命令行是:
gst-launch-1.0 filesrc location=audio.mp2 ! audio/mpeg ! mpg123audiodec ! wavenc ! filesink location=audio.wav