通过UDP流传输.ts文件

3
我想通过UDP流传输.ts文件,为此我使用了以下管道。

但是在一秒钟内就到达了EOS。

GST_DEBUG=3 gst-launch-1.0 -v filesrc location=avm.ts ! queue ! tsparse ! rtpmp2tpay ! udpsink host=192.168.1.139 port=8080

Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.177011430

接收端无法接收到完整数据,只有前几帧数据能够被接收,这是由于发送端立即退出导致的。

在流媒体中播放一个包含视频和文本数据的 .ts 文件时,在接收端只能获取到文本数据。

在发送端出现了以下调试信息。

0:00:00.030345526  7863       0xd9df60 WARN                 basesrc gstbasesrc.c:3483:gst_base_src_start_complete:<filesrc0> pad not activated yet
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/MpegTsMux:mpegtsmux0.GstPad:sink_65: caps = "application/x-metadata\,\ standard\=\(string\)klv"
0:00:00.031289005  7863       0xd710f0 FIXME               basesink gstbasesink.c:3064:gst_base_sink_default_event:<udpsink0> stream-start event without group-id. Consider implementing group-id handling in the upstream elements

当我更改了管道并添加身份验证时,例如:

gst-launch-1.0 filesrc location=vfpd.ts ! queue ! tsparse ! rtpmp2tpay ! identity silent=false ! udpsink -v host=192.168.1.139 port=8765

如果你收到太多类似下面这样的消息,

/GstPipeline:pipeline0/GstIdentity:identity0: last-message = chain   ******* (identity0:sink) (1328 bytes, dts: none, pts:none, duration: none, offset: -1, offset_end: -1, flags: 00004000 tag-memory ) 0x7fcaf40abac0
/GstPipeline:pipeline0/GstIdentity:identity0: last-message = chain   ******* (identity0:sink) (200 bytes, dts: none, pts:none, duration: none, offset: -1, offset_end: -1, flags: 00004000 tag-memory ) 0x7fcaf40abdf0
/GstPipeline:pipeline0/GstIdentity:identity0: last-message = chain   ******* (identity0:sink) (1328 bytes, dts: none, pts:none, duration: none, offset: -1, offset_end: -1, flags: 00004000 tag-memory ) 0x7fcaf40db7f0
/GstPipeline:pipeline0/GstIdentity:identity0: last-message = chain   ******* (identity0:sink) (1328 bytes, dts: none, pts:none, duration: none, offset: -1, offset_end: -1, flags: 00004000 tag-memory ) 0x7fcaf409d450
/GstPipeline:pipeline0/GstIdentity:identity0: last-message = chain   ******* (identity0:sink) (1328 bytes, dts: none, pts:none, duration: none, offset: -1, offset_end: -1, flags: 00004000 tag-memory ) 0x7fcaf4007460
/GstPipeline:pipeline0/GstIdentity:identity0: last-message = chain   ******* (identity0:sink) (200 bytes, dts: none, pts:none, duration: none, offset: -1, offset_end: -1, flags: 00004000 tag-memory ) 0x7fcaf40bfc10
/GstPipeline:pipeline0/GstIdentity:identity0: last-message = chain   ******* (identity0:sink) (1328 bytes, dts: none, pts:none, duration: none, offset: -1, offset_end: -1, flags: 00004000 tag-memory ) 0x7fcaf408f000
/GstPipeline:pipeline0/GstIdentity:identity0: last-message = chain   ******* (identity0:sink) (1328 bytes, dts: none, pts:none, duration: none, offset: -1, offset_end: -1, flags: 00004000 tag-memory ) 0x7fcaf409d560
/GstPipeline:pipeline0/GstIdentity:identity0: last-message = chain   ******* (identity0:sink) (952 bytes, dts: none, pts:none, duration: none, offset: -1, offset_end: -1, flags: 00004000 tag-memory ) 0x7fcaf408f330
/GstPipeline:pipeline0/GstIdentity:identity0: last-message = event   ******* (identity0:sink) E (type: eos (28174), ) 0x7fcaf4003400

据我所知,这意味着它将在单个实例中发送所有数据包,也就是没有流量控制。

该文件的帧速率为25fps。如何使ts流与同样的流速率进行传输?

这个警告是什么意思?如何解决它?如何解决这个问题?如何降低传输速率?


也许可以尝试在sink上调整同步参数。 - nayana
没有任何改进,什么都没变。 - Prasanth Kumar Arisetti
然后检查日志,找到有趣的内容,并将其放在这里。 - nayana
为了传输 ts 文件,我使用了分离和复用的技术,这会增加处理权重。因此,我想要直接流传输原始 ts 文件,不需要任何复用或解码,如果可以的话,如何实现? - Prasanth Kumar Arisetti
是的,我更新了问题,请再检查一遍。我认为所有帧都在单个实例中流式传输,我能控制像25fps这样的流量吗? - Prasanth Kumar Arisetti
显示剩余2条评论
2个回答

4

首先,我认为管道看起来不错。

从您的更新中:

好像如我所预期的那样,它会一次性传输(正如您已经说明的那样),问题在于在原始流中没有帧内的时间信息(即那些无dts、pts和持续时间的信息)... 有两种可能的解释:.ts文件存在问题... 或者gstreamer管道存在问题...

个人认为您的.ts文件有问题。

为了排除第一个问题,建议使用某些mpeg分析器分析.ts文件。

您应该检查mpeg ts流是否包含正确的PCR值,这是mpeg流的同步信息。

更新:

好的,在进行一些小修改后,我找到了这个解决方案,希望它在接收端能够正常运行。我只测试了流式传输的长度与原始ts文件相同。

gst-launch-1.0 filesrc location=football.ts ! queue ! tsparse set-timestamps=true ! rtpmp2tpay ! udpsink -v host=192.168.1.139 port=8765

set-timestamps 正确地为缓冲区标记了时间信息。


如果.ts文件有问题,那为什么使用playbin时它能够正常播放呢?即使我使用这个管道命令:gst-launch-1.0 filesrc location=vfpd.ts ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink,也能正常播放。 - Prasanth Kumar Arisetti
我相信 ts 文件已经创建成功,并且解码正常。 - Prasanth Kumar Arisetti
当我在tsdemux之后设置identity时,数据包将按照每秒帧数流式传输,而不是一次性传输。 - Prasanth Kumar Arisetti
如果我在第一个管道中删除tsparse,则会出现协商错误,有没有办法替换tsparse以使管道正常工作? - Prasanth Kumar Arisetti
让我们在聊天中继续这个讨论 - Prasanth Kumar Arisetti
显示剩余4条评论

1
我使用了下面的流程,解决了我的问题。
 GST_DEBUG=3 gst-launch-1.0 -v filesrc location=avm.ts ! queue ! tsdemux ! mpegtsmux ! rtpmp2tpay ! udpsink host=192.168.1.139 port=8080

1
请记住在完成代码后及时接受它作为正确答案(下方灰色的选中标记)。 - nayana
你不需要额外的RTP封装。移除rtpmp2pay元素,你就可以使用UDP传输MPEG-TS了。效果很好。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接