Learning to code

So January 2008 I posted blog entry in which I expressed the hope for an easy to use GStreamer transcoding application.
Well after so much time gone by and still none on the horizon I decided to bite the bullet myself and make a go for it. Only problem was that I didn’t have either a clue about programming or about how glade works. But upon skimming through the book Learning Python at Robs place I decided to try to do it.

In addition to the book there was two online resources who helped to make things connect for me. The first was this tutorial on how to make user interfaces with python and glade and Jono Bacons blog about getting started with gstreamer and python.

My first application from playing with those tutorials was a GTK button which when you pressed it played a beep sound using the audiotestsrc element in GStreamer. But I kept at it and after having now spent about 5 days on learning the basics I am pretty happy with the progress I have made
on my application named ‘Transmageddon’:


The application is still very early stage, but if you got all the GStreamer plugins modules installed it should work. I even posted Fedora RPM on the very basic Transmageddon homepage.

There is a lot of coding stuff that needs fixing behind the scenes to enable more features and make the application more robust. My big long term goal is to add support for profiles to the application, so you choose Nokia 810 or iPod or PSP and the application chooses the container format and codecs for you and also rescale the video if needed to be optimal for that device. For those who care I have a fairly detailed Todo list here.

Any feedback people want to provide please feel free to email me or post a comment on this blog entry, just make sure to read the Todo list before suggesting stuff ;)

I also hope to write some blog entries explaining how I did some of the stuff in the application as I don’t think there is a very simple tutorial on how you do a progressbar with GStreamer for example.

