<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Wed Jun 19, 2013 8:22 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Wed Jun 19, 2013 8:22 pm</pubDate>
  <lastBuildDate>Wed Jun 19, 2013 8:22 pm</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: Python ogg converter</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=103723#103723</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=4'&gt;evilnick&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Sat Jan 07, 2012 11:27 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      nice work. Sorry I have not been hanging around in the forums so much or I could have helped you out - but it looks like you did an excellent job on your own!</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=103723#103723</comments>
                                        <author>evilnick</author>
                                        <pubDate>Sat Jan 07, 2012 11:27 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=103723#103723</guid>
                                      </item>
                                      <item>
                                        <title>Fixed</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=102324#102324</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=67745'&gt;LGLudd&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri Oct 21, 2011 10:44 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      ok, after much heartache I have fixed this (with help from google and a shove in the right direction from the #python irc channel)&lt;br /&gt;
&lt;br /&gt;
The previous comment I found about the warning not being the issue was correct&lt;br /&gt;
&lt;br /&gt;
There were two problems with the code above.&lt;br /&gt;
&lt;br /&gt;
Firstly the code was not actually converting the music file as (I think) it was not ready to join the elements together correctly.&lt;br /&gt;
&lt;br /&gt;
This was remedied by creating a demux element (I don't know why this is required for an audio only file) and monitoring it for the pad-added signal at which point it would be linked to the decoder element.&lt;br /&gt;
The elements are linked in two stages to account for this.&lt;br /&gt;
&lt;br /&gt;
The other issue was that the MainLoop was never being terminated and so the code was never completing cleanly.&lt;br /&gt;
&lt;br /&gt;
This was fixed by creating a bus object for the converter pipeline object and monitoring the messages for the MESSAGE_EOS signal and then terminating the MainLoop from there.&lt;br /&gt;
&lt;br /&gt;
I switched to using gtk instead of gobject in an attempt to get rid of the deprecated message (this did not work) and because the example code I found on the &lt;a href=&quot;http://pygstdocs.berlios.de/pygst-tutorial/pipeline.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot; class=&quot;postlink&quot;&gt;pygst tutorial&lt;/a&gt; &lt;img src=&quot;images/smiles/icon_redface.gif&quot; alt=&quot;Embarassed&quot; border=&quot;0&quot; /&gt; &lt;br /&gt;
&lt;br /&gt;
Anyway, just in case anyone is interested the code is now as follows:&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;import gst&lt;br /&gt;
import gtk&lt;br /&gt;
&lt;br /&gt;
class OggConvert&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; def __init__&amp;#40;self&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.converter = gst.Pipeline&amp;#40;'converter'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; source = gst.element_factory_make&amp;#40;'filesrc'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; source.set_property&amp;#40;'location','/home/user/Music/HappyShopper.ogg'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; demuxer = gst.element_factory_make&amp;#40;&amp;quot;oggdemux&amp;quot;, &amp;quot;demuxer&amp;quot;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; demuxer.connect&amp;#40;&amp;quot;pad-added&amp;quot;, self.demuxer_callback&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.decoder = gst.element_factory_make&amp;#40;'vorbisdec'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; convert = gst.element_factory_make&amp;#40;'audioconvert'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resample=gst.element_factory_make&amp;#40;'audioresample'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; encoder = gst.element_factory_make&amp;#40;'lame'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; encoder.set_property&amp;#40;'bitrate',192&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; id3tag=gst.element_factory_make&amp;#40;'id3v2mux'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sink = gst.element_factory_make&amp;#40;'filesink'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sink.set_property&amp;#40;'location','/home/user/Music/converted.mp3'&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.converter.add&amp;#40;source,demuxer,self.decoder,convert,resample,encoder,id3tag,sink&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gst.element_link_many&amp;#40;source,demuxer&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gst.element_link_many&amp;#40;self.decoder,convert,resample,encoder,id3tag,sink&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bus = self.converter.get_bus&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bus.add_signal_watch&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bus.connect&amp;#40;&amp;quot;message&amp;quot;, self.on_message&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.converter.set_state&amp;#40;gst.STATE_PLAYING&amp;#41;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; def on_message&amp;#40;self,bus,message&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t = message.type&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if t == gst.MESSAGE_EOS&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.converter.set_state&amp;#40;gst.STATE_NULL&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gtk.main_quit&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; elif t == gst.MESSAGE_ERROR&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.converter.set_state&amp;#40;gst.STATE_NULL&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print message&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; def demuxer_callback&amp;#40;self, demuxer, pad&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adec_pad = self.decoder.get_pad&amp;#40;&amp;quot;sink&amp;quot;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pad.link&amp;#40;adec_pad&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
def main&amp;#40;&amp;#41;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; gtk.gdk.threads_init&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; gtk.main&amp;#40;&amp;#41;&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;&amp;#58;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; OggConvert&amp;#40;&amp;#41;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; main&amp;#40;&amp;#41;&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
This is now going to be extended to take parameters defining the track to convert and its destination as well as using it to convert a whole list of tracks selected by a user from a gui frontend.&lt;br /&gt;
&lt;br /&gt;
Leo</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=102324#102324</comments>
                                        <author>LGLudd</author>
                                        <pubDate>Fri Oct 21, 2011 10:44 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=102324#102324</guid>
                                      </item>
                                      <item>
                                        <title>Python ogg converter</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=102280#102280</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=67745'&gt;LGLudd&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed Oct 19, 2011 4:31 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I have been attempting to follow Nicks python tutorials in the magazine and thought I would have have gone off at a bit of a tangent from the latest one which amongst other things shows you how to play music files using gst.&lt;br /&gt;
&lt;br /&gt;
Anyway, I thought it would be fun to attempt to write a small app to convert music files to mp3 format for my wife so she can load my ogg files onto her ipod.&lt;br /&gt;
&lt;br /&gt;
Unfortunately I have fallen at pretty much the first hurdle in that I cannot get my conversion process to work.&lt;br /&gt;
&lt;br /&gt;
from the command line I can run:&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;gst-launch -v filesrc location=HappyShopper.ogg ! decodebin ! audioconvert ! audioresample ! lame bitrate=192 ! id3v2mux ! filesink location=music.mp3&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
and it converts fine, but putting this in a script either as:&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;import gobject, gst&lt;br /&gt;
&lt;br /&gt;
converter = gst.parse_launch&amp;#40;'filesrc location=&amp;quot;HappyShopper.ogg&amp;quot; ! decodebin ! audioconvert ! audioresample ! lame bitrate=192 ! id3v2mux ! filesink location=&amp;quot;happyshopper.mp3&amp;quot;'&amp;#41;&lt;br /&gt;
converter.set_state&amp;#40;gst.STATE_PLAYING&amp;#41;&lt;br /&gt;
&lt;br /&gt;
gobject.threads_init&amp;#40;&amp;#41;&lt;br /&gt;
gobject.MainLoop&amp;#40;&amp;#41;.run&amp;#40;&amp;#41;&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
or&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;import gobject, gst&lt;br /&gt;
&lt;br /&gt;
converter = gst.Pipeline&amp;#40;'converter'&amp;#41;&lt;br /&gt;
&lt;br /&gt;
source = gst.element_factory_make&amp;#40;'filesrc'&amp;#41;&lt;br /&gt;
source.set_property&amp;#40;'location','HappyShopper.ogg'&amp;#41;&lt;br /&gt;
&lt;br /&gt;
decoder = gst.element_factory_make&amp;#40;'vorbisdec'&amp;#41;&lt;br /&gt;
convert = gst.element_factory_make&amp;#40;'audioconvert'&amp;#41;&lt;br /&gt;
resample=gst.element_factory_make&amp;#40;'audioresample'&amp;#41;&lt;br /&gt;
&lt;br /&gt;
encoder = gst.element_factory_make&amp;#40;'lame'&amp;#41;&lt;br /&gt;
encoder.set_property&amp;#40;'bitrate',192&amp;#41;&lt;br /&gt;
&lt;br /&gt;
id3tag=gst.element_factory_make&amp;#40;'id3v2mux'&amp;#41;&lt;br /&gt;
&lt;br /&gt;
sink = gst.element_factory_make&amp;#40;'filesink'&amp;#41;&lt;br /&gt;
sink.set_property&amp;#40;'location','HappyShopper.mp3'&amp;#41;&lt;br /&gt;
&lt;br /&gt;
converter.add&amp;#40;source,decoder,convert,resample,encoder,id3tag,sink&amp;#41;&lt;br /&gt;
gst.element_link_many&amp;#40;source,decoder,convert,resample,encoder,id3tag,sink&amp;#41;&lt;br /&gt;
&lt;br /&gt;
gobject.threads_init&amp;#40;&amp;#41;&lt;br /&gt;
gobject.MainLoop&amp;#40;&amp;#41;.run&amp;#40;&amp;#41;&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
just returns the message:&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Quote:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;quote&quot;&gt;** Message: pygobject_register_sinkfunc is deprecated (GstObject)&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
I have searched and found suggestions that it could be the pygobject package that is out of date (I am using version 2.21.5) but this is the most recent one available to me on Fedora 14 I also came across a posting with a very similar issue that then followed up their own post with a comment that the version was not the problem but a fault in the posters original code (however there was no explanation of what the fault was).&lt;br /&gt;
&lt;br /&gt;
Can anyone please help?&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;
Leo</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=102280#102280</comments>
                                        <author>LGLudd</author>
                                        <pubDate>Wed Oct 19, 2011 4:31 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=102280#102280</guid>
                                      </item></channel></rss>