微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将 uridecodebin 动态添加到合成器

如何解决将 uridecodebin 动态添加到合成器

我正在尝试将另一个 uridecodebin 动态添加compositor/audiomixer

这是我的“开始”管道,它有效:

    compositor name=videomix !  tee name=vo 
    audiomixer name=audiomix async=true !   tee name=au



    hlssink2  async-handling=true name=output location=out/hlssink.%05d.ts playlist-location=out/out.m3u8  sync=true target-duration=10 playlist-length=5 max-files=5 name=hls 
    vo. 
            ! queue ! videoconvert ! videoscale ! videorate
            !   x264enc cabac=false  key-int-max=50 quantizer=0  pass=0 speed-preset=ultrafast  tune=zerolatency bitrate=8000   byte-stream=true ! video/x-h264,width=1920,height=1080,pixel-aspect-ratio=1/1,framerate=25/1,format=RGBA,profile=constrained-baseline ! hls.video
    au. 
            ! audioconvert
            ! audiorate
            ! audioresample
            ! audio/x-raw,rate=44100,layout=interleaved,format=F32LE,channels=2 ! avenc_aac bitrate=128000 ac=2
            ! audio/mpeg
            ! hls.audio


    uridecodebin connection-speed=50000000  uri=https://HLS1        sync=false async=true name=d1 
        d1. ! videoconvert ! videoscale ! video/x-raw,height=1080 ! videomix.
        d1. ! audioconvert
            ! audiorate
            ! audioresample
            ! volume volume=1.0
            ! audiomix.
    
    

    uridecodebin connection-speed=50000000  uri="https://HLS2"      sync=false async=true name=d2
        d2. ! videoconvert ! videoscale ! video/x-raw,height=1080 ! videomix.
        d2. ! audioconvert
            ! audiorate
            ! audioresample
            ! volume volume=1.0
            ! audiomix.
    

我需要 T 恤 - 因为在最终制作中我想制作一个 hls 输出和另一个

我尝试添加另一组 uridecodebin

到正在运行的管道 - 使用 go-gst(但我认为我的问题是一个基本的理解,所以任何语言的任何解决方案都可以 - 移植不应该是问题)

bin := gst.NewBin("dyn1")

// uridecodebin connection-speed=50000000  uri="https://HLS3"       sync=false async=true name=d2
// d2. ! videoconvert ! videoscale ! video/x-raw,height=1080 ! videomix.
// d2. ! audioconvert
//  ! audiorate
//  ! audioresample
//  ! volume volume=1.0
//  ! audiomix.

els,_ := gst.NewElementMany("uridecodebin","videoconvert","videoscale","audioconvert","audiorate","audioresample","volume")

uridecodebin := els[0]
uridecodebin.Set("name","dynamic1")
uridecodebin.Set("uri","https://HLSDYNAMICADDED")
uridecodebin.Set("sync",false)
uridecodebin.Set("async",true)

videoconvert := els[1]
videoscale := els[2]
audioconvert := els[3]
audiorate := els[4]
audioresample := els[5]
volume := els[6]

gst.ElementLinkMany(uridecodebin,videoconvert,videoscale)
gst.ElementLinkMany(uridecodebin,audioconvert,audiorate,audioresample,volume)

bin.AddMany(uridecodebin,videoscale,volume)

videomixer,_ := pipeline.GetElementByName("videomix")
audiomixer,_ := pipeline.GetElementByName("audiomix")

pipeline.Add(bin.Element)

volume.Link(audiomixer)
videoscale.LinkFiltered(videomixer,gst.NewCapsFromString("video/x-raw,height=1080"))
bin.SetState(gst.StatePaused)

当我运行管道时,它可以工作,并且有几秒钟的延迟,“添加”发生了,管道崩溃了:

    ERROR: Internal data stream error.
    DEBUG: ../gst-libs/gst/adaptivedemux/gstadaptivedemux.c(3891): 
    gst_adaptive_demux_stream_download_loop (): 
/GstPipeline:pipeline0/GstBin:dyn1/GstURIDecodeBin:dynamic1/GstDecodeBin:decodebin3/GstHLSDemux:hlsdemux3:
streaming stopped,reason not-linked (-1)

解决方法

检查函数的错误返回值。

gst.ElementLinkMany(uridecodebin,...) 将在您的代码中失败:uridecodebin 动态添加焊盘,您需要从 pad-added 信号链接。

参见例如herehere 在 GStreamer 文档中了解更多详情。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。