首页 > 解决方案 > Gstreamer:到 VP8/webm 录制的 RTP 流不会产生可搜索的文件

问题描述

我正在使用 Gstreamer 将 WebRTC 流捕获到 webm 文件。我注意到在 rtp 流中使用 VP8 编码时,生成的文件在任何播放器(例如 Chrome 或 VLC)中都不可搜索。通过可搜索,我的意思是您不能从流中的任意点播放文件,它只能在播放时从一开始就开始。

我改为使用带有 rtp 的 h264 编码,并且生成的 mp4 文件是可搜索的。此外,删除 rtp 编码/解码会为 VP8 生成可搜索的输出文件。

这是产生这些结果的测试管道。

# produces a valid webm file that is not seekable (I need this to be seekable)
gst-launch-1.0 -e \
  autovideosrc ! autovideoconvert ! vp8enc ! rtpvp8pay ! rtpvp8depay ! webmmux ! \
  filesink location=test.webm

# produces a valid webm file that is seekable
gst-launch-1.0 -e \
  autovideosrc ! autovideoconvert ! vp8enc ! webmmux ! \
  filesink location=test.webm

# produces a valid mp4 file that is seekable
gst-launch-1.0 -e \
  autovideosrc ! autovideoconvert ! x264enc ! rtph264pay ! rtph264depay ! h264parse ! mp4mux ! \
  filesink location=test.mp4


有没有一种方法可以创建可搜索的 rtp/VP8/matroska 录音?这是 Gstreamer 中的错误吗?

我在 Ubuntu 上使用了 Gstreamer 1.14 和 1.18,结果相同。

标签: webrtcgstreamerwebmvp8

解决方案


这是 webm 格式中的一个奇怪之处,它也会影响 MediaRecorder API。见这里

简而言之,您需要在停止录制时更新文件开头的持续时间元数据。


推荐阅读