Thursday, February 17, 2011

encoding files to watch on Samsung TV

I have access to a nice Samsung TV that supports media on USB drives.

It has a bunch of codecs including x264 and MP3. My Ubuntu has some codecs on it so I needed to encode my media files into a suitable format to play them.

I received the error:

Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

And finally arrived at the following:


ffmpeg -i ./test.flv -acodec libmp3lame -vcodec libx264 -vpre medium test.avi

You can find helpful details on encoding on the blog:
http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/
including a handy list of encoding quality vs speed presets.



Update

It may be worth running ffmpeg -i test.

If either of the streams are mp3 or h264 then you can save time by passing 'copy' as the -acodec or -vcodec respectivly.

Tuesday, January 11, 2011

Drupal pretty URLs on Ubuntu

Ubuntu helpfully provides Drupal in its repositories. This installed fine for me but during install.php (to configure drupal) pretty urls wouldn't work.

To fix this, I had to edit

/etc/drupal/6/htaccess

find the line at the bottom:

#  RewriteBase /drupal

remove the '#' and add a '6' onto the end to give:

RewriteBase /drupal6

Wednesday, December 29, 2010

getting workspace with gnome visal effects

I maintain linux-desktop-audit software. My Ubuntu machine recently allowed me to enable 'visual effects' to make nice looking transitions between workspaces.

However, this broke linux-desktop-audit. So, instead of listening to 'active_workspace_changed' the code should be listening to 'viewports_changed'. Once this event fires, to get the current workspace number I use the following code:

def viewport_change (self, screen):
        self.current_workspace = screen.get_active_workspace()
        v_x = self.current_workspace.get_viewport_x()
        v_y = self.current_workspace.get_viewport_y()
        v_w = screen.get_width()
        v_h = screen.get_height()
        v_r = self.current_workspace.get_width()
        v_c = self.current_workspace.get_height()
        total_cols = v_r/v_w
        total_rows = v_c/v_h
        desk_col = v_x/v_w
        desk_row = v_y/v_h
        ws_num = desk_col + (desk_row * total_cols)

Tuesday, November 23, 2010

NUnit-console-runner, FileLoadException, access is denied

I was using NUnit, and careless stuffed it into svn from my Linux box.
When I checked it out from svn onto my Windows environment I got this error when trying to run: ./nunit-console.exe:


Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'nunit-console-runner, Version=2.4.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. Access is denied.
File name: 'nunit-console-runner, Version=2.4.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at NUnit.ConsoleRunner.Class1.Main(String[] args)

I had created a problem for myself because various dll's didn't have 'execute' flag enabled.

To fix this in a brutal way, from the cmd.com, I used:

cacls nunit.core.dll /p /e Everyone:F

Friday, August 6, 2010

handy java property to dump http traffic.

I find myself needing this command and unable to remember it or find it on Google easily. So I'm going to make a note of it here to save my precious memory for other more important information:

-Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true

Right, now I can try and remember where I live...

Tuesday, August 3, 2010

svn Id keyword in Perl

My Perl program wants to report it's SVN Id keyword. Setting this up is simple enough if you follow one of the many excellent examples on the web. However I found that it was beyond me to get the value of my Id printed out by my code.
The problem is that the completed SVN Id keyword contains @ and $ symbols.

So my code resorts to greping it's self to get the value from the source code.

# $Id$
my $id_str = `grep -m1 '\$Id:' $0`;
print $id_str;


It feels like a crime against programming, but it works - and provided that there is an $Id$ before the grep command, it should work reliabably.

Thursday, July 29, 2010

Exit code idiom in Java

I have been looking into employing C 'enum' like exit codes in Java. For example, if the application you are writing will be called by a script so it is handy for the script to know when there is an exit that is OK, and when it is a FAIL.

I looked to the web for inspiration, and couldn't find anything Java specific, so, I have arrived at the following:

class MyClass {
  private static enum EXIT {
        OK(0), BAD_COMMANDLINE(1), INPUT_ERROR(10);
      
        EXIT (int code) {
            this.code = code;
        }
        private int code;
        public int getCode() {
            return code;
        }
    }

   public static void main (String[] args) {
        if (args.length() < 1) {
            System.exit(EXIT.BAD_COMMANDLINE.getCode());
        }

        System.exit(EXIT.OK.getCode());
    }
}