Playing with video on the iPad

One of the great uses for the iPad is watching video.  Seriously, it’s a reasonably large display, held close to the user and, whilst it may not replace the big flat screen in the living room for family viewing, it’s more than good enough for catching up on the normal stuff.

Whilst I’m waiting for the BBC to release an iPlayer app for the iPad (iPlayer support is currently limited to streaming content), I have some video content that I’d like to catch up on whilst disconnected from the ‘net.  Unfortunately, my iPad didn’t want to play it… until I converted the video to a suitable format.

My first task was to use GSpot (on a Windows machine) to have a look at what codecs the file used.  It turned out to be an XviD video/MP3 audio file at 30fps in a .AVI container.

According to Apple’s technical specifications, the iPad can cope with:

Audio playback

  • Frequency response: 20Hz to 20,000Hz
  • Audio formats supported: HE-AAC (V1), AAC (16 to 320 Kbps), Protected AAC (from iTunes Store), MP3 (16 to 320 Kbps), MP3 VBR, Audible (formats 2, 3 and 4), Apple Lossless, AIFF and WAV
  • User-configurable maximum volume limit

TV and video

  • Support for 1024 by 768 pixels with Dock Connector to VGA Adapter; 576p and 480p with Apple Component AV Cable; 576i and 480i with Apple Composite AV Cable
  • H.264 video up to 720p, 30 frames per second, Main Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4 and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4 and .mov file formats; Motion JPEG (M-JPEG) up to 35 Mbps, 1280 by 720 pixels, 30 frames per second, audio in ulaw, PCM stereo audio in .avi file format

Unfortunately, it’s not possible to install additional codecs on the iPad (at least not on a non-jailbroken one), so the video needed to be converted to something that the iPad could handle.  To do this, I installed the DivX and XviD codecs on my Mac (although I should have just used Perian), and used Apple QuickTime Pro to export the video as an MP4… except it took ages and converted it to 4:3 ratio at a lower resolution and higher frame rate – not really the result I was after…

Then I remembered Handbrake.  Handbrake doesn’t have any iPad presets yet but Carson McDonald has created some and they worked brilliantly to create a suitable H.264/MP4 file (there’s also a thread on iPad encoding in the Handbrake Forums).

When it cames to getting the video onto the iPad, I had two options: drag the the video to iTunes and sync (it then appears in the iPad’s built in Videos app); or upload the file to Dropbox and access it that way (by marking the file as a favourite, Dropbox will cache it for offline access). Now I can catch up on my TV viewing whilst I’m disconnected.

I’m still waiting for BBC, Channel 4, et al to step up the mark with their apps though!

Where are the WVP2 codecs for QuickTime on a Mac?

It’s generally accepted that Macs are great computers for graphic design and audio-visual work – so why is it so hard to play Windows Media content on a Mac? I know that QuickTime is the centre of Apple’s audio-visual experience – so why should Apple support competing formats – but perhaps I should really ask why the various software companies have seen fit to introduce such a myriad of audio and video codecs? I’m a techie and I can only just keep up – think about the poor consumer who just wants to share some family videos with the grandparents!

The trouble is that Microsoft, as the developer of the most widely installed operating system on the planet (with a correspondingly huge number of multimedia file formats as described in Microsoft knowledge base article 316922), has seen fit to dump development of Windows Media products for other platforms. Quoting part of the Wikipedia article on Windows Media Player:

Version 9 was the final version of Windows Media Player to be released for Mac OS X before development was cancelled by Microsoft. WMP for Mac OS X received widespread criticism from Mac users due to poor performance and features. Developed by the Windows Media team at Microsoft instead of the Macintosh Business Unit and released in 2003, on release the application lacked many basic features that were found in other media players such as Apple’s iTunes and QuickTime Player. It also lacked support for many media formats that version 9 of the Windows counterpart supported on release 10 months earlier.

The Mac version supported only Windows Media encoded media (up to version 9) enclosed in the ASF format, lacking support for all other formats such as MP4, MPEG, and Microsoft’s own AVI format. On the user interface front, it did not prevent screensavers from running during playback, it did not support file drag-and-drop, nor did it support playlists. While Windows Media Player 9 had added support for some files that use the WMV9 codec (also known as the WMV3 codec), in other aspects it was seen as having degraded in features from previous versions.

