7

I am new to gstreamer and trying to use it for some GPU accelerated video decoding on my NVIDIA Jetson ARM based board. I found some python code online which creates a gstreamer pipeline and I was trying to use it to familiarize myself. The code that creates the pipeline is as follows:

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

The full project can be found here (https://github.com/kulve/gst-multiwindow)

Now, whenever I try to create a pipeline from a local file I get the error:

on_error(): (GError('Invalid URI "testfile.avi".',), 'gsturidecodebin.c(1373): gen_source_element (): /GstPipeline:pipeline0/GstURIDecodeBin:decodebin')

I have a feeling this error is because a local file is not a valid uri. I tried passing it as file://testfile.avi but that did not work either returning could not open resource for reading error.

Is there a change in this code that may help me play local video files?

Luca
  • 10,458
  • 24
  • 107
  • 234

3 Answers3

6

The file/URI to play should be set via the “uri” property. This must be an absolute URI, relative file paths are not allowed.

Ex:

The file.avi is in /home/user/Downloads, then:

uri=file:///home/user/Downloads/file.avi

2

You are only giving the file name as input. The URI property takes standard URI's as input. Moreover only reletive URI's are not supported for uridecodebin. The correct URI is like:

file://localhost/absolute/path/to/file

or if you want to remove the host name (note the additional slash):

file:///absolute/path/to/file

Some parsers are intelligent enough to parse relative paths as well (uridecodebin doesn't support this). In your case it could've been specified as:

file:./testfile.avi

For more details about the File URI scheme.

Umer Javaid
  • 200
  • 1
  • 7
1

URI Must be starts with URI Tag, like http, tcp, rtsp, file. and then : and at the end Location of the resource.

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