objective-c

fcpxImageExporter and my 5 minutes of coding fame

Mon 2, December 2013

A little while ago at Orangutan we had a client ask us to export several hundred frames from a 1 hour video we had produced for them.

We worked in fcpx and manually exporting frames can be quite a task.

So I spent a late afternoon putting together a little app to read fcpxml and use it to export still images based on the markers we had put in the timeline.

I polished it a little more and shared it on the fcp.co forums and over the week the little app had been downloaded over 700 times.

It even got a nice review from Larry Jordan and several retweets from other fcpx pros like Richard Taylor and sites like premiumbeat.com. 

fcpxImageExporter is available over at Orangutan.

fie105

NSSlider, Mouse Down & NSThread

Tue 2, August 2011

I hope the following makes some sense and is of some use to newbie Mac Developers out there.

For the past week I have been working on Sub It to try get it ready for first release on the Mac App Store.

One of the tools I have put in is a slider to adjust the movie playback rate – similar to the scrub tool in Final Cut Pro.

There were a few hurdles I had to overcome to get this to work.

Initially I realised I would have to subclass NSSlider to be able to detect/grab the MouseDown and MouseUp NSEvents (I wanted the slider to reset to 0 after the user had released the mouse – putting the movie in pause/stop) – googling revealed that NSSlider runs inside its own event loop in the main thread.

Hooking up a delegate to NSSlider subclass allowed me to call actions/methods in the main controller on those Mouse events – eventually I got this to work with the following code (and via Interface Builder I hooked up the delegate property to the my main Controller):

TimeScrubberSlider.h

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
 
@interface TimeScrubberSlider : NSSlider {
	IBOutlet id delegate;
}
 
@property (readwrite,retain) id delegate;
 
@end

TimeScrubberSlider.m

#import "TimeScrubberSlider.h"
#import "Controller.h"
 
@implementation TimeScrubberSlider
 
@synthesize delegate;
 
- (void)mouseDown:(NSEvent *)theEvent  {
 
	[delegate doScrubTime:nil];
	[super mouseDown:theEvent];
	[self mouseUp:theEvent];
 
}
 
 
- (void) mouseUp: (NSEvent*) theEvent
{
 
	[self setIntValue:0];
	[delegate doPlay:nil];
 
}
 
@end

This was all working, but the problem was that the time display of the movie would not constantly update – only when the slider was moved would the current time update – not continuously.

So I decided to try attach the updating of the current time display to a separate thread – using NSThread. My thought was that no matter what happened in the main controllers’ thread, this other thread would always do it’s own thing and hopefully not be interrupted.

To get this going I created a method (called ‘launchTimer’) that is called when a file is loaded, and this calls the ‘updateCurrentTime’ method, and this ‘launchTimer’ method is run under the seperate thread. Umm i think that kinda makes sense.

Something along these lines:

snippets from the Controller.m

- (void)setupGUIFromFileRead{
 
	//just a snippet...
 
	//begin timer to update the current frame/time display - as separate thread so nsslider "scrub" can play nicely
	[NSThread detachNewThreadSelector:@selector(launchTimer) 
                             toTarget:self 
                           withObject:nil];
 
}
 
-(void)launchTimer{
 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSLog(@"startingtimer");
    [NSThread setThreadPriority:1.0];
    updateTimerToggle = YES;
    while (updateTimerToggle) {  // loop until cancelled
        [self doUpdateCurrentTimeDisplay:nil];
        [NSThread sleepForTimeInterval:.1];
    }
    [pool release];
 
}

mp3 to wav (a little app written in Objective-C)

Thu 28, April 2011

What?

Just knocked together a little app to batch convert selected MP3 files in iTunes to WAV format.

Seems to work pretty well so far.

When the app launches click the button to select the “Output Directory” of the converted files.

Then hit the “Go!” button.

 

Why?

I was looking for an easy way to batch convert selected tracks in my iTunes library to WAV format, and have them export into a directory (for later use in Final Cut Pro). I came across some Applescripts that would do the conversion within iTunes, but in the end wasn’t really what I was after. I started writing something in Python but then figured it would be a great opportunity to give it a go in Obj-C. It took half a day and I learnt a lot in the time it took to put it together.Hopefully people out there can find a use for the little app, or use the XCode project to build something better!


Requirements:

iTunes must be open and the tracks you want to convert must be selected

*Only tested on Mac OS X 10.6.7

 

Download:

App: Download MP3toWAV

Xcode Project: Download mp3towavXcodeProj

 

Notes:

Built using XCode and ObjC. I needed the following to talk to iTunes via OBJC:

 

 

 

MyShares app

Wed 14, October 2009

icon

Spent most of today learning more about NSTableView, memory management and other things Cocoa/Obj-C/xCode.

What came of it?

I made a little app for keeping track of shares – via finance.yahoo.com.

Includes an open/save dialog so you can have a ‘portfolio’ to open again at a later time.

ATM I think it only runs in OS X 10.6.

Download MyShares

myshares
Download MyShares xcode project

SubIt 1.1

Sat 10, October 2009

subit_icon
Latest release of SubIt – version 1.1

Finally it’s here!
After a complete rewrite in Objective-C I am happy to say that I have a working version of SubIt.

What’s new?
Most noticeably the ability to select QTTracks in your media.
Ability to select a font/style/size before exporting your work.

Download it and let me know what you think and what bugs you have found!

subit_window

Multiply – little xcode project

Mon 28, September 2009

Yesterday afternoon I was sitting with Erin & Hugh seeing if we could do 2 digit multiplications in our head, such as 34 * 94.

It turned out I am pretty bad at this so I figured I’d make a little mac app/game to practice with and get back into coding.

Looks like it’s a 64 bit app, and i think it only runs in 10.6.

multiply

I might rebuild it for the iPhone.

multiply app (151)

xcode project:

multiply xcode project .zip (163)

Learning Obj-C

Sat 30, May 2009

Yesterday I decided I have to give up on PyObjC for the moment and step into the world of Objective-C.

I have got to a point in developing SubIt that I can’t seem to get enough out of the PyObjC bridge to be able to get what SubIt needs.

So now I am in the process of rewriting SubIt in Obj-C.

Obj-C seems weird and complicated and I can’t see why it has to be this way when Python/Ruby seem just so much much easier to understand. Oh well, I have taken the plunge.

I spent most of yesterday reading a great and easy to follow PDF called “Become An Xcoder“, available for free download:
http://www.cocoalab.com/?q=becomeanxcoder

I have been looking at a bunch of podcasts/videos/books and to me this PDF was the quickest/easiest way to get a little up to speed.