On January 12, 2006 Microsoft announced it had ceased development of Windows Media Player for Mac.[4] Microsoft now distributes a third-party plugin called WMV Player (produced and maintained by Flip4Mac) which allows some forms of Windows Media to be played within Apple’s QuickTime player and other QuickTime-aware applications.[5] Mac users can also use the free software media player VLC, which is also able to play WMV-3 / WMV-9 / VC-1 Windows Media files.

It seems that the Flip4Mac WMV Player, which should provide the missing Windows Media support for Mac users (as endorsed by Microsoft) does not support all Windows Media codecs, namely it refuses to play content encoded with the Windows Media Video 9 Image v2 (WVP2) codec.

I can understand Microsoft’s position – after all they want to preserve their market share – so why doesn’t Apple make it easier for switchers with legacy video content? As the iLife applications are such a selling point for Apple, why not make it easier to convert from the Windows equivalents?

My problem is that, for the last few years, I’ve been creating home video content using Windows Movie Maker and Photo Story. They may not be the best video applications in the world but they are fine for movies of holidays and the kids and are included with Windows XP (well, Movie Maker is – Photo Story is a free add on). Nowadays, I have a Mac but I still want to play my old content.  The resulting WMV content from Movie Maker hasn’t caused too many problems as it uses the Windows Media Audio 9.1 and Windows Media Video 9 (WMV3) codecs and simply needs appropriate QuickTime components to be installed. Unfortunately the Photo Story output refuses to play the (WVP2) video track in either QuickTime (WMV Player) or Windows Media Player for Mac OS X and as far as I can tell there are no suitable codecs available.

In desperation, I went back to PhotoStory and tried to export in another format but there is no such option (it supports various screen sizes and frame rates but they all seem to be using the same codec).

One macKB thread suggests using Dr Div X to convert the file but the latest version of Dr DivX failed (on both Windows and Mac); similarly the DivX Converter didn’t work for me.

Eventually, I found a utility that could convert the file for me (Advanced X Video Converter) – it’s done a good job although whilst the quality is acceptable for my home movies there are some visible compression artifacts (I used the H264 video and 24bit audio codecs to convert to a .MOV file). In fairness, the compression artifacts may also be visible in the original WMV file and anyway they are hardly surprisingly as the video was created from compressed JPEG and MP3 files, which have then been compressed to WMV and once more to MOV so the quality is certain to have suffered along the way. What’s possibly of greater concern is the resulting increase in file size – up from 19.5MB to 431.4MB.

I’m glad I got there in the end – for a while it seemed that I would have to keep a Windows virtual machine just to play old home movies – and there I was, naively believing that converting to digital capture and storage would save me from issues with legacy formats.

Missing QuickTime codecs

Earlier this week, I needed to play back a .AVI file in iTunes/Front Row. That’s not really a problem as it’s easy to convert the video to a .MOV file using Apple QuickTime Pro but one major issue was a complete lack of sound.

Now, before I go any further I should explain that there is one common theme throughout the comments section of every site discussing media formats and players – someone always says something to the effect of “use VLC – it plays everything”. VLC is a great media player but:

  • I have Apple QuickTime Pro.
  • I use Apple iTunes and Front Row (both of which depend on QuickTime).
  • QuickTime components are available for many audio and video formats.

In other words, using VLC isn’t the right solution for me. QuickTime gave me a clue as to the problem as it informed me that:

Some necessary QuickTime software is missing. It may be available on the QuickTime Web site.
If you have a dialup connection to the internet, make sure it is active, then click the Continue button to check for the software.

I could have worked out for myself that I was missing a codec (and that message is pretty poorly written… should I not click continue if I don’t have a dialup connection? Maybe I’m reading the message too literally!) but clicking continue took me to the QuickTime components page and I didn’t know which one I needed. I was pretty sure that the video was an XviD movie and I already had the DivX codec (v6.4) as well as Christoph Nägeli’s XviD codec (v0.51) installed but then I found a big clue in the XviD FAQ:

