GStreamer Woes

S

Stupergenius

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 :)

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>
 
S

Stupergenius

Also, the exact source I am using is:

require 'gst'

Gst.init
unless ARGV.length == 1
$stderr.puts "Usage: #{__FILE__} <mp3 filename>"
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
 
L

Logan Capaldo

--Apple-Mail-22-434204315
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed


while pipeline.iterate do end

What is this line supposed to do?

The syntax for while is

while <condition>
<body>
end

Could it be that you mean to say

while pipeline.iterate
end

and it's stopping early?


--Apple-Mail-22-434204315--
 
S

Stupergenius

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.
 
L

Logan Capaldo

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.

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]]]]
 
L

Laurent Sansonetti

Hi,

Also, the exact source I am using is:

require 'gst'

Gst.init
unless ARGV.length =3D=3D 1
$stderr.puts "Usage: #{__FILE__} <mp3 filename>"
exit 1
end

# create a new pipeline to hold the elements
pipeline =3D Gst::pipeline.new

# create a disk reader
filesrc =3D Gst::ElementFactory.make("filesrc")
filesrc.location =3D ARGV.last
puts "Using file "+ARGV.last

# now it's time to get the decoder
decoder =3D Gst::ElementFactory.make("spider")

# and an audio sink
audiosink =3D 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

What do you get if you use:

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

# syntax not tested :)

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
 
R

Ryan Davis

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, :eek:bj], :meth],
true]]]]]]

The next release of ParseTree will make it outputs just:

[[:while, [:call, [:vcall, :eek:bj], :meth], true]]
 
S

Stupergenius

Laurent said:
Hi,



What do you get if you use:

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

# syntax not tested :)

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!
 
L

Logan Capaldo

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, :eek:bj], :meth],
true]]]]]]

The next release of ParseTree will make it outputs just:

[[:while, [:call, [:vcall, :eek:bj], :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

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

zimbatm

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

Laurent Sansonetti

Hi,

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 :)

# 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top