Archive for the ‘Apple / Macintosh’ Category

MediaInfo Mac 0.7.7.58, revisited.

Sunday, September 21st, 2008

As you maybe know, time is a commodity these days, but i took some hours to fix some bugs and update several things in MediaInfo Mac.
Most of the fixes are related to the usability aspect of this little tool, as in, improved open and save dialogs, etc, but there is also some speed improvement in the parsing routines, and, the application is 64bit ready now (for capable hardware).
For the late comers, MediaInfo Mac is a Macintosh version of an amazing tool (called MediaInfo) created by Jerome Martinez, you can find more info about his incredible work by going here.

If you want to download MediaInfo Mac, you can visit the official site by going here… or, if you are lazy, you can just grab the latest version by clicking here.

Below is a little video demo of what the application can do and what kind of detailed information you should expect when processing video / audio files.

[flashvideo filename=/wp-content/uploads/2008/09/mediainfo_demo.mp4 /]

As usual, questions, comments and suggestions are welcome :)

Keeping track of your users hardware / Software with Sparkle and PHP.

Tuesday, April 15th, 2008

Some months ago I started using the amazing Sparkle framework to manage the auto-update features on my MediaInfo Mac application, and it wasn’t until today that I decided to update my Sparkle version to the latest one from the SVN and give it a try, mostly because I’m planning to release upcoming MediaInfo Mac builds as 32 and 64bit Universal Binaries, but that’s a different story.

I have found that with the new Sparkle version, you can kindly ask the user if he/she wants to send anonymous information about the system they are using to run your application, like the MacOS version, amount of RAM, number of processors, language, etc. This is specially useful for many reasons (at least for me), first, I’m starting the process of localizing my application, so that gives me a pretty good idea of what languages are the most used so far, and, finally, it will let me now when I could stop caring about Tiger and start a Leopard only version of my Software.

The idea is pretty simple, you have a PHP script that generates the whole AppCast compatible feed, and all the hardware / software information is passed as url parameters, as in feed.php?osVersion=10.2.5&lang=en … etc.

So, by using good old Google, i found a really good script to generate the AppCast feed, but, i also needed a way to store the tracking data into a DB for later usage, and, i came up with this (really barebones, but working) prototype.

So, i did some minor modifications to the original PHP code; first, i changed the way to parse the version number from the file names, so as long as you use the application_name_1.5.zip pattern it will work, please note that you can put as much revision or subversion numbers as you wish: application_name_1.2.3.4.5.zip should also work.

This is the code snippet as i have it working now on my development server:

<?php
// ----------------------------------------------------------- //
// Script to generate an RSS appcast from folder contents
// Version 1.0.1
//
// (cc) Random Sequence 2007, Some Rights Reserved
//
// Licenced under a creative commons Attribution ShareAlike licence
// http://creativecommons.org/licenses/by-sa/3.0/
// ----------------------------------------------------------- //
// REQUIRES PHP 5 or greater
// Tested with APACHE 1 & 2 on Mac OS X, Debian Linux   

// -------------------- BEGIN CONFIG ------------------------- //

$title = "Downloads";           // Used as feed title in feed readers
$description = "File List";     // Used as feed description in feed readers

// these are the types of files to list in the appcast & their MIME Types. Use lower case.
$fileTypes = array( "zip"=>"application/zip",
                    "tgz"=>"application/x-gtar",
                    "tar"=>"application/x-tar",
                    "dmg"=>"application/octet-stream"
                    );

// -------------------- END OF CONFIG ------------------------ //

$appcastHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:sparkle=\"http://www.andymatuschak.org/xml-namespaces/sparkle\">
<channel>
    <title>MediaInfo Mac Software Updates Feed</title>
    <link>http://massanti.com/mediainfo</link>
    <description>AppCast compatible feed for MediaInfo Mac Updates</description>
    <language>en</language>
";
$appcastTemplate = "
        <item>
            <guid  isPermaLink=\"false\">*guid*</guid>
            <title>*title*</title>
            <description><![CDATA[*description*]]></description>
            <pubDate>*pubdate*</pubDate>
            <enclosure
                sparkle:version=\"*version*\"
                type=\"*type*\"
                url=\"*url*\"
                length=\"*length*\" />
        </item>";

