【问题标题】:Gstreamer playing audio from video file with (uri)decodebin - high CPU usageGstreamer 使用 (uri)decodebin 从视频文件中播放音频 - 高 CPU 使用率
【发布时间】:2017-05-28 17:49:35
【问题描述】:

我正在使用 gstreamer 从文件/RTMP/RTSP 流中转换音频,然后对其进行分析。

问题是,如果我的源文件是视频或视频流,gstreamer 会占用大量 CPU。

示例 1(视频)- 如 htop 所说,使用 30-35% 的 CPU。

gst-launch-1.0 uridecodebin uri='test.mp4' ! autoaudiosink

示例 2(使用 ffmpeg -c copy 转换的上述视频文件中的音频)- 使用 2-4% 的 CPU

gst-launch-1.0 uridecodebin uri='test.mp3' ! autoaudiosink

如何指定我只需要视频文件中的音频源?

我正在使用 decodebin,因为我不知道我会从用户那里获得哪些文件(格式)。

【问题讨论】:

    标签: audio ffmpeg gstreamer


    【解决方案1】:

    对于上述示例,您可以使用 playbin 设置 flags 属性:

    flags               : Flags to control behaviour
                            flags: readable, writable
                            Flags "GstPlayFlags" Default: 0x00000617, "soft-colorbalance+deinterlace+soft-volume+text+audio+video"
                               (0x00000001): video            - Render the video stream
                               (0x00000002): audio            - Render the audio stream
                               (0x00000004): text             - Render subtitles
                               (0x00000008): vis              - Render visualisation when no video is present
                               (0x00000010): soft-volume      - Use software volume
                               (0x00000020): native-audio     - Only use native audio formats
                               (0x00000040): native-video     - Only use native video formats
                               (0x00000080): download         - Attempt progressive download buffering
                               (0x00000100): buffering        - Buffer demuxed/parsed data
                               (0x00000200): deinterlace      - Deinterlace video if necessary
                               (0x00000400): soft-colorbalance - Use software color balance
    

    如果你想提取音频并对其进行转码,你可能需要编写一些代码。

    【讨论】:

    • 我已经有一个带有 decodebin 和 appsink 的工作管道,它让我可以访问原始转码 pcm16 16khz 音频,谢谢!好像我发现了问题。 Decodebin2(顺便说一下在playbin中使用)解码它可以在源文件/流/等中找到的所有流。似乎现在正在开发的 decodebin3 将摆脱那些无用的 CPU 使用率。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多