Forum: Ruby GStreamer Woes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
94a30535d38606170f571898d96b6181?d=identicon&s=25 Stupergenius (Guest)
on 2006-04-03 04:06
(Received via mailing list)
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>
94a30535d38606170f571898d96b6181?d=identicon&s=25 Stupergenius (Guest)
on 2006-04-03 06:20
(Received via mailing list)
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
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-04-03 22:56
(Received via mailing list)
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?
94a30535d38606170f571898d96b6181?d=identicon&s=25 Stupergenius (Guest)
on 2006-04-03 23:06
(Received via mailing list)
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.
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-04-03 23:21
(Received via mailing list)
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]]]]
Dc32e0513d1a0b086d2afa9311e9e472?d=identicon&s=25 Laurent Sansonetti (Guest)
on 2006-04-04 00:41
(Received via mailing list)
Hi,

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

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
5a837592409354297424994e8d62f722?d=identicon&s=25 Ryan Davis (Guest)
on 2006-04-04 04:53
(Received via mailing list)
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
94a30535d38606170f571898d96b6181?d=identicon&s=25 Stupergenius (Guest)
on 2006-04-04 05:11
(Received via mailing list)
Laurent Sansonetti wrote:
> >   exit 1
> > # now it's time to get the decoder
> > filesrc >> decoder >> audiosink
> >
> # 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!
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-04-04 06:19
(Received via mailing list)
On Apr 3, 2006, at 10:51 PM, Ryan Davis 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...
0bf205083975ef054b4ad08915d1d653?d=identicon&s=25 zimbatm (Guest)
on 2006-04-04 16:46
(Received via mailing list)
Do the bindings works with gstreamer 0.10 now ? I've tried to contact
the author but didn't get any response.
Dc32e0513d1a0b086d2afa9311e9e472?d=identicon&s=25 Laurent Sansonetti (Guest)
on 2006-04-04 16:58
(Received via mailing list)
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
This topic is locked and can not be replied to.