GStreamer Woes


#1

Hi all, newbie to Ruby and this group.

My question deals with the Ruby GStreamer bindings. Basically, I
copied and pasted the GStreamer example from the Ruby GNOME2 site and
replaced the mad plugin, which I don’t have on my linux box
appearently, with the spider plugin, and I get nothing when I run the
script.

Which is to say I get no error and I get no sound, just a clean exit as
soon as some messages are printed out. All the objects are being
correctly allocated and all, no nils here, it just doesn’t work.

Am I missing something here? I installed the GNOME2-all package and
all the libglade and gtk stuff work perfect except GStreamer is hating
me. Additionally, the Gst::Thread(which I would rather use)
implementation of the same script functions the same as the
Gst::Pipeline implementation, nothing. I’m at a loss here, I’ve
validated everything, valid mp3, valid allocation, valid libraries,
etc.

If you’re wondering what I’m doing with GStreamer, I am writing a
simple mp3 player for a class project, so I know my GNOME2 install
isn’t bodged since libglade functions.

Help! Thanks :slight_smile:

This output confirms that all the objects are allocated when I put
them, they just don’t work.
#Gst::FileSrc:0xb7c909e4
#Gst::Spider:0xb7c905e8
#Gst::OssSink:0xb778f844
#Gst::Pipeline:0xb7c91998


#2

Also, the exact source I am using is:

require ‘gst’

Gst.init
unless ARGV.length == 1
$stderr.puts "Usage: #{FILE} "
exit 1
end

create a new pipeline to hold the elements

pipeline = Gst::Pipeline.new

create a disk reader

filesrc = Gst::ElementFactory.make(“filesrc”)
filesrc.location = ARGV.last
puts "Using file "+ARGV.last

now it’s time to get the decoder

decoder = Gst::ElementFactory.make(“spider”)

and an audio sink

audiosink = Gst::ElementFactory.make(“alsasink”)

add objects to the main pipeline

puts filesrc, decoder, audiosink, pipeline
pipeline.add(filesrc, decoder, audiosink)

link elements

filesrc >> decoder >> audiosink

start playing

pipeline.play

while pipeline.iterate do end

stop the pipeline

pipeline.stop

puts “all done”

And I am calling it with:
ruby gst_test.rb glyn.mp3


#3

Yes, I had the same suspicion and changed it to:

while pipeline.iterate
puts ‘playing’
end

Which doesn’t work either, and it doesn’t print the message at all
either.

I’m still lost, and this seems to be the best way for me to do this, so
I don’t want to go out and get FMOD which is totally overkill for my
application.

Thanks though.


#4

On Apr 3, 2006, at 12:18 AM, Stupergenius wrote:

while pipeline.iterate do end

What is this line supposed to do?

The syntax for while is

while

end

Could it be that you mean to say

while pipeline.iterate
end

and it’s stopping early?


#5

Hi,

On 4/3/06, Stupergenius removed_email_address@domain.invalid wrote:

create a new pipeline to hold the elements

and an audio sink

pipeline.play
And I am calling it with:
ruby gst_test.rb glyn.mp3

What do you get if you use:

$ gst-launch filesrc location=glyn.mp3 ! spider ! alsasink

syntax not tested :slight_smile:

If nothing, then the problem is probably elsewhere. I suspect you do
not have a MP3 decoder library on your machine and/or I believe the
spider just calls the mad plugin (which you do not have).

Laurent


#6

On Apr 3, 2006, at 2:20 PM, Logan C. wrote:

Frankly I’m confused that
while obj.meth do end isn’t a syntax error…

while 1 do end
[…]
I tried fiddling with it with ParseTree, but it was less than
enlightening:
ParseTree.new.parse_tree(A)[0][3]
=> [:defn, :m, [:scope, [:block, [:args], [:while, [:call,
[:self], :class], true]]]]

Why are you confused that it isn’t a syntax error? Is it simply
because of the lack of a semi between do/end?

while bool-expr [do]
body
end

Given that body is zero or more expressions, it would seem to me to
be perfectly valid as-is.

BTW, there is a much easier way to use ParseTree:

% echo “while 1 do end” | parse_tree_show -f
(eval):1: warning: literal in condition
[[:class,
:Example,
:Object,
[:defn, :example, [:scope, [:block, [:args], [:while, [:lit, 1],
true]]]]]]
% echo “while obj.meth do end” | parse_tree_show -f
[[:class,
:Example,
:Object,
[:defn,
:example,
[:scope,
[:block, [:args], [:while, [:call, [:vcall, :obj], :meth],
true]]]]]]

The next release of ParseTree will make it outputs just:

[[:while, [:call, [:vcall, :obj], :meth], true]]


_why: zenspider’s most intense moments of solice are immediately
following the slaughter […]
_why: that topknot’s the only thing keeping a lid on the righteous anger
bricolage: yeah, that and his flagrant obsession with dvorak


#7

Laurent S. wrote:

exit 1

now it’s time to get the decoder

filesrc >> decoder >> audiosink

syntax not tested :slight_smile:

If nothing, then the problem is probably elsewhere. I suspect you do
not have a MP3 decoder library on your machine and/or I believe the
spider just calls the mad plugin (which you do not have).

Laurent

If nothing, then the problem is probably elsewhere. I suspect you do
not have a MP3 decoder library on your machine and/or I believe the
spider just calls the mad plugin (which you do not have).

Ahh, that seems to be the problem indeed, reading up on spider shows
that it does indeed determine which plugin to use based on the type of
the file. Still, Ruby-GStreamer should throw an error as well like
gst-launch does. Converting the mp3 to a wav produces sound perfectly.
Now off to get more plugins!

Thanks!


#8

On Apr 3, 2006, at 10:51 PM, Ryan D. wrote:

ParseTree.new.parse_tree(A)[0][3]
Given that body is zero or more expressions, it would seem to me to
true]]]]]]
The next release of ParseTree will make it outputs just:

while takes a block argument? I was always under the impression it
was syntax not a method…


#9

On Apr 3, 2006, at 5:03 PM, Stupergenius wrote:

this, so
I don’t want to go out and get FMOD which is totally overkill for my
application.

Thanks though.

Frankly I’m confused that
while obj.meth do end isn’t a syntax error…

Hmm, even

while 1 do end

works
that’s about the weirdest thing ever

I tried fiddling with it with ParseTree, but it was less than
enlightening:
ParseTree.new.parse_tree(A)[0][3]
=> [:defn, :m, [:scope, [:block, [:args], [:while, [:call,
[:self], :class], true]]]]


#10

Do the bindings works with gstreamer 0.10 now ? I’ve tried to contact
the author but didn’t get any response.


#11

Hi,

On 4/4/06, zimbatm removed_email_address@domain.invalid wrote:

Do the bindings works with gstreamer 0.10 now ? I’ve tried to contact
the author but didn’t get any response.

No they don’t. I unfortunately miss the time to do this. If you are
willing to help do not hesitate dive in :slight_smile:

BTW I am the author, but my primary e-mail is down for a while, this

can explain why you did not get a response.

Laurent