Friday, July 24, 2009

Got me some N97

Hi,

Yesterday I finally got onto the bandwagon of the N97. I've read a lot about it, the ups and downs, got to try it out for myself and finally got one.

At first I thought it was going to be a big change from the 7710 and the N96. And it is and isn't both at the same time.

On the one hand it does most of what the N96 did and even adds a few things, and from the old 7710 back is the touch interface, the handwritting window and a few other tricks. But on the whole it doesn't add a lot more than adding touch to S60. I won't repeat what has been said ad-nauseum. Instead I'll focus on the topic and reason why I got this. Can you guess?

Well to play videos of course.

There's nothing really new or added that I've discovered so far from the N96 features. The old post I made last year about what settings to use still pretty much applies and there are some minor drawbacks even when compared to N96.

To start, some WMV videos that used to play correctly in the N96 seem to stutter in the N97. It could be that the CPU is indexing still some data since I just got the device but it's odd. Other than that videos that are in an aspect ratio of 1.77 (16x9) play great. So my old VGA and QVGA videos will need to be re-encoded to play better in this new screen format.

Also worth nothing is that the best resolution to use in this device will be 640x360 (native resolution) but doing some testing I found the PSP old resolution (368x208) to also work great. Not only is this the correct aspect ratio but for the size of screen it's sharp enough thus saving some CPU power and size.

I also ran into problems playing H264 videos even though they're playing fine in the N96. I had the same problem when moving from the N95 to the N95 8GB then to the N96. There are subtle differences in what they support. This is a big headache, I think with each new model the support will be expanded while keeping compatibility but alas this is not the case.

Some have claimed that H264 support is not there for the initial firmware release, I can't confirm this but I can't get H264 videos to play either. Maybe future releases will fix this as it stated in Forum Nokia that N97 DOES support H264.

TIP: Just like in the N96 and other newer models when you load a lot of content (videos, music, photos), the phone goes into indexing mode in the background. Everything slows down to a crawl and it can take 5 minutes or more to finish indexing everything (loaded 700 songs, 15 videos and 30 photos). Even though there's an option to Refresh Library, this doesn't work like it used to in the N95 or N91, you just have to leave it alone and wait until the contents show up. The device should provide some indication that it's doing this.

TIP: Don't shut off your phone or take out the battery right after loading contents, doing so could corrupt the databases.

Another thing I noticed is that the N97 doesn't support user created thumbnails like the previous models. Even if you load the picture with the video the "Videos and Photos" applications will create their own thumbnails which is a drawback as many of them are just a black screen or whatever is the beginning of the video. If you have several movie trailers you will get a bunch of icons with the green start screen. :(

TIP: When playing video you can stretch, or zoom to fill the screen useful for different aspect ratios.

TIP: You can use the rocker key to control playback. Center select acts as Play/Pause. Up and Down is FFW/REW and left and right control the volume.

Well this is the first couple of days of using it, hopefully with more time with it I will learn some workarounds to get more performance out of the video playback. Also I'm waiting for CorePlayer and DIVX to release their versions for this phone.

Until next time, keep on reading.

Thursday, July 2, 2009

3GP, MP4, M4A, WMA, AVI, DIVX and codecs

Hello again,

As the title suggests today I'm going to write a little bit about different Video file formats and what's the relationship between the file format (also called container) and the Video codecs. Finally I'll make some comments about some differences and what file formats and codec combos are better to use in Nokia phones and what are some common drawbacks.

Some of this information or for more details check out my Older post on How to become a better video editor

File Formats

The first thing is that we need to understand that the file container or wrapper, also known as the file format is what the name implies, just a wrapper, a structure or vessel where the content is going to be contained.

A file with extension MP4 can contain many different things inside. It could be an audio file, a video file, audio/video, or something else. The audio or the video can be encoded in many different ways and also using different codecs. Like xVid, MPEG-4, MPEG-4 AAC, eAAC+, H263, H264, to name a few.

The same goes for M4A or AVI or other file extensions. In fact M4A containers can have also video and they will work in Nokia devices, and MP4 can contain MPEG-4 audio files and they will play in the Music Player.

Some file extensions are commonly used only with one format of codec, but this is just that. It's commonly used. But you can put other things inside it and it's still a valid file and will work with several programs. Some extensions have changed it's use throughout time.

