Gstreamer : how to put video in a gtk widget on windows?

Hello,

On windows with old gst version, we use to put video in a
gtk window with xwindow_id:

view = Gst::ElementFactory.make(‘playbin’)
view.video_sink = Gst::ElementFactory.make(‘directdrawsink’)
handle = Win32API.new(‘user32’, ‘GetForegroundWindow’, [], ‘N’).call
view.video_sink.xwindow_id=handle

but it’s seem that from now ‘xwindow_id’ do not exist.

NOTA:
(view.video_sink.methods - Object.methods) give :

copy,gtype,type,value
(class GLib::Value)

Hi,

2013/9/3 Regis d’Aubarede [email protected]:

NOTA:
(view.video_sink.methods - Object.methods) give :

copy,gtype,type,value
(class GLib::Value)

Please let me identify the problem.
I tried the following codes on Windows.

In GStreamer 0.10 (Ruby/GStreamer 1.2.6 or earlier), “directdrawsink”
exist.

gem "glib2", "1.2.6"
gem "gstreamer", "1.2.6"
require "gst"
p Gst::ElementFactory.make('directdrawsink')
#=> #<Gst::ElementDirectDrawSink:02BC1670 ptr=02C3D918>

In GStreamer 1.0 (Ruby/GStreamer 2.0.0 or later), “directdrawsink”
does not seem to exist.

gem "glib2", "2.0.2"
gem "gstreamer", "2.0.2"
require "gst"
p Gst::ElementFactory.make('directdrawsink')
#=> nil

I’m looking for a list of elements.


Masafumi Y.
GitHub: myokoym

I’m looking for a list of elements.

here the code (i try to use d3dvideosink) :
require “gtk3”
require “gst”

Gem.loaded_specs.map {|n,g| puts "  | %10s %6s " %

[g.name,g.version] }

window = Gtk::Window.new
wid=Gtk::DrawingArea.new()
wid.set_size_request(200,100)
v =Gst::ElementFactory.make('playbin')
v.video_sink = Gst::ElementFactory.make('d3dvideosink')

require('win32api');
handle = Win32API.new('user32', 'GetForegroundWindow', [], 'N').call
p window.window.methods
v.video_sink.xwindow_id(handle) # !!!!scratch!!!!

v.uri = "file:///d:/usr/local/video/avi/film3.avi"

wid.events |= ( ::Gdk::Event::Mask::BUTTON_PRESS_MASK |

::Gdk::Event::mask::POINTER_MOTION_MASK |
::Gdk::Event::mask::BUTTON_RELEASE_MASK)
wid.signal_connect(‘draw’) do |w1,e| end

window.signal_connect("destroy") {Gtk.main_quit}
window.add(wid)
window.show_all
Gtk.main

And the execution:

d:\usr\Ruby\local\Ruiby\samples>ruby v.rb
| pkg-config 1.1.4
| glib2 2.0.2
| gio2 2.0.2
| atk 2.0.2
| cairo 1.12.6
| pango 2.0.2
| gdk_pixbuf2 2.0.2
| gdk3 2.0.2
| gtk3 2.0.2
| gobject-introspection 2.0.2
| gstreamer 2.0.2
DL is deprecated, please use Fiddle
[:to_i, :to_f, :to_s, :to_a, :to_h, :inspect, :&, :|, :^, :nil?, :to_r,
:rationalize, :to_c, :===, :=~, :!~, :eql?, :hash, :<=>, :class,
:singleton_class, :clone, :dup, :taint, :tainted?, :untaint, :untrust,
:untrusted?, :trust, :freeze, :frozen?, :methods, :singleton_methods,
:protected_methods, :private_methods, :public_methods,
:instance_variables, :instance_variable_get, :instance_variable_set,
:instance_variable_defined?, :remove_instance_variable, :instance_of?,
:kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :extend,
:display, :method, :public_method, :define_singleton_method, :object_id,
:to_enum, :enum_for, :==, :equal?, :!, :!=, :instance_eval,
:instance_exec, :send, :id]

(ruby.exe:7228): GStreamer-CRITICAL **: gst_child_proxy_get_property:
assertion G_IS_VALUE (value)' failed v.rb:15:in‘: undefined method `xwindow_id’ for
#<GLib::Value:0692E3B0 ptr=06902908 own=true> (NoMethodError)

That’s work !
Thank you.

Discovering Clutter, it’s seem very mysterious, no tutorials…

bye

Good evening.

2013/9/18 Regis d’Aubarede [email protected]:

Discovering Clutter, it’s seem very mysterious, no tutorials…

I started to write Ruby/Clutter tutorial.

http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-clutter

Tell me if it is difficult to understand.


Masafumi Y.
GitHub: myokoym