It’s important to understand that video and audio are two separate things, which when combined make up movies. A movie consists of a video stream for the picture and an audio stream for the sound. The XviD codec is what makes it possible to decode the video stream, but it has nothing to do with decoding the audio stream. If the sound in a movie isn’t working you have to find out which audio codec is missing and install it.

The FAQ continues to explain how to use a Windows utility called GSpot to identify the necessary codecs but after reading Mike Peck’s article about playing XviD movies on an Intel Mac (and Paul Stamatiou’s follow-up post on getting Front Row to play XviD, DivX and 3ivX videos), I realised that the missing codec was for AC-3 (Dolby Digital). After installing the A52Codec (v1.7.2) for AC-3 playback and restarting QuickTime and iTunes I was able to watch my video, complete with the previously-missing audio stream.

I’m sure that over time I’ll need to add more codecs and one potentially useful resource is afreeCodec , offering downloads for Windows, Linux and Macintosh computers, games consoles and mobile phones.

Multimedia file format conversions, ripping DVDs, playback and more

Recently, I’ve had cause to convert various multimedia items between formats and it’s not always been straightforward. I’m still learning as DRM, codecs and platform-related issues often complicate the process but this post summarises what I learned along the way with:

  • Grabbing audio content from another application.
  • Trimming audio files down to a particular section.
  • Converting Flash video (.FLV) files to video (as well as converting between a variety of other video formats).
  • Ripping DVD content for playback on the computer.
  • Playing Windows Media content on a Mac.
  • Playing QuickTime content in full-screen mode without buying QuickTime Pro.

I carry out most of my multimedia work on a Mac but some of these solutions will be equally applicable to Windows and possibly even to Linux users.

Grabbing audio content from another application

I’ve just three words to say that will describe how I did this – Audio Hijack Pro – a great application from Rogue Amoeba which takes the audio from any running application and allows it to be recorded.

Trimming audio files down to a particular section

In this scenario, I had about half an hour’s worth of audio, but only wanted to publish a section which was about 3 minutes in length. Apple QuickTime Pro will let me trim tracks, but didn’t seem to let me set the start and end points as accurately as I needed. There is another Rogue Amoeba application that I could use for this (Fission) but tasks like this are pretty rare for me and I didn’t want to pay $32 for what could potentially be a single use (the demo version inserts fades into the track to encourage purchase of the full software which seems fair enough as at least it lets me try before I buy). Instead, I used MP3 Trimmer from Deep Niner – the interface may not be as good as Fission’s, but it’s a fully-functional demo with no time limits and registration is just $10.95 should I find myself needing to trim MP3s more often.

Converting Flash video (.FLV) files to video (as well as converting between a variety of other video formats)

I spent all afternoon yesterday trying to work this one out – I had a bunch of Flash videos which I had downloaded from a website and although I could play them using Eltima Software’s SWF and FLV Player, I wanted to play them in iTunes. After searching the net for hours all roads seemed to lead to a Windows application that would convert the files to MPEG4 format for me (Moyea FLV to Video Converter). The demo version of this application inserts a watermark in the centre of the video (again, that’s fair enough – this is try before you buy) but as I really wanted something for my Mac I decided not to part with the $39.95.

Later that evening, my friend Alex recommended Perian to help me out with problems ripping a DVD (see below) and I found out that the Perian component for QuickTime had already been installed (probably when I had a quick look at the Democracy Player a few weeks back) so QuickTime could already play back my .FLV files! Because I have QuickTime Pro, it can also save the files as .MOVs although I’ve since found Vixy – an online service that will also carry out the conversion from Flash video to a variety of MPEG4 video formats including .AVI/.MOV/.MP4 and .3GP or to .MP3 (audio only).

After I’d done all this, Alex (who really should blog more often about the huge volumes of Mac and Internet-related stuff that he knows and I don’t) told me that he uses iSquint for converting Flash Video for iTunes playback. I had been under the impression that iSquint would reduce the picture size for iPod playback but it seems it can also retain TV size (whatever that is). iSquint also has a grown-up brother – Visual Hub – and, although I haven’t used it yet, it looks to be a pretty useful program which “bridges the gap between numerous complicated video formatting standards”.

