[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

GStreamer Woes

Stupergenius

4/3/2006 2:02:00 AM

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>

10 Answers

Stupergenius

4/3/2006 4:14:00 AM

0

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

Logan Capaldo

4/3/2006 8:54:00 PM

0


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 <condition>
<body>
end

Could it be that you mean to say

while pipeline.iterate
end

and it's stopping early?

Stupergenius

4/3/2006 9:01:00 PM

0

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.

Logan Capaldo

4/3/2006 9:21:00 PM

0


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

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







Laurent Sansonetti

4/3/2006 10:41:00 PM

0

Hi,

On 4/3/06, Stupergenius <stupergenius@gmail.com> wrote:
> 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
>

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


Ryan Davis

4/4/2006 2:52:00 AM

0


On Apr 3, 2006, at 2:20 PM, Logan Capaldo 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



Stupergenius

4/4/2006 3:07:00 AM

0


Laurent Sansonetti wrote:
> Hi,
>
> On 4/3/06, Stupergenius <stupergenius@gmail.com> wrote:
> > 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
> >
>
> 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!

Logan Capaldo

4/4/2006 4:18:00 AM

0


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

>
> On Apr 3, 2006, at 2:20 PM, Logan Capaldo 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
>
>

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




zimba.tm@gmail.com

4/4/2006 2:41:00 PM

0

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

Laurent Sansonetti

4/4/2006 2:56:00 PM

0

Hi,

On 4/4/06, zimbatm <zimba.tm@gmail.com> 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 :-)

# 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