3GP format and later 3G2 were selected as the file container for MMS files and other telephony video formats as part of the 3GPP Standards. In general these files usually contained H263 encoded video, but more and more they are containing MPEG-4 and H264 video.

In the 90's .AVI files where usually containing uncompressed video like IndeoVideo, YUV2 or MSvideo. Now most AVI files contain xVid or Divx coded videos. But I still have some old encoders that will encode raw video into AVI.

This is one of the problems most people have when they try to play videos on their portable devices. They see an MP4 extension and assume that the video is MPEG-4 and that it must play in the device because it supports MP4. This is far from true. You need to know what exactly is inside that MP4 wrapper to know if it will play.

Some proprietary codecs have proprietary extensions so they are a bit easier sometimes. Still the contents could be different depending on the codec version used. See Video Codecs. Some examples:
  • DIVX coded videos are in .divx file format
  • Windows Video 8/9 videos are in .WMV file format
  • Quicktime format videos are in .MOV file format
  • MacroMediaFlash videos are in .FLV file format
  • RealVideo videos are in .RM format

Video Codecs and their relationship to File types

Ok so now that we know a bit more about file formats and containers, let's talk a bit about codecs. There are a number of video codecs. Each codec usually has also several versions or levels or a combination of both. E.G. H264 can be Baseline or Main Profile and then there are 4-8 levels within each profile.

The most common formats for videos I've come across are:

AVI files
These files usually contain divx or xvid coded videos. Although as mentioned before sometimes they contain uncompressed video. These files don't play out of the box in Nokia devices, but you can install Divx mobile player, Smartmovie or CorePlayer to use them.

MOV files
This is a proprietary format from Apple. They usually contain Quicktime coded files although more and more files I've seen contain MPEG-4 or H264 (MPEG-4 AVC) coded videos. These only play in the iPhone. You need to change the container or re-encode them into a suitable format.
Some MOV files have 480p, 720p or 1080p video resolutions. Also called High Def.

WMV files
This is a Microsoft proprietary format that has been licensed by many vendors including Nokia. The most recent Nseries devices starting from the N78 and N96 can play WMV videos if they are WMV8 or WMV9 and the resolution is less than QVGA (320x240). Newer models may support higher resolutions but I haven't tested that.
Some WMV files contain AC3 audio (5.1 surrund sound) and can contain HD content (very high resolution video). This is great to watch in a nice flatscreen, but require conversion to be able to watch them on the phones, and some encoders still can't handle AC3 correctly.

FLV files
MacroMedia flash has existed for many years. It was used for video and animations since the early 90's and came of age with the internet. But it wasn't until Google Video and YouTube started using this low quality file types that FLV really took off. Before FLV streaming became the norm most sites were using RealPlayer or ASF (windows format) to stream video over the internet.

Now it seems that even in the Microsoft video webpages they use FLV format to stream video content. The advantages of FLV is that it's very economical in bandwidth and storage the downside is that it's not very high quality. Now they have the HQ option in YouTube but then you lose the advantage of the low bandwidth. Another quirk is that usually you can't download these videos they're for streaming. You need some special or extra software to save the stream locally so you can re-encode them or transfer them to your device.

FLV videos will play on most new Nseries devices, but high quality FLVs may stutter quite a lot as they need a lot of CPU to render. Still, the best way to watch them is in the browser, but you can also side-load them and play them from the File Manager.

RM Files

RM or RMVB files contail RealVideo coded videos although they can contain audio only as well. There are many versions of the RealVideo codec and not all of them are supported properly in Nokia devices, so it's a bit of a gamble if you have an RM file. It may or may not play. Also the resolution needs to be a specific one otherwise it may not play 320x144 may play but 320x140 may not. I haven't figured out what the pattern is. It may be that it needs to be divisble by 16 or something like that.
The main advantage for these files is when you are using a streaming server since in a single file you can have support for multiple downlink speeds, so that the watching experience is good even if your broadband is not very fast.

MP4, 3GP, 3G2, M4V files
I put all of these file types together because they can pretty much be used indistinctibly. Also these files are surprisingly not very common even though a lot of mobile phones use these file types. Even some people have trouble playing them back specially the 3GP and 3G2 file types.

Most of these files can contain a number of different things and as such they are sometimes the trickiest to figure out why they don't play correctly. In many instances I end up re-encoding them again into the same file type but with a different codec or settings.

