Rtsp stream(s) to gtk4 grid

well that’s kind of where i started with the gio.inputstream, as i assumed i should use the gtk_media_file_new_for_input_stream instead of gtk_media_file_new_for_filename.

That being said, i’m trying gtk_media_file_new_for_filename , but i’m not sure how to get that attached to my grid.

There is some other issue with input streams and the GStreamer backend, see here: https://gitlab.gnome.org/GNOME/gtk/-/issues/4062

You might want to try something like this:

gtk_media_file_new_for_file(g_file_new_for_uri("rtsp://mystream"))

And I think that might work using rtspsrc?

There is some other issue with input streams and the GStreamer backend, see here: https://gitlab.gnome.org/GNOME/gtk/-/issues/4062

good to know, thanks.

You might want to try something like this:

gtk_media_file_new_for_file(g_file_new_for_uri("rtsp://mystream"))

Right, but my problem right now is: assuming i have a media module that works(i have one that is not throwing type errors that i want to test in my gui. see below), what is the Chain o’ Widgets to get it to render in a grid?

i have (using the nim gintro bindings):

media_file1 = gtk4.newMediaFileForFilename("rtsp://admin:passwd@192.168.1.5:554")

Gtk.Grid wants a widget when attempting to attach to it, and the media modules are not widgets. I’m guessing i’m supposed to use Gdk.Paintable somehow, but i’m not seeing how from the text on it’s api docs page…

You would have to use a file object with a URI, not a filename. The media stream can then be attached to a GtkVideo with set_media_stream, or to a GtkPicture with set_paintable.

1 Like

as an example i have this:

import gintro/[gtk4, gobject, gio, gdk4]

proc activate(app: gtk4.Application) =
  let window = newApplicationWindow(app)
  let grid = newGrid()
  let media_file1 = gtk4.newMediaFileForFile(gio.newGFileForUri("rtsp://admin:passwd@192.168.1.5:554"))  
  let picture1 = gtk4.newPicture()
  gtk4.setPaintable(picture1, cast[gdk4.Paintable](media_file1))
  window.defaultSize = (800, 600)
  grid.columnSpacing = 25 
  grid.attach(picture1, 0, -1)    
  window.setChild(grid)
  window.show

proc main =
  let app = newApplication("org.gtk.example")
  app.connect("activate", activate)
  let status = app.run
  quit(status)

main()

but it seems that the gtk4.newMediaFileForFile(gio.newGFileForUri("rtsp://admin:passwd@192.168.1.5:554"))

part is not working. I do have the real rtsp stream creds in the actual code. Everything appears to be attached properly, but no rtsp stream plays. I also tried with a gtk4.Video and set_media_stream with the same result. Any ideas?

I think you have to do this somewhere in there:

media_file1.play()
1 Like

unfortunately, that didn’t work.

Does it work if you play it on the command line? Something like: gst-launch-1.0 -v playbin uri=rtsp://admin:passwd@192.168.1.5:554

yes, it does. also, the gintro gstreamer example works here: https://github.com/StefanSalewski/gintro#a-gstreamer-example

but parseLaunch just uses it’s own window, of course.

Hmm, I can’t figure out what’s going on, I tried to do it using this demo rtsp stream and it seems to be playing the audio but I see no video. So it’s half working :slight_smile: but there is probably a bug somewhere and I’m not sure how to report it, maybe someone who is really good at reading gstreamer debug logs could figure something out.

I don’t have nim installed but here is my very similar javascript test program I was using:

imports.gi.versions.Gtk = '4.0';
const { Gio, Gtk } = imports.gi;

let app = new Gtk.Application({ application_id: 'com.MediaTest' });

app.connect('activate', () => {
  const win = new Gtk.ApplicationWindow({ application: app, default_width: 600, default_height: 400 });
  const file = Gio.File.new_for_uri('rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_175k.mov');
  const media = Gtk.MediaFile.new_for_file(file);
  const picture = new Gtk.Picture();
  picture.set_paintable(media);
  win.set_child(picture);
  media.play();
  win.present();
});

app.run([]);

thanks. i had forgotten about the rtsp stream for testing. the bigbuckbunny rtsp stream works in my example program with the media_file1.play() added (both audio and video), but my ipcam rtsp stream uri does not. the same cam uri that works with gst-launch. so, maybe the gio.newGFileForUri doesn’t like the fact that it’s not a stream of an actual file? i don’t remember/know exactly how that works under the hood, so maybe that’s fool talk. :slight_smile:

idk, if it would matter for you but i have my media_file1.play() right after the setPaintable and before the picture gets attached to the window.

@ebassi do you know where gtk4 ended up in regards to this?

is there a way/what is the method for directly connecting a playbin pipeline to a widget without cpu copy? It doesn’t look like there’s a way to feed my rtsp ipcam stream to a paintable like newMediaFileForPipeline(), for instance. Or maybe a more manual way that currently works for gtk4? (preferably with no cpu copy)

thanks

Zero copy OpenGL rendering should be supported with the gstreamer backend since this commit: https://gitlab.gnome.org/GNOME/gtk/-/commit/7901ab857b689b8777cb8f8aeb431951c9554066

cool, but how do you get a ipcam rtsp stream into the MediaFile? gio.newGFileForUri seems to be picky about the rtsp stream in some way.

I’m not sure, I think this could be a GTK bug…

1 Like

this one looks scary for cpu usage: https://gitlab.gnome.org/GNOME/gtk/-/issues/4184

possibly related to the gio.newGFileForUri pickyness question: https://gitlab.gnome.org/GNOME/gtk/-/issues/3902

That first one is very odd to me since all gtk_video_new_for_filename does is call gtk_video_set_media_stream internally.

I reported the issue, while i work on the rest of the application.

https://gitlab.gnome.org/GNOME/gtk/-/issues/4367

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.