$appcastFooter = "
</channel>
</rss>";
$dir = getcwd()."/releases";
$files = scandir("$dir");
$etag = sha1(implode("/",$files));
rsort($files);

// support for conditional fetch
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) {
    header('HTTP/1.1 304 Not Modified');
    exit;
}

$appcast = $appcastHeader;

$link = "http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"];

$appcast = str_replace("*link*",$link,$appcast);
$appcast = str_replace("*title*",$title,$appcast);
$appcast = str_replace("*description*",$description,$appcast);

foreach ($files as $file) {
	preg_match("/.*\.([a-z09]{1,3})$/i",$file,$matches);
	if (isset($matches[1]) && isset($fileTypes[strtolower($matches[1])]) !== false) {
		$appcastFile = $appcastTemplate;
		$folderUrl = "http://".$_SERVER["HTTP_HOST"].substr($_SERVER["PHP_SELF"],0,strrpos($_SERVER["PHP_SELF"],"/"))."/releases/";
		$guid = $folderUrl.sha1($file);
		$path_parts = pathinfo($file);
		$title = mb_convert_case( str_replace("_", " ", $path_parts['filename']) , MB_CASE_TITLE, "UTF-8");
		//$description = preg_replace("/^(.*?)([0-9]+[a-z])\.([a-z09]{1,3})$/i","$1",$file);
		$description = getFileDescription("releases/".$file.".html");
		$pubdate = date("D, d M Y H:i:s",filectime("releases/".$file));
		$type = $fileTypes[strtolower($matches[1])];
		$url = $folderUrl.$file;
		$length = filesize("releases/".$file);  
		preg_match("/(\d+\.)+\d+/", $file, $m_version);
		$version = $m_version[0];
		//$version = preg_replace("/^(.*?)([0-9]+[a-z])\.([a-z09]{1,3})$/i","$2",$file);
		$appcastFile = str_replace("*guid*",$guid,$appcastFile);
		$appcastFile = str_replace("*title*",$title,$appcastFile);
		$appcastFile = str_replace("*description*",$description,$appcastFile);
		$appcastFile = str_replace("*version*",$version,$appcastFile);
		$appcastFile = str_replace("*pubdate*",$pubdate,$appcastFile);
		$appcastFile = str_replace("*type*",$type,$appcastFile);
		$appcastFile = str_replace("*url*",$url,$appcastFile);
		$appcastFile = str_replace("*length*",$length,$appcastFile);                                    
		$appcast .= $appcastFile;
	}
}

// Reads a file called filename.html and returns the HTML output

function getFileDescription($fileName) {
	$handle = @fopen("$fileName", "r");
	$rValue = "";
	if ($handle) {
		while (!feof($handle)) {
			$buffer = fgets($handle, 4096);
			$rValue .= $buffer;
		}
		fclose($handle);
	}
	return $rValue;
}

$appcast .= $appcastFooter;
/*"GET /u.php?UUID=F2958FD0-2EC9-40CA-8171-C63D663AAE90&
		osVersion=10.5.4
		cputype=7
		cpu64bit=1
		cpusubtype=4
		model=P5KC
		ncpu=4
		lang=en
		appName=MediaInfo%20Mac&appVersion=0.7.7.50
		cpuFreqMHz=2400
		ramMB=2048 HTTP/1.1" 200 575 "-" "MediaInfo Mac/0.7.7.50 Sparkle/282"
		*/
// Database Functions

$vars = array('osVersion' , 'cputype', 'cpu64bit', 'cpusubtype', 'model', 'ncpu', 'lang', 'appName', 'appVersion', 'cpuFreqMHz', 'ramMB', 'UUID');
$values = array();
$shouldInsert = true;
foreach ($vars as $item) {
	if (isset($_GET[$item])) {
		$values[$item] = html_entity_decode($_GET[$item]);
	} else {
		if ($item != 'cpu64bit') {
			$shouldInsert = false;
		}

	}
}
if (isset($_GET['cpu64bit'])) {
	$values['cpu64bit'] = html_entity_decode($_GET['cpu64bit']);
} else {
	$values['cpu64bit'] = '0';
}

