gstreamer uri vs 文件:无法播放本地视频文件
gstreamer uri vs files: Cannot play local video file
我是 gstreamer 的新手,正在尝试在我的基于 NVIDIA Jetson ARM 的主板上使用它进行一些 GPU 加速视频解码。我在网上找到了一些创建 gstreamer 管道的 python 代码,我试图用它来熟悉自己。创建管道的代码如下:
def new_pipeline(self, mediauri):
pipeline = Gst.Pipeline()
if (not pipeline):
print ('Failed to create pipeline')
exit (-1)
# Create bus to get events from GStreamer pipeline
bus = pipeline.get_bus()
self.bus.append(bus)
bus.add_signal_watch()
bus.connect('message::error', self.on_error)
# This is needed to make the video output in our DrawingArea:
bus.enable_sync_message_emission()
bus.connect('sync-message::element', self.on_sync_message)
# Create GStreamer elements
decodebin = Gst.ElementFactory.make('uridecodebin', 'decodebin')
videosink = Gst.ElementFactory.make('nveglglessink', 'videosink')
if (not decodebin or not videosink):
print ('Failed to create uridecodebin and/or nveglglessink')
exit(-1)
# Set properties
decodebin.set_property('uri', mediauri)
videosink.set_property('create-window', False)
# Add elements to the pipeline
pipeline.add(decodebin)
pipeline.add(videosink)
decodebin.connect("pad-added", self.decodebin_pad_added)
return pipeline
完整项目可在此处找到 (https://github.com/kulve/gst-multiwindow)
现在,每当我尝试从本地文件创建管道时,我都会收到错误消息:
on_error(): (GError('Invalid URI "testfile.avi".',), 'gsturidecodebin.c(1373): gen_source_element (): /GstPipeline:pipeline0/GstURIDecodeBin:decodebin')
我感觉这个错误是因为本地文件不是有效的 uri。我尝试将其作为 file://testfile.avi
传递,但无论返回 could not open resource for reading
错误都不起作用。
此代码是否有可以帮助我播放本地视频文件的更改?
要播放的file/URI应该通过“uri”设置属性。这必须是绝对 URI,不允许相对文件路径。
例如:
file.avi在/home/user/Downloads,那么:
uri=文件:///home/user/Downloads/file.avi
URI 必须以URI Tag开头,如http, tcp, rtsp, file。
然后 : 最后是资源的位置。
For Ex : for file /home/Desktop/a.avi
URI : file:/home/Desktop/a.avi
For RTSP,
URI : rtsp://<IP>:<PORT>/<PATH>
ex: rtsp://192.168.1.1/test
您只是将文件名作为输入。 URI 属性 将标准 URI 作为输入。此外,uridecodebin 仅不支持相关 URI。正确的 URI 如下:
file://localhost/absolute/path/to/file
或者如果你想删除主机名(注意额外的斜杠):
file:///absolute/path/to/file
一些解析器足够智能,也可以解析相对路径(uridecodebin 不支持此功能)。在您的情况下,它可以指定为:
file:./testfile.avi
有关 File URI scheme 的更多详细信息。
我是 gstreamer 的新手,正在尝试在我的基于 NVIDIA Jetson ARM 的主板上使用它进行一些 GPU 加速视频解码。我在网上找到了一些创建 gstreamer 管道的 python 代码,我试图用它来熟悉自己。创建管道的代码如下:
def new_pipeline(self, mediauri):
pipeline = Gst.Pipeline()
if (not pipeline):
print ('Failed to create pipeline')
exit (-1)
# Create bus to get events from GStreamer pipeline
bus = pipeline.get_bus()
self.bus.append(bus)
bus.add_signal_watch()
bus.connect('message::error', self.on_error)
# This is needed to make the video output in our DrawingArea:
bus.enable_sync_message_emission()
bus.connect('sync-message::element', self.on_sync_message)
# Create GStreamer elements
decodebin = Gst.ElementFactory.make('uridecodebin', 'decodebin')
videosink = Gst.ElementFactory.make('nveglglessink', 'videosink')
if (not decodebin or not videosink):
print ('Failed to create uridecodebin and/or nveglglessink')
exit(-1)
# Set properties
decodebin.set_property('uri', mediauri)
videosink.set_property('create-window', False)
# Add elements to the pipeline
pipeline.add(decodebin)
pipeline.add(videosink)
decodebin.connect("pad-added", self.decodebin_pad_added)
return pipeline
完整项目可在此处找到 (https://github.com/kulve/gst-multiwindow)
现在,每当我尝试从本地文件创建管道时,我都会收到错误消息:
on_error(): (GError('Invalid URI "testfile.avi".',), 'gsturidecodebin.c(1373): gen_source_element (): /GstPipeline:pipeline0/GstURIDecodeBin:decodebin')
我感觉这个错误是因为本地文件不是有效的 uri。我尝试将其作为 file://testfile.avi
传递,但无论返回 could not open resource for reading
错误都不起作用。
此代码是否有可以帮助我播放本地视频文件的更改?
要播放的file/URI应该通过“uri”设置属性。这必须是绝对 URI,不允许相对文件路径。
例如:
file.avi在/home/user/Downloads,那么:
uri=文件:///home/user/Downloads/file.avi
URI 必须以URI Tag开头,如http, tcp, rtsp, file。 然后 : 最后是资源的位置。
For Ex : for file /home/Desktop/a.avi
URI : file:/home/Desktop/a.avi
For RTSP,
URI : rtsp://<IP>:<PORT>/<PATH>
ex: rtsp://192.168.1.1/test
您只是将文件名作为输入。 URI 属性 将标准 URI 作为输入。此外,uridecodebin 仅不支持相关 URI。正确的 URI 如下:
file://localhost/absolute/path/to/file
或者如果你想删除主机名(注意额外的斜杠):
file:///absolute/path/to/file
一些解析器足够智能,也可以解析相对路径(uridecodebin 不支持此功能)。在您的情况下,它可以指定为:
file:./testfile.avi
有关 File URI scheme 的更多详细信息。