【发布时间】: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