if ($shouldInsert == true) {
	$mysqli = new mysqli("yourDBHost", "yourDBUser", "yourDBPassword", "yourDBName");

	if (mysqli_connect_errno()) {
	    printf("Connect failed: %s\n", mysqli_connect_error());
	    exit();
	}

	$stmt = $mysqli->prepare("INSERT INTO stats (os_version, cpu_type, cpu_64bit, cpu_subtype, model, n_cpu, lang, app_name, app_version, cpu_freq, ram_mb, UUID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
	$stmt->bind_param('siississsiis', $values['osVersion'], $values['cputype'], $values['cpu64bit'], $values['cpusubtype'], $values['model'], $values['ncpu'], $values['lang'], $values['appName'], $values['appVersion'], $values['cpuFreqMHz'], $values['ramMB'], $values['UUID']);
	$stmt->execute();
	$stmt->close();

}

header("Content-type: application/xml; charset=UTF-8");
header("ETag: $etag");

echo $appcast;
exit;
?>

As usual, suggestions or improvements are welcome ;)

MediaInfo Mac 0.7.6.30 update released

Sunday, April 13th, 2008

Hi there, just a quick note to let you know that a new version of MediaInfo Mac (0.7.6.30) has been released, not only it includes several bugfixes and improvements in the Cocoa arena, but also a new build of the MediaInfo engine which features the following improvements:

  • AVC: Count of reference frames.
  • AU: Comments.
  • Some global speed improvement.
  • Id3v2: Unsynchronized frames support (v2.3 & v2.4).
  • MKV: handling of files created for streaming.
  • MPEG-4: Handling of corrupted stream size info with some PCM streams.
  • DVD video: Hebrew patch (“iw” code is mapped to Hebrew).
  • MPEG-4: better handling of bitrate mode (VBR or CBR).
  • AVI: MediaInfo reads now the framerate value from the container rather than the stream value.
  • AC3: TrueHD detection.
  • MPEG-TS (or Bluray): VC-1, AC3+ and AC3 TrueHD detection.
  • AVC in MKV: all SEI userdata infos from x264/eavc in Writing library settings.
  • EVO: Better detection of duration.
  • Dirac: raw files parsing.
  • MPEG-TS: Dirac management.
  • MPEG-TS: DVB subtitles/Teletext management.
  • MPEG-4 Visual (DivX/XviD): writing library name was missing.
  • MPEG-Video: some DTS files with wrong extension were detected as MPEG-Video.
  • SWF: Compressed SWF files support is back.

If you are an actual user, just launch the application and use the auto update feature, or you can get the latest version by visiting the official MediaInfo Mac website.

As usual, feel free to leave any comment or suggestion in here.

Enjoy :)

iPhone’s “Code Signing”: Is there any limit for the ridiculous ?

Sunday, March 9th, 2008

Some hours ago i was pointed to an interesting post about the new “code signing” features that Apple is going to implement for the iPhone software developers, and honestly, I am speechless…
There was a time when i used to believe that there was a good reason for Apple to be so closed in some aspects: To keep the user experience as clean and smooth as possible.
That could explain several behaviors in the iTunes Music Store, in the iPod and of course in the whole Mac platform, but after reading several times this great article at Rogue Amoeba’s blog, just one thing comes to my mind… “is there any limit ?”.

I still can’t believe the fact that it is just NOT possible to load an application inside an iPhone unless it’s blessed (read: digitally signed) by Apple, and yes, you read it right, not even for testing purposes, which means that if you want to start writing some code for the iPhone, you have to a) buy a $99 testing certificate, and b) buy an extra iPhone compatible with that extra certificate.
But the story continues….

Apple seems to have a list of things that they are not going to bless, like for example Porn, or “Bandwidth Hog” applications, and there is also the “unforeseen” category, which translated to plain English means “anything that we don’t like at all or we consider bad for our business model”.