Hi,

2013/9/17 Regis d’Aubarede [email protected]:

window = Gtk::Window.new
v.uri = "file:///d:/usr/local/video/avi/film3.avi"

| cairo 1.12.6
:untrusted?, :trust, :freeze, :frozen?, :methods, :singleton_methods,
v.rb:15:in <main>': undefined method xwindow_id’ for
#<GLib::Value:0692E3B0 ptr=06902908 own=true> (NoMethodError)

Attachments:
http://www.ruby-forum.com/attachment/8729/v.rb

Umm… The API seemed to change.

Now, there is also the following way:

require “clutter-gtk” # gem install clutter-gtk (It uses gtk3)
require “clutter-gst” # gem install clutter-gstreamer

clutter = ClutterGtk::Embed.new
stage = clutter.stage

For Clutter-GStreamer 2.0.2. This API will change.

video_texture = ClutterGst::VideoTexture.new
stage.add_child(video_texture)
video_texture.uri = “file:///d:/usr/local/video/avi/film3.avi”
video_texture.playing = true

window = Gtk::Window.new
window.signal_connect(“destroy”) {Gtk.main_quit}
window.add(clutter)
window.show_all
Gtk.main


Masafumi Y.
GitHub: myokoym

Hi,

Regis d’Aubarede wrote in post #1121938:

Found that on wikipedia:
"
Clutter is an open source graphics library for creating
hardware-accelerated user interfaces. It relies upon OpenGL (1.4+) or
OpenGL ES (1.1 or 2.0) for rendering, can be compiled on different
platforms (X11, Wayland, Darwin and Win32) and has multiple bindings to
other languages (including Mono, Perl, Python, Ruby and Vala). It also
supports media playback using GStreamer and 2D graphics rendering using
Cairo.[4]
"

If Clutter is done for performence, its usage via Ruby is it relevant ?

Umm, I don’t know much about it…

I use Gosu for graphics (smooth) animations (sprites,vectors for
games…),
Is Clutter better for that ?

Oh, Gosu is looking good. But I think that uses are different.
Gosu is for game application, and Clutter is for general desktop
application.

Clutter is able to make game application, but it will be some hard work.
If not making game application, I think that Clutter may be better than
Gosu.


Masafumi Y.
GitHub: myokoym

http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-clutter

Tell me if it is difficult to understand.

Nice start !

Found that on wikipedia:
"
Clutter is an open source graphics library for creating
hardware-accelerated user interfaces. It relies upon OpenGL (1.4+) or
OpenGL ES (1.1 or 2.0) for rendering, can be compiled on different
platforms (X11, Wayland, Darwin and Win32) and has multiple bindings to
other languages (including Mono, Perl, Python, Ruby and Vala). It also
supports media playback using GStreamer and 2D graphics rendering using
Cairo.[4]
"

If Clutter is done for performence, its usage via Ruby is it relevant ?
I use Gosu for graphics (smooth) animations (sprites,vectors for
games…),
Is Clutter better for that ?

Video in Ruiby dsl done!

require “gtk3”
require ‘Ruiby’
require “gst”
require “clutter-gtk” # gem install clutter-gtk
require “clutter-gst” # gem install clutter-gstreamer

module Ruiby_dsl

def video(url=nil,w=300,h=200)
clutter = ClutterGtk::Embed.new
video=ClutterGst::VideoTexture.new
clutter.stage.add_child(video)
video.width=w
video.height=h
video.uri = url if url
video.playing = false
isNotify=false
clutter.define_singleton_method(:url=) { |u| video.url = url }
clutter.define_singleton_method(:play) { video.playing = true }
clutter.define_singleton_method(:stop) { video.playing = false }
clutter.define_singleton_method(:progress=) { |pp|
video.progress=(pp) unless isNotify
}
if block_given?
video.signal_connect(“notify”) { |o,v,param|
isNotify=true ;
yield(video.progress()) rescue p $! ;
isNotify=false
}
end
attribs(clutter,{})
end
end

Ruiby.app width: 600,height: 400 do
video_file= ARGV[0] || “d:/usr/XT.avi”
unless File.exists?(video_file)
error(“File video does not exists : ‘#{video_file}’”)
exit!(0)
end
video_url=“file:///#{video_file}”
stack do
@video=video(video_url,600,400-40) {|progress|
@prog && @prog.progress=progress*100
}
flowi do
buttoni(" Start “) { @video.play }
buttoni(” Stop “) { @video.stop }
@prog=slider(0,0,100.0) { |pos| @video.progress= pos/100.0}
buttoni(” Exit ") { exit!(0) }
end
end
end

Screen copy at :
http://raubarede.tumblr.com/post/62084710192/new-video-tag-for-ruiby-works-on-windows