26 thoughts on “Learning to code

  1. Super cool! I’ve been wanting this forever! Now if I could get it to export a script to repeat the operations, that would be just awesome (so I don’t need to run it manually 100 times a week). Transcoding is the least fun part of my job.

    • @EdgeWise: Well the transcoder_engine.py file is meant to contain the transcoding logic. So once things mature a bit maybe I get around to creating some simple command line tools etc. to use it.

    • @Tom: well its essentially based on two libraries. PyGst and PyGtk. The UI was all done with Glade-3. And for the time being I am just editing the code in gedit.
      Be sure to have gst-plugins-good,bad,ugly and gst-ffmpeg installed. And Schrodinger if you want Dirac support.

  2. I don’t see “quality” configuration in the todo. Isn’t that a problem ?

  3. @uraeus: Thanks for the quick answer. It is working!

    So you wrote transmageddon.py, transcoder_enginge.py and created transmageddon.glade, right?
    The only mystery to me is how did come up with all the other dozens of files. Did you use a tool to generate those?

  4. Would be nice to have some passthrough option for both audio and video. So if you just wanted to switch conatainer format or not re-encode the audio it would be possible. Anyway, looks great!

  5. Hi!

    You program is really cool.
    Actually I develop with 2 other developers a similar application. Gnac only supports audio yet.

    We definitely want to add video support. If you’re interested you may consider joining the team :)

    Just take a look on http://gnac.sf.net

    • @David: I am struggling to even understand what I am doing in Python, don’t think I am ready to move onto a C program :) Gnac looks nice though. I also rediscovered another application doing
      much the same as Transmageddon and Gnac, OggConvert (http://oggconvert.tristanb.net/)

  6. Yesss!

    Go with the profile idea, allow for creating custom profiles, and hide all of that behind ‘advanced settings’ or something. The GUI as-is, is *wonderful*.

    If only tvtime could have an embedded recording app as simple as this… Perhaps you can read from v4l-devices as well?

  7. @uraeus Motivation is the main factor, other stuffs are only details :D Ok, I admit that C can be sometime despairing.

    Nevertheless, my offer still apply :) If you change your mind, I will be disposed to “mentor” you.

    Keep going!

  8. Will you be putting this up for package review to include it in the Fedora repository?

    • @Rahul: that is my plan, although not before the code of my application contains a lot less known ugliness :)

  9. Python is pretty neat. Glade too.

    I’ve been working (in my copious spare time) on a little PyGtk app to copy e-books into my N810, over sshfs, while maintaining the directory structure (author/title, sometimes author/series/title). I use it as a Nautilus script (although perhaps it should be an extension — Send to -> my Nokia N810). I’ve had idle thoughts of making it copy music and videos to the proper locations. Transcoding would fit right in.

    I only need a duplication machine to make a copy of myself to have the time to work on it…

  10. I would love if you’d reuse my code and UI at rudd-o.com/new-projects/linuxvideoconverter for your application. Contact me if you’re interested. I’m familiar with pygst and pygtk2 too.

    • @Rudd-O: thanks for the link. I took a quick look and once my code matures a little more I might take a stab at porting your UI to use my transcodeengine.py. It should help me both make sure that I have a clean UI and engine separation and also let me see what I need to expose to allow some basic tweaking of encoder parameters as I notice your current code also sets changes those. My code atm, just use the defaults for the encoder.

  11. It’s probably a good idea to eventually change from using Glade’s file format and library to the shiny new one in GTK – GtkBuilder. You can save GtkBuilder files out of Glade now, and/or convert old glade files with a utility.

  12. For the profiles I would just add a combobox at the top and a little “Save”-button next to it. You could then add a few standard profiles (like PSP, iPod) to the combobox. If the user chooses one of them, the options are filled into the UI. If the user makes changes and wants to save them, he just clicks on the save button and chooses a name for the new profile in a little dialog.
    That’s how I would do it.

    Regards, Benny

  13. Winff is another conversion program for Win and Linux, but its GUI looks very bad in GNOME.
    Abyhow, it has a lot of presets that you could use for Transmageddon.
    I too suggest to show the full output options only after the user’s explicit request.

  14. Transcode is relatively specific jargon so when translated it will very likely be simplified into a more generic word anyway. If instead you used the word “Convert” you could use the GTK stock item and label and effectively get your translation of that button for free/automagically.

    It will be very interesting to see how this program develops, the introduction of profiles will allow you to make it much simpler more task based even as the list of codecs and other options gets much longer. A longer list of codecs won’t scale well though, putting them in drop down menus allows the interface to scale better but slows down users who would like to scan and select what they want quickly (but I think this would be an acceptable trade off since you would hope to provide profiles and obviate the need for users to choose the codecs themselves most of the time).

    In terms of ergonomics bigger buttons are as you know easier to hit. I’d be interested to see if you could put the input and output choosers below their titles so they could use the full width of the dialog and see if that doesn’t make the dialog too chunky.

    The interface Rudd-O uses in his program looks rather good.

    Since transcoding can be a potentially time consuming and resource intensive task it might be useful to have a Pause button to allow users to interrupt the task without being forced to cancel the transcoding from scratch. The idea might still be impractical to implement or risk making the dialog overcomplicated but I leave the idea for your consideration.

    From your plans it seems like you want to keep this as a standalone application but if you can manage to keep it simple (a single dialog) you might also be able to integrate it as a Plugin to Pitivi, which would be very cool. (It might also help limit the scope of the application if you could point to other parts of Pitivi to do more complicated tasks you’d prefer not to include.)

    Nice work.

  15. First, this is a really good idea, we’re missing a simple application for that. Even better to have it GStreamer-powered.

    Now some remarks :
    1. Don’t use Glade XML files, prefer GtkBuilder. It does almost the same thing, but the format is a bit different. The bonus being that it’s integrated in GTK and removes a dependency on libglade.

    2. Don’t use GtkRadioButton for codecs, it doesn’t scale well depending on the codecs available on the machine. Use one GtkTreeView for audio codecs, another one for video codecs so you can just not display the codecs not supported by the container.

    3. Remove all the “Choose” from the interface. They clutter it and give no useful information.

    4. Remove the “Container” word, which may be a bit confusing for newbies. “Output Format” or “Output File Format”. According to the widgets you choose for the UI, make sure you respect the capitalization for UI elements:

    5. Have the Cancel and Transcode buttons respectively left and right aligned.

    Nice work ;-)

  16. Pingback: Transmageddon continued « Christian Schaller

Comments are closed.