Showing posts with label information. Show all posts
Showing posts with label information. Show all posts

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!

Sunday, June 28, 2009

Common resolutions, CIF, qCIF, QVGA, etc

Hello again,

Just briefly I'll post some common resolutions and names so that we are all speaking the same language.

  • CIF 352x288
  • qCIF 176x144
  • sub-qCIF 128x96
  • nHD 640x360*
  • VGA 640x480
  • QVGA 320x240
  • WVGA 800x480**
  • SVGA 800x600
  • SVCD 480x480
  • VCD 352x288 or 352x240
* Screen Resolution of 7710, N97, 5800
** Internet tablet N800/N810 screen resolution

Another resolution to keep in mind is 176x208 which was the resolution of some older models before QVGA became the standard screen resolution. E.G. N91 8GB.

Hope this information is helpful.

Until next time, keep on watching.

Tuesday, September 9, 2008

My recommended settings for N96 video

Hello again.

On this occasion I want to share with all my list of recommended settings for encoding video to be used in N96.

While I've done a lot of testing, please note that this is just my recommendation, and this was tested with a firmware that may be different to what you have in your hands so things may have changed.

I'll keep using the N96 and if I find any significant changes I'll post an updated version. I've also done efforts to cross check my findings with what's available from official sources so I feel pretty confident that these settings are accurate.

As always, if you have comments or questions, feel free to add them here. I'll do my best to review, post and answer any questions you may have. Even if the answer is "I don't know" ;)

Ok on to the settings:

For playback in N96 screen

Codec: MPEG-4 Part 10 AVC/H264 Baseline Profile

Container: .mp4

Resolution: QVGA 320x240

Aspect Ratio: 4:3 (1.3333)

Framerate: As per source but limit is 29.97

