【问题标题】:gstreamer convert audio/mpeg to audio/x-rawgstreamer 将音频/mpeg 转换为音频/x-raw
【发布时间】:2018-04-10 18:40:26
【问题描述】:

哪些 gstreamer 元素会将音频/mpeg 的输入转换为音频/x-raw?

背景

我正在尝试了解如何组装 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 或 sink 类型的插件。 gst-inspect 表明 wavparse 可以产生 audio/mpeg 并且 mad 可以将其转换为 mp3 两者都不是有帮助。

我还假设设计 gstreamer 管道的一种好方法是使用 gst-launch 快速创建执行正确操作的命令行,然后将其转换为 C++。但是,这里的大多数文档和问题似乎都是直接从 C++ 开始的。我在某个地方漏掉了一个技巧吗?

【问题讨论】:

    标签: audio gstreamer


    【解决方案1】:

    一个适用于 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]
    

    这是最近从“丑陋”插件集转移到好的插件集:

    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
    

    使用它的命令行是:

    gst-launch-1.0 filesrc location=audio.mp2 ! audio/mpeg ! mpg123audiodec ! wavenc ! filesink location=audio.wav
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-31
      • 2017-07-04
      • 2013-05-04
      • 1970-01-01
      • 2017-10-17
      相关资源
      最近更新 更多