gpt4 book ai didi

python - gstreamer playbin - 在 Windows 上设置 uri

转载 作者:行者123 更新时间:2023-11-28 19:41:11 25 4
gpt4 key购买 nike

我正在尝试使用此站点上的 CLI 示例播放一些音频文件:

http://pygstdocs.berlios.de/pygst-tutorial/playbin.html http://pygstdocs.berlios.de/pygst-tutorial/playbin.html

我在 Windows 上读取文件时出错。我指定以下路径:

$ python cliplayer.py C:\\voice.mp3

0:00:00.125000000 3788 009DA010 ERROR basesrc
gstbasesrc.c:2834:gst_base_src_activate_pull:<source> Failed to start in
pull mode
Error: Could not open resource for reading.
..\..\..\Source\gst-plugins-base\ext\gio\gstgiosrc.c(324):
gst_gio_src_get_stream ():
/GstPlayBin2:player/GstURIDecodeBin:uridecodebin0/GstGioSrc:source:
Could not open location file:///C:/file:/C:/voice.mp3 for reading: Error
opening file: Invalid argument

我应该如何在windows上指定文件路径?

另外,这行代码有什么特别需要我做的吗?

self.player.set_property("uri", "file://" + filepath)

谢谢!

最佳答案

正如您所怀疑的,这段代码写得相当糟糕:

for filepath in sys.argv[1:]:
# ...
self.player.set_property("uri", "file://" + filepath)

使用这样的东西:

'file:' + urllib.pathname2url(filepath)

并且(在命令行中)以正常的 Windows 表示法指定文件路径,例如C:\a\b.mp3.

关于python - gstreamer playbin - 在 Windows 上设置 uri,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2216064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com