Bitrate: 600 kbps (but can go as high as 1 Mbps but there's little gain in quality)

Audio: mpeg4aac, 96 kbps @ 44.1 KHz sample rate (can use 48 KHz if source is 48 KHz)

For use with TV-out


Codec: MPEG-4 Part 10 AVC/H264 Baseline Profile

Container: .mp4

Resolution: VGA 640x480

Aspect Ratio: 4:3 (1.3333)

Bitrate: 1 Mbps

Framerate: As per source up to 29.97.

Audio: mpeg4aac, 96 kbps @ 44.1 KHz sample rate (can use 48 KHz if source is 48 KHz)

Alternatively you can use MPEG-4 Part 2 SP/H263 Simple profile as the codec and use bitrates of 3 Mbps, this creates much bigger files but it's an alternative to H264/AVC.

Keep in mind that TV-out will change your video somewhat as the video will need to streched/cropped to PAL or NTSC and also the frame rate will change to comply with TV standards.


For WMV videos

Resolution: CIF (352x288) or QVGA (320x240). I haven't tested but QCIF (176x144) may also work.

Codec: WMV9 VC-1 SP/ MP.

Bitrate/Framerate: Depends on the profile you use. VC1 Simple profile: low level (QCIF 15fps), medium level (QVGA 24fps / CIF 15fps 384 kbps, VC1 Main profile, low level (CIF 30fps 2Mbps)

Audio part will be WMA (WMA2 part of WMV9) Use 32 kbps. and sample rate as per source material, you can of course go higher depending on the video bitrate. But for most cases I rather sacrifice audio quality than video since there's not a lot of headroom.


For Flash Lite Videos

If you are already converting your videos to FLV you can also use them on the N96 but these videos don't show up in the Video Manager or Photos applications so you need to access them through the File Manager.

Here are the specs:

Codec: Sorenson Spark or h263 or VP6

Resolution: QVGA 320x240

Bitrate: 192 kbps (for video part)

Framerate: 25 fps for h263 15 fps for Sorenson or VP6

Audio: MP3 (Mpeg1 Layer 3) variable bitrate

Combined bitrate should be around 350 kbps (in my tests if you start going to around 500kbps then the playback becomes choppy).

Other Codecs and Containers

There are other possible codecs to use, like Realvideo (Rm or Rmvb) but after doing some testing I don't recommend using Real as the performance is much restricted. I guess the main reason for still keeping real (keeping it real), ;) is mainly for video streaming. So CIF and QVGA are the main resolutions, only 15 or 25 fps is supported and the bitrate needs to be quite low (256 kbps).

You can also use .3GP and .3G2 containers for MPEG-4 codecs, as well as using .M4V container. Just keep in mind that iTunes uses H264 MAIN profile in their .m4v videos so they will NOT play in N96.

WMV can also have the extension .ASX or .ASF usually for streaming links. I had had some problems if the wmv or asf file contains more than 1 video or audio stream. The end result being that it doesn't play or plays partially.

MPEG-4 Part 10 also includes the "normal" mpeg-4 (non AVC) and several Levels are supported. Baseline profile Levels 1, 1b, 1.1, 1.2, 1.3, 2. So it's an alternative as well.

Thumbnails and other issues to keep in mind

You can still create you personalized thumbnails to be displayed in video center following my previous tips. HERE
The file attribute “hidden” should be turned on for the thumbnail. The best way to do this is to set the hidden attribute when you create the images on a Windows PC (right mouse click on file in File Explorer -> Properties ->Hidden). Or use YBrowser to achieve the same effect.

  • TIP: Some things to keep in mind is that when you load a lot of video clips, video center may not show them right away, you may need to leave it open for a few minutes before the library is refreshed. While this is happening your videos may not play correctly as the N96 is furiously searching for all those videos and creating thumbnails.
  • TIP: If you just inserted a Memory Card with lots of videos, they may not appear right away in the Video Center, you have to let the program find the videos. It's very important that you either a) DO NOT remove the memory card while Video Center is searching for videos or b) Use the"Remove F: Memory card" option from the power button. Failure to do so may cause corruption to the Memory card

Also, the Photos application also shows videos stored in your device. So you can choose whether to use Photos or Video Center.

  • TIP: Remember to save your videos in the VIDEOS or MY VIDEOS folders in the Mass Memory (E:) or the memory card (F:)
You can use either the front media keys or the landscape (hidden) media keys to control the videos. When the landscape media keys are exposed, i.e. Slide is down, then the front media keys will be inactive.


Wednesday, March 12, 2008

Will this video play on my Nxx?

Sometimes the question is: why doesn't this video play?

Well to learn more see my old post HERE

_________________

I know some of you will not so here are some more generic tips.

These are the generic baselines for most Nseries devices. Some models support more, but as a general guide.
Basic compatibility
  • RealVideo 8,9 and 10 (note that there is no support for Realvideo 7! or 11). Video size of QCIF, QVGA , CIF. Bitrate of 128 Kbps.
  • h263 video in 3GP or 3G2 or MP4 container at 128 kbps (narrow band audio AMR or AAC)
  • MPEG-4 in a 3GP, 3G2, MP4 or M4V container at 256 kbps (aac audio mono or stereo)
And that's it!. Then you start getting into the category that some will play and some will not.
Newer Nseries:
  • Support VGA MPEG-4
  • (N95, N81, N82, etc) support H264 in an MP4 or M4V container. BUT, and this is key, only the Baseline profile of H264 is supported.
iPod, iPhone and PSP also support H264 but they support different versions of the codec. Including Main Profile, Sorenson H264, Spark or other levels of the BaseLine profile not supported by Nseries phones.

This is why many of the H264 videos don't play on Nseries devices even if they are in a supported resolution and bitrate.

As of today N95, N95 8GB, N93 and others support H264 at QVGA resolution. At VGA it will stutter or not play regardless of the bitrate or frame rate.

A note on quality, different codecs and framerate.

In general, the quality of a video is dictated by the resolution, bitrate and the frame rate. But these parameters also control the size of the video.

Plus if you use MPEG-4 and AVC (H264) the resolution has to be divisible by 16, otherwise you waste a lot of space (resulting file is needlessly large). So if you use a resolution of 640x480 this is better than 640x396 since 396 is not a factor of 16. 320x160 is better than say 320x150. 320x144 is OK though.

OK, this is basic good information but I want better quality than the general compatible quality!

In this case it starts to get more complicated as videos you encode may ONLY work on your device and may not work on other devices. For the best settings IMHO see my post about using SUPER.

What if I want to play AVI files or XVID?

This is also a common question. First thing is you need to get a player for your device that can play this codec.
I recommend you get DIVX mobile Player (see links at the bottom of my blog)

If you want a better experience and don't mind spending some money get CorePlayer or Smartmovie.

Anyway. What ever the player you get there will be some limitations due to the smaller CPU in the phone than your PC. So as a rule of thumb in my experience videos that are smaller than VGA tend to play almost correctly. Videos that are VGA or greater will drop many frames. Again QVGA, CIF videos play correctly almost 100% of the time. Also VCD resolution plays ok (480x480) for the most part. But once you get higher than this you start running into problems.

TIP: Using TV out is great because TV-out resolution is VGA instead of the internal display 's QVGA. So you see more pixels with TV-out.

TIP: When you use TV-out the CPU has more to do, so a video that plays marginally good in the phone may not play or play worse when using TV-out.

I welcome your comments. Tell your buddies about the blog, email the posts. Let's get more people into enjoying Video in their Nseries devices!


How to COPY files between PC and Phone (Just for you bettina...)

Ok here are some pictures on how you can Copy a file in the PC from one folder to another.

First open the Windows Explorer to the folder you want the files. In this case the Output folder from SUPER. See picture:
Alternatively you can select the file then right-click on it like this:
Now the file is the windows "clipboard" a temporary storage location. Now open the folder in you phone, in this example is E:\My Videos but it could also be I:\My Videos.
Select Paste.

You can do this with many files at a time, folders, or one by one.

Other tips. If you want to select multiple files, select one file (click on it) then hold down the "Shift" key on your keyboard and select another file. All the files in between will be selected.

Another method is to click on one file then hold down the CTRL (Ctrl) key and select another, now both files will be selected. You can use this method to control which files you select. If you want to remove a file from the selection just click on it again (while still holding down the Ctrl key).

I hope this helps!.

Tuesday, March 11, 2008

How to become a better Video editor...

Ok the title is a little deceptive.

I assume most people don't want to learn, couldn't care less .... about the technical details and nuances that come with digital video editing, video encoding and video conversion or transcoding. And I agree 1000% :)

But to be honest the only way to make sense out of all these things is to study a bit and learn about what you're up against. At the minimum you should have this links somewhere so that if you see an acronym or term you don't understand you can go and read about it. READ, such an underrated tool...

So without further ado, here are some good links for information:

So what do Nokia S60 devices support?; well see this:
Nokia Video Feature table (press "Audio & Video Features tables")
Unfortunately not all the information on that Table is accurate. E.G. In there it shows the N91 supporting 320x240 h264 AVC which is incorrect, it only supports QCIF h264.

If you don't know what QCIF means go HERE.

A good guide about "anamorphic video" and why should you care. No, honestly this is a must if you are encoding videos from a DVD and want to get rid of those pesky black bars. AnamorphicGuide
If you still feel like you need to get to the bottom of the resolution issues. READ this it's a really good page.

Video Containers (these are those extensions we see but are different that codecs)

Different Video Codecs (Must read this)

DVD video Highly recommended to read.

MPEG-4

MPEG-4 Video stuff

MPEG-4 Part 2 Divx, Xvid and Quicktime

MPEG-4 levels

Video Codec (what's a video codec really?)

Mpeg industry forum

This is not an extensive list and by no means do I encourage people to become experts. But if you are of a technical inquisitive nature, then go and learn about it, and then come back and teach me a thing or two ;)

Cheers!

Tuesday, February 26, 2008

Welcome to this blog

Hello all.

Some of you may know me from the Nokia discusssion forum link others may have found their way here from a search engine.
The purpose of this blog is to post some detailed instructions and information about Video Coding for Nseries devices in general but also for the upcoming N96.
A few words about myself. I've been a fan of mobile devices and techno-gadgets for more than I care to admit. I was also a fan of computers since the personal computer was in its infancy, but as I got older (and hopefully wiser), I moved more into portable devices and away from the PC and coding.
Throughout these times I've used many a mobile phone and other mobile devices (palmtops, PDA, portable gaming devices, etc.). Personally I'm also a bit of a gamer, more than a casual gamer, but not a hardcore gamer, a photo aficionado (used film until 2 years ago when finally I made the switch to a digital SLR), a part time musician (I'm also part of a band), and audio/video technogeek.
I've used Nokia devices for a number of years. Since the 2110, 6110, 6160, 7110, 7710, 9210, N-gage, N-gage QD, up to the N91, N91 8GB, N92. Recently I also used the N81 and N95 8GB.
But my main devices at the moment are the N91 8GB and the N95. That is, until the N96 comes out.
I'll post some general tips about video encoding that I've learned or picked up from other helpful users in other blogs/fora. Posting pictures and screenshots as applicable. And if you like some specific topic to be added please leave your comments.
I don't plan to answer each comment individually but look forward to improvement ideas.
Until the next post, keep on rocking!

FREE TRIAL