Another toolset which may be useful is ffmpegX, which provides a Mac OS X interface to a number of open-source video and audio processing tools. There’s also the Apple QuickTime MPEG-2 Playback component, which enables QuickTime to play Video CD (MPEG1) and DVD (MPEG2) content and even convert them to MPEG4.

Ripping DVD content for playback on the computer

Ripping DVDs. Surely that’s illegal? Only if I then pass copies on to others, which of course I won’t, will I? Let’s be clear from the start that I’m only talking about backing up legally purchased content for personal use.

One application commonly used to make backup copies of DVDs is Mac the Ripper. There is a Windows application called DVDShrink (which allows the DVD content to be reauthored and if necessary “shrunk” to fit on a standard DVD) but to simply rip a copy for local playback the most commonly used application is HandBrake (also available for a while as MediaFork but the two development streams have now merged and future versions will be known as HandBrake). I was having problems using this last night but once I stopped trying to rip at a constant quality of 100% quality (and stuck with the default setting of an average bitrate of 1000kbps – perfectly acceptable for computer playback) everything was fine.

Others have written better guides on this than me… you can find some here:

Playing Windows Media content on a Mac

Although I have a copy of Windows Media Player 9 for Mac OS X (which I think came with Office 2004 for Mac), Microsoft discontinued development of this product a while back and now distributes the free Flip4Mac Player as the Windows Media Components for QuickTime. Unfortunately there is no support for content that is protected with Windows Media digital rights management (DRM) but I’m sure there are cracks and workarounds for those who are motivated to do so… if the BBC distributes content in Windows Media format (therefore cutting out Mac and Linux users) then I might even have a look myself… the Wikipedia article on DRM is a good place to start.

Playing QuickTime content in full-screen mode without buying QuickTime Pro

Apple QuickTime Pro it is a handy application for $29.99 (although, yet again Apple rips us off in the UK with a dodgy exchange rate so it’s £20 here) as it can be extended to play other media formats (as discussed above); however one of the Pro benefits is playing content in full-screen mode. It seems that Mac users can trick the standard QuickTime application into playing content in full-screen mode using a little AppleScript. For QuickTime users on Windows, I wrote about some methods for full-screen MPEG4 playback last year – including simply playing the content through iTunes!

I hope this pile of multimedia tips has been useful. Comments are welcome from those who have other free or low-cost solutions to contribute to the mix.

Embedding video content in (X)HTML

Yesterday’s Mac vs. PC post should have been straightforward, except that it contained three video clips, each of which I wanted to embed in a standards-compliant way whilst maintaining maximum browser compatibility (i.e. ignoring the official advice from Adobe on embedding Flash content and Apple’s advice for embedding QuickTime content by avoiding the non-standard <embed> element and just using the <object> and <param> elements)… what a task that turned out to be.

To be honest, a lot of the problems probably came down to me not thinking my code was working because the preview function in my content management system (Blogger) failed to display the videos in one browser or another so, after another late night, I decided to publish and be damned. The resulting code seems to work for the Flash content on most the the browser/operating system combinations I have tried (Mozilla 1.7.13 and Firefox 1.5.06 on Linux; Internet Explorer 7.0.5730.11 on Windows XP, Safari 2.0.4 and Firefox on Mac OS X – Intel), although I was using Adobe Flash Player 9 (I’m not sure which version is needed for the clips I used so I didn’t update the codebase attribute to reflect it – older player versions will not automatically update until I fix this) and I’m aware that there may still be some issues with the QuickTime clip (it does seem to be working on Firefox and IE though).

So, how should this be done?

Firstly, the valid Flash, video, and audio embed (object) markup post at the Web Standards Project links to some great articles which should be read, namely:

These give the background to why the <embed> element shouldn’t be used, as well as demonstrating the use of conditional comments to force certain browsers into compliance. I actually used another variation on this theme – David Grudl’s how to correctly insert Flash into XHTML – ironically this uses a negated version of Internet Explorer-specific conditional comments to force IE into ignoring code intended for other browsers!

