【问题标题】:Limiting send rate of gstreamer's udpsink限制 gstreamer 的 udpsink 的发送速率
【发布时间】:2013-06-17 13:51:04
【问题描述】:

如果我发送数据而不进行多路分解,有没有办法限制 gstreamer 的 udpsink?

我有一个管道需要发送未复用的流。

filesrc ! tee name=t ! tsdemux ! ffdec_h264 ! videosink t. udpsink

主要关注点是:filesrc ! udpsink

我看不出有任何方法可以通过 filesrc、queue 或 udpsink 选项来限制它。使用sync 不起作用,因为我假设没有要同步的媒体流。因此,使用该管道的结果是数据尽可能快地通过 udpsink 馈送,而接收 udpsrc 无法处理。

我们已经尝试使用appsrc作为基本元素编写我们自己的udpsink,使用这个数据包限制方案(在数据包发送方法中有一个thread.sleep(throttleDelay);):

/**
 * Update the delay to pause the packet sending thread.
 * Calculated by dividing how many bytes (roughly) need to be sent <code>packMaxSize</code>
 * by the target bytes/sec rate to get how many seconds are needed. Then multiplying to get
 * time in milliseconds.
 */
private void updateThrottle() {
  if (targetRate > 0)
  {
    throttleDelay = (long)((1000.0 * packetMaxSize) / (double)targetRate);
    if (throttleDelay < 0) {
      throttleDelay = 0;
    }
  } else {
    throttleDelay = 0;
  }
}

但是无论速度设置如何,这似乎都不起作用。太慢了,一帧就通过了。太快了,一两个就通过了。在“正确”的速度 (500 kB/s) 下,帧以 0.5-2 FPS 的速度进入,但已严重损坏。

这是在代码中解决此问题的正确方法吗? gstreamer 有没有办法限制吞吐量?

【问题讨论】:

    标签: java gstreamer java-gstreamer


    【解决方案1】:

    您可能想要做的是使用 RTP 作为您的传输协议。通过使用提供的 rtph264pay,您可以设置 MTU 大小,例如:

    filesrc !  tsdemux ! tee name=t ! ffdec_h264 ! videosink t. rtph264pay mtu=1300 ! udpsink
    

    应该是诀窍。

    【讨论】:

    • 这不是问题,您不能通过未复用的方式发送文件(如问题中所述)吗?我也一直在尝试通过 UDP 获取文件(MKV),但未能成功。不过,我已经能够使用 RTP 获得单个视频流 - 类似于您所描述的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多