写,然后用 gstreamer 读取 rtpopus 到文件?

Write, then read rtpopus to file with gstreamer?

是否可以将 rtpopus 写入文件,然后用 gstreamer 读回?这看起来很简单,但我一无所获,似乎无法在网上找到任何信息。这是我的尝试:

gst-launch-1.0.exe audiotestsrc ! opusenc ! rtpopuspay ! filesink location=test.opus

然后,关闭 运行:

gst-launch-1.0.exe filesrc location="test.opus" ! rtpopusdepay ! fakesink dump=true

gstreamer 失败:

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstFileSrc:filesrc0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstFileSrc:filesrc0:
streaming stopped, reason error (-5)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

我认为这行不通。 RTP 与 UDP 打包有关,因此它可以在通过 UDP 流式传输时工作。

你最好使用支持opus音频的文件容器,比如matroskamux:

gst-launch-1.0 -e audiotestsrc ! audioconvert ! opusenc ! matroskamux ! filesink location=test.mkv

# Let play for 5s and stop with Ctrl-C

# Replay:
gst-launch-1.0 filesrc location=test.mkv ! matroskademux ! opusdec ! audioconvert ! autoaudiosink