Log in

View Full Version : TUTORIAL: resizing/downsampling .AVI videos


Menneisyys
10-15-2005, 08:39 PM
When you may need this tutorial? If you have full-resolution (PAL/NTSC) videos in AVI files and a QVGA PDA, you most probably will want to resize them before playing.

There's no point in trying to watch full resolution videos on QVGA Pocket PC's (as opposed to VGA PPC's) because the screen has too small a physical resolution to be able to display the video at its full glory (full resolution). It will only cause tons of dropped frames, annoying pauses in playback and a lot of excessive CPU utilization (resulting in really short battery life and, sometimes excessive, CPU heating).

When may you run into full-resolution videos and not QVGA-optimized ones? A lot of the video playing-related questions I've run into on various Pocket PC boards (see for example http://www.pocketpcmag.com/forum/topic.asp?TOPIC_ID=18720 and http://www.pocketpcmag.com/forum/topic.asp?TOPIC_ID=14426 ) concern playing full-resolution videos (while, of course, the 'How do I put my DVD to my Pocket PC?' question is the most often asked. In this tutorial, I do not explain the latter – only the case of resizing/downsampling source AVI videos. Please read the excellent reviews/tutorials/comparisons of DVD to Pocket PC converters). This clearly shows this problem is indeed acute for many. This is both the case of third-party videos available on, say, p2p networks and with encoded videos you've done yourself (unless they are in WMV – I don't think any video should be encoded to WMV as Pocket Windows Media Player is so inferior to Pocket Media Player (TCPMP; http://tcpmp.corecodec.org/about) and the WMV format - because it's a closed, proprietary format and is, therefore, pretty hard to convert to other formats or even resize/downsample - is so much worse than DivX/XviD. Please note that I'm not saying anything about the quality of WMV, which is very good, just its openness and Pocket PC support.)

Note that this tutorial can also be used by VGA device owners for a very simple reason: sometimes, they will also run into video files that are not exactly 640-pixel-wide. With videos like these, it may (I haven't done excessive benchmarking on this question; therefore, I may be wrong) be, in cases, advantageous to resize these videos to be exactly 640-pixel-wide so that TCPMP doesn't need to do the streching itself, which may be a CPU-intensive task.

To achieve the best results, you should use either DivX or XviD as the video codec and use videos that have the same width as your screen (and the above-mentioned/linked TCPMP as the video player).

To convert your AVI (that is, mostly, DivX/XviD videos) to this optimized format, you'll need to do the following:

1. Get the trial version of DivX Create ( http://www.divx.com/divx/create/download/ ); it has a 6-month-long trial period so you will have plenty of time to decide it if you need it or not after this period. Install it.

Note that if you don't want to pay anything and don't want to use trial versions either, you still have several choices:

- get the free PocketDivXEncoder (PDE; http://divx.ppccool.com/ ); which makes the conversion even easier (no need for height computation; batch mode etc) and, because it already contains the necessaary codecs, doesn't require separate codec installs. The reason I'm still recommending using the DivX (or, XviD) + VirtualDub combo because the latter is far more flexible and you'll be able to use it for a lot more purposes – not just for converting for your gadgets. The other reason is that PDE isn't developed further (much as the latest beta version is dated a month back) and, therefore, doesn't necessarily contain the best-quality, latest, most effective codec. Note that Lathe, the successor to PDE, is a commercial program and doesn't even have a trial version; it's very cheap, though.

- get the free XviD codec from http://www.xvidmovies.com/codec/ and install it. I'll explain its usage later – it's pretty similar to the DivX codec.

2. Get the free VirtualDub (http://virtualdub.org/ ). Current version is 1.6.11; this tutorial is also based on it. Unzip it to a directory and start the unzipped VirtualDub.exe .

3. Once in, load (Ctrl-O) the file you want to edit. In this example, I use the freely downloadable Star Wreck (see http://www.firstloox.org//forums/showthread.php?p=41492 for more info) as it's a "problematic" movie on old, slow(er) PDA's because it's a full-resolution video, which must be resized before watching, especially on aging Pocket PC's.

You'll get the following screen (the video area is black because it shows the first screen of the movie. You can move the slider at the bottom to switch to other screens):

http://www.winmobiletech.com/102005AVIConversion/VDubResampleTutorial-1.png

Go to Video/Compression . Choose DivX 6.0 Codec :

http://www.winmobiletech.com/102005AVIConversion/VDubResampleTutorial-2.png

Press the Configure button and enter 300 (300 kbps is pretty good for quarter-size videos; if you still encounter dropped frames – which are pretty common with really old/slow Pocket PC's; for example, the Casio E-115/E-125, you can go as low as, say, 150-180 kbps) in the textfield on the right of Encode mode :

http://www.winmobiletech.com/102005AVIConversion/VDubResampleTutorial-25.png

Note that if you've downloaded the XviD codec, you'll need to choose XviD MPEG-4 Codec instead. To set the target video speed, click the Configure button and set the Target quantizer slider. Make sure you don't go above 10 (you may want to experiment with it a bit); then, the quality will quickly become very bad.

Go to Video/Filters. Click the Add button. Choose resize from the list on the left:

http://www.winmobiletech.com/102005AVIConversion/VDubResampleTutorial-3.png

Click OK. In the next dialog,

http://www.winmobiletech.com/102005AVIConversion/VDubResampleTutorial-4.png

leave the default 320 of New width intact (it's the vertical screen size of your PDA). The New height value is a bit more problematic. To compute it, you'll need to do some math, based on the values you get at File/ File Information...:

http://www.winmobiletech.com/102005AVIConversion/VDubResampleTutorial-5.png

Here, pay special attention to the first row, Frame size, fps. You'll need the value at the left, which is, in this case, 640x272, which means the width of the frames in the video is 640 pixels, while the height is 272.

Now, for the math. To get the new height (NH; the old width/height will be accordingly abbreviated as OW/OH) that must be entered to VirtualDub, use the following formula:

NH = OH * 320 / OW

(Note that you must use the same formula if you resize (in most cases, enlarge, because most videos are either 640, 608 or 576 pixels) videos for VGA. Then, just change 320 to 640.)

That is, in the case of the Star Wreck video,

NH = 272 * 320 / 640

That is, NH is exactly 136. This is what you must enter in the New height field. (Leave the Expand frame and letterbox image checkbox disabled. BetaPlayer/TCPMP automatically centers/letterboxes videos, so, you won't need this feature.)

Also make sure Direct stream copy is checked in the Audio menu. (The high-quality MP3 stereo soundtrack that mostly come with DivX/XviD rips, unless it's AC3 (which is quite common with DivX/XviD rips), puts, in most cases, very little burden on the CPU (TCPMP has very processor-effective decoders – see for example my article on generic Pocket PC sound recording at http://www.winmobiletech.com/mp3 ), compared to high-resolution video, so, we don't downsample the audio here. Let me know if you need downsampling, and then, I also elaborate on that subject.)

Now, just start the conversion by going to File/Save As....

It's this easy.

Note that you may also want to make quick tests, especially if you want to see the quality of the output. To do this, you don't need to convert the entire video: you can easily tell VirtualDub what part of the source video to convert. To do this, just press the Home button at the starting position. After you've set the starting position, move the slider at the bottom to the right and, when you're at the end position of the block you'd like to encode, press the End button. (These two keys are both above the cursor block on standard PC keyboards and their functionality can also be accessed via Edit/Set selection start and Edit/Set selection end.) Now, if you choose File/Save As..., only the selected section will be encoded; this way, getting the best results will be made much faster.

Please also note that, if you get the previous DivX version, 5.x, it still had a free encoder (as opposed to the commercial-only in this version). Using it is pretty much the same as with the current, 6.0 version. (Much as the page at http://www.divx-digest.com/software/divxcodec5.html says the standard version is only capable of playback, I think it's also able of encoding. I haven't tested it myself; previous Standard versions of the DivX codec have always been able to do so.) Alternatively, use the XviD codec.

Feedback is welcome.

Links to other sources of information:

http://tcpmp.corecodec.org/about - the two tutorials and the three application links on the TCPMP page

http://www.pocketmatrix.com/guides/dvd/ - the PocketMatrix guide of ripping DVD's. If you "only" want to resize DivX/XviD input, you won't need it.

http://discussion.brighthand.com/showthread.php?s=&threadid=119114 – a new, hx4700 (VGA)-related thread with some links to commercial, mostly DVD-converter apps

http://www.pocketpcthoughts.com/forums/viewtopic.php?t=39743 – a review of Pocket DVD Wizard – you may find it useful if you don't want to "manually" convert your files and/or want to convert your DVD's

http://www.pocketpcthoughts.com/forums/viewtopic.php?t=40413 - Getting TV shows on PPC easily

http://forum.doom9.org/forumdisplay.php?s=&forumid=52 – the home of XviD-related discussion

http://www.pocketpcmag.com/forum/topic.asp?TOPIC_ID=15632 – generic questions on Pocket PC videos

etc. You may also want to pass 'virtualdub', 'divx' to the search engines of Pocket PC sites. (And, naturally, 'dvd', if you want to know more about converting DVD's to the Pocket PC.)

To look for more info (you will really want to do this, especially if you want to encode DVD's instead of plain AVI files), direct links to the search pages of major PPC boards:

PPCT (http://www.pocketpcthoughts.com/forums/search.php)
Pocket PC Mag (http://pocketpcmag.com/forum/search.asp)
FirstLoox (http://www.firstloox.org//forums/search.php?)
BrightHand (http://discussion.brighthand.com/search.php) (note that the search engine, as of Oct-16-2005, won't likely to give you results between 2002 and 2005!)
AximSite (http://www.aximsite.com/boards/search.php?)
iPAQ HQ (http://www.ipaqhq.com/forums/search.php?)

EDIT at 8:50AM CET, 16-Oct-2005: added XviD, PDE and search sections, corrected a mistake and cleaned up the text a bit