I happen to believe that protecting the user experience as much as you can is a good thing, and that is mainly the reason because Mac OS is more enjoyable than any other OS out there, no discussion there, but when a company starts telling me what I am allowed to run (or not) on a device that i OWN, I think that something is really wrong. In my particular case, I don’t own an iPhone (and not even planning to own one, mostly because I use Nextel, and I wouldn’t change it for anything), for the contrary i own a Motorola headset, and i can load any application on it, or even write my own if I feel like.

No matter how much I love Apple and their products, I think that freedom of choice is one of the most valuable things that our society must protect, and while I read a lot of forum / blog posts by the so called “Apple fanboys” saying things like “if you don’t like it, don’t buy it” I just don’t want to believe what could happen if a company with this way of thinking becomes the market leader.

I have yet to see the evolution of this whole thing, but right now this just makes me re-think if some other eternally blamed companies are really sooooo evil after all…

MediaInfo for Mac: Know everything about your media files.

Wednesday, January 30th, 2008

You should consider this piece of software my “hello world” project in the Mac development arena, because, even the fact that i have pretty good skills when it comes to OO development, I’m totally new when it comes to the Mac, and I’m using this project mainly as a learning experience.

Attention: download links were moved

In order to keep things organized, the download links and general information for MediaInfo Mac were moved into this new website.

MediaInfo Mac ScreenshotIn the past few days i have been working in a full Aqua version of a linux tool called “Mediainfo”, so this is the result.
Let me introduce you to “MediaInfo Mac”.

MediaInfo Mac does just one thing: it gives you a lot of information about multimedia files, even files that QuickTime can’t read, and it does that by using a custom Universal Binary build of the linux library “libmediainfo” by Jerome Martinez as its core.
This application is obviously OpenSource and i will make all the sources available as soon as i finish cleaning the code and configuring an SVN repository on this server.
MediaInfo Mac requires any PowerPC or Intel Macintosh computer running MacOS X 10.4 “Tiger” or newer.
If you have any question or suggestion, feel free to leave your comment below :).

A BIG thank you goes to Rainer Brockerhoff, (who is a true monster in the Macintosh development area), for having the patience to answer a lot of my questions, and also, to the guys at #macdev on freenode for helping me to understand a lot of things in the “Cocoa Arena”. Thank you, i really appreciate your time.

In order to keep things in organized, anything in relation with MediaInfo Mac is going to be on this new website.

IF you are any kind of software tracker, there is a feed with MediaInfo updates, and it is compatible with the AppCast definition.

5 things that apple could / should consider for iTunes 8

Sunday, January 13th, 2008

This is just a brief and humble list of things that i would like Apple to consider for iTunes 8 in order to improve the application. If im lucky enough, at least item 1 on this list will become true, and that, would make me and several other people really happy :).