Then, there is the issue of the changes made to the behaviour of ActiveX content in Internet Explorer, following the Eolas patent suit, as described by Robert Nyman. In my case, it doesn’t really matter if you need to activate a control to view a video clip on my blog; however there are some workarounds. Most use JavaScript (indeed Adobe recommends a JavaScript-based workaround to the changes made in Internet Explorer) and one popular alternative is to use document.write in an external JavaScript function to dynamically re-write the object embedding code. Alternatives include Geoff Stearns’ SWFObject (formerly known as FlashObject) and Bobby van der Sluis’ unobtrusive flash objects (UFO). I plumped for a version I found in a comment by Karl Rudd the Robert Nyman post that I linked earlier (Fix It uses a similar concept, also advocated by David Grudl in his post on how to avoid activation of ActiveX in IE).

After spending most of yesterday working on the object embedding, and a good part of this morning writing about it here, I think I’ll leave that one alone now, unless anyone has any better ideas to fix my code (note that the <br /> tags scattered through it were added by Blogger – not by me).

Nerd TV (how to play back MPEG-4 video without using Apple QuickTime Pro)

My wife is out tonight, so I’m home alone. I’ve been working pretty hard recently and am very tired so I’m under strict instructions to relax and go to bed early (especially as it’s my turn to get up with our son tomorrow morning… probably at about 5.30am).

The trouble is that I’m also a nerd (as indicated by blogging late at night!) with a geek rating of 40% (this has gone up since I started using Unix) and I have a load of episodes of Nerd TV that I’ve been meaning to watch since it launched last September.

Although the MPEG-4 Nerd TV download is only available at 320×240 resolution, I wanted to watch it scaled to full screen. This was a problem as Apple QuickTime 7 Player only lets me watch it at double size (unless I upgrade to the Pro version) and Microsoft Windows Media Player 10 can’t handle MP4s (Microsoft knowledge base article 316992 has more details).

I tried installing the 3ivX D4 4.51 CODECs to allow MP4 playback in Windows Media Player but playback was too fast (sounded like the Smurfs). The DivX 5.2 CODECs that I had lying around on my external hard disk didn’t work either (and I have a feeling that you have to pay for the latest ones) so I switched to MPlayer on my Solaris box (after first trying the Totem Movie Player, which also failed to play back files with a MIME type of Video/QuickTime).

MPlayer is a really good command line media player for Linux (there are also Solaris and Windows ports available) but I experienced some quality issues when running full screen. Using /opt/asf/bin/mplayer filename -vo x11 -zoom -fs informed me that “Your system is too slow to play this!”, although it did also help out by suggesting various switches to try in order to increase performance.

I didn’t have time to figure out the optimum MPlayer settings so I went back to Windows Media Player with the 3ivX CODECs, thinking I mist be able to do something to fix the playback speed. Purely by chance I found out that simply stopping (not pausing) the playback and starting again corrected the speed and gave a perfect playback.

Finally, I remembered that Apple iTunes is built on QuickTime… I wish I’d tried this an hour or so earlier as I found that my MP4s will play in full screen mode within iTunes. Having said that, Windows Media Player 10 with the 3ivX CODECs looks to provide a smoother image when scaled to full screen; however that could just be my eyesight (or my Microsoft-tinted glasses).

So there you go – three methods to play back MP4s at full screen without using QuickTime Pro: Windows Media Player with 3ivX CODECs, MPlayer, or iTunes.

Standalone QuickTime installer

Apple QuickTimeI have Apple iTunes installed on the PC where I synchronise my iPod. I don’t need it anywhere else, but for some reason if you try to download Apple’s QuickTime, it comes bundled with iTunes. Thanks to a Tech-Recipes Internet tip, I found the standalone QuickTime installer. Now all I need is for Apple to realise that I don’t want to install an English (United States) version – if there’s only one English option available, then please call it English.

Sun’s university challenge

Last week I blogged about Microsoft’s contest for the New Year and here’s Sun’s – a university challenge to encourage programming students to create a new application or port an existing application to the Solaris platform. The winner gets $5,000 and their university gets $100,000 to spend on Sun equipment.

There’s even a list of ideas for projects – and after just a few weeks of using the platform I agree with many of these (like a QuickTime player – Apple should have come up with one for Linux/Unix by now – after all, isn’t OS X based on Unix?).

Of course, some of the ideas are just plain laziness on the part of Sun – they should really be writing their own bug fixes and creating new device drivers, but then again, now that Solaris has become open source, maybe that’s the whole idea…