Mp4 seems to be the one that is sticking more and more as a Video format, but what's inside seems to vary a lot. Many of the MP4 files I've come across contain MPEG-4 or MPEG-4 AVC H264. But some contain xVid.

I actually found it odd that although most people think of MP3 as a music file format but even though MP4 can also contain music files, people think more of M4A as the MPEG-4 file format. I guess it's all thanks to iTunes, but it's funny to me nonetheless.

For a while I used 3GP for H263 coded files and 3G2 for MPEG-4 videos, it's convenient as this file format is supported by all 3G phones (or should be as it's part of the 3G standards). But like everything else, some combinations are not supported. Is should also be noted that 3GP, 3gpp can also be used for music files. Older 3GP files will have AMR or WB-AMR audio which does play in most phones but may not play in some PC video players.

Some differences in Codecs

Ok now I explained the different common file types and the codecs they usually contain. Now I'll talk about some differences.

One thing we need to keep in mind is that different codecs perform different types of compression. A codec is really a compression algorithm. The most effective codec then is the one that will look better with the lowest bitrate. In other words, the benefit of a "better" codec is that you will get better results with less information (bits, bitrate, file size). This is very important, because at some point, if you use too much bitrate you will lose the benefits of the codec and the resulting video quality and file size is the same regardless of the codec.

Newer codecs are not "better" than older codecs in terms of video quality.

Newer codecs are better in terms of compression, so they yield better results at lower bitrates.

As an example. If you encode a video in QVGA resolution at 2.0 Mbps into an MPEG-4 codec and also in an H264 codec also at 2Mbps the resulting videos will be almost exactly the same in terms of file size and video quality. The same could be said for xvid. So at this bitrate the benefits of H264 are lost, there is no better quality to be gained by adding more information (bits). But if you do the same video (QVGA) but do it at 128 kbps in both MPEG-4 and H264, then you WILL see a clear difference.

The same could be said for H263, MPEG-2 or MPEG-1. At low bitrates the vides done in these codecs will not be as good as the results using xvid, divx or H264.

BUT, if you crank the bitrate high enough you will get the same size and quality from any video codec.

This makes sense. After all DVD are encoded using MPEG-1 or 2 and blueray are mostly MPEG-4 AVC to get the size down for HD resolutions, but the first bluray discs used MPEG-2 video.

I hope I didn't confuse you a lot with this.

So what's the difference?

"Best" codec/file combos and common drawbacks
The difference of the different codecs/file formats for ME (IMHO) is how easy it is to move them between my different devices. PC-PS3-Phone-PSP-Digital Frame

With now most phones supporting very high bitrates of 1.5 to 2 Mbps videos in MPEG-4 and H264, the quality issue is pretty much done. That is until we move to larger resolution screens beyond the VGA range.

I tend to like AVI files containing xvid or divx codec if I have them already in this format. This is by far the most supported format I've seen. It seems to be everywhere. There are a ton of devices that support "DIVX files" in AVI format.

If I'm encoding a DVD or other source video for use in my devices I first make a master copy in DIVX at the same resolution and high bitrate to use as the basis for further encoding. This has served me well since my days with the 7710 and Ngage. As devices supported higher resolution I could re-encode the master high rez copy into new formats. Then I encode into whatever is the best for my device. In the case of the N96 the best seems to be MPEG-4 (also because Nokia only supports baseline H264 which is not supported by other devices sometimes). I use the MP4 file format as this seems to be the most commonly used.

RealVideo formats seem to be disapearing fast IMHO, I don't see it as often. FLV is king for streaming but not so for local playback. WMV is so-so. Mostly I've been using it for my home movies because I had already a bunch of home videos in WMV format, but I never convert videos into WMV if I can help it. Also the fact that only QVGA max resolution is supported in N96 is a drawback. Haven't heard if N97 brings WMV support for higher rez.

H263 in the 3GP file format is fairly common as many basic phones only record into 3GP using this codec. But more and more are using MP4/MPEG-4 combination to record, so it may be that in time it will go the way of the .qt files or .rv or .nim

And if you don't know what those file formats are then you have nothing to worry about, you're still young and have a long life in front of you. ;-)

Until next time I hope you enjoyed this.

PS: All these comments are IMHO. If you have a different perspective then good for you!

FREE TRIAL