iTunes Icon

  1. Support for HE-AAC Plus V2 Audio:
    This is one of the most modern audio codecs out there, with supporters going from 3GPP to Nero, you can get really good stereo audio quality and channel separation at bitrates as low as 48kbps, which is great for radio streams and podcasts.
    The following is a head by head comparison between an audio file encoded to MP3 with the LAME encoder at 192kbps at maximum quality, and the same file encoded with the 3GPP aacPlus encoder at 48kbps. 

    MP3 audio sample encoded at 192kbps, total file size: 2.56 MB.

    [vidipress height=”20″ width=”450″ mode=”http” filename=”http://massanti.com/wp-content/uploads/2008/01/demo_mp3_192k.mp3″ /]

    aacPlus v2 audio sample encoded at 48kbps, total file size: 0.66 MB.

    [vidipress height=”20″ width=”450″ mode=”http” filename=”http://massanti.com/wp-content/uploads/2008/01/demo_aacplus_48k.m4a” fs=”no” /]

  2. (more…)

HE-AAC Plus encoder for Mac (Universal Binary)

Sunday, September 30th, 2007

This post is outdated, for a more up to date version of both the binary encoder and the sources, please visit this new post.

I needed a native solution to encode HE-AAC Plus audio on a Mac, but there is not any native solution so far right now, so i compiled the reference encoder (enhAacPlusEnc) published by the 3GPP group.
I also created an xCode project to make it easy to manage future builds.
This is an “Universal Binary” build, meaning that it will work on both, Intel based and PowerPC based Macs.

You can download the universal binary encoder by clicking here, and you can download the xcode project by clicking here.

Keep in mind that i had to make some minor modifications in order to make it compile as Universal Binary, so you wil find some minor diferences when comparing with the original source code released by the 3GPP group.

If you have any question, leave a comment here.

Creating good quality h264 video for the upcoming Flash Player and Flash Media Server

Friday, September 28th, 2007

Important

This tutorial has been updated (and improved) a lot, for the new version please follow this link.

UPDATE: I realized that when i read a tutorial about anything, in most cases, i want to first see what result im going to get so then i can decide if the tutorial is worth reading (or not), so here is a head by head comparison: 

This is an h264 file encoded by the guys at apple.com, it’s the TV Commercial for the brand new iMac: ORIGINAL VIDEO

This is the same file re-encoded using the steps on this tutorial: RE-ENCODED VIDEO

Obviouisly, there is an small quality degradation, but keep in mind that apple’s original movie is 14MB in size, while mine is 1.5MB ;).
You can play my MP4 video with almost any video player out there, but remember that not all video players out there support HE-AAC audio (or aacPlus) and b-frames, so if you play the file with a player like QuickTime, it is NOT going to work.
I recommend mPlayer or VLC media player to play this kind of video, and obviously, Flash Player will play the file perfectly too.

Update for Macintosh users:

I updated the bash script on this post so it can be used also by Macintosh users, so instead of using the NERO Digital AAC Encoder, Macintosh users can take advantage of the native 3GPP AAC Plus V2 encoder that i just compiled. Visit this post for more information about it.

Like a lot of people out there, i was really happy when i found the press release from Adobe, stating the addition of h.264 video support and HE-AAC Plus audio to their upcoming Flash Player versions, and also, to the upcoming Flash Media Server.
After following several “Tutorials” all over the web, i found that there was not any single one that gave me the results that i wanted; that is, good video quality, with the less possible file size, so after a lot of trial and error and after a lot of help and optimizations by the guys at the ffmpeg and x264 IRC channels, i decided to create this tutorial that will most probably help you a lot to encode good quality h264 video, with HE-AAC Plus Audio, and all this inside an MP4 container with tags and all ready to deliver to your visitors.

There are several things that you will need in order to do this:

Some friendly bookmarks:
SVN checkout for x264:
svn checkout svn://svn.videolan.org/vlc/trunk vlc-trunk
SVN checkout for ffmpeg:
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

First of all, I’m assuming that you are running Linux, Mac-OS X or any other UNIX variant. I never tried this on windows because I am pretty sure that there are lot of really nice programs that you could buy to do the job.
(more…)

Apple’s Think Different TV commercial, in good quality…

Tuesday, September 25th, 2007

As many of my friends already know, im working on an online archive of Apple related commercials and institutional videos, so well, some days ago i received a series of uMatic tapes, and i found this inside one of them.

This is, in my humble opinion, one of the better (if not the better one) examples of clean institutional advertising & branding, and one of those commercials that “touch your heart”.
Quick Tip: In recent pre-releases of Mac OS X Leopard, you will find the whole narration for this commercial in the high resolution icon of the “Text Edit” application.

I hope you enjoy this, because you wont find a better quality version in the whole web ;)
Please note that you will need a 512kbps internet connection (or faster) in order to watch this video without interruptions.

[vidipress mode=”rtmp” rtmpid=”massanti.com/td_hq” /]

 

Quote from Wikipedia: “Think Different was an advertising slogan created for Apple Computer in the late 1990s by the Los Angeles office of advertising agency TBWA\Chiat\Day. It was used in a famous television commercial, several print advertisements, and several television advertisements for Apple products. Apple’s use of the slogan was discontinued with the start of the Apple Switch ad campaign in 2002. The slogan may have been a play on the venerable IBM Think motto coined by Thomas J. Watson.”