*

Welcome, Guest. Please login or register.

Get your own OLPC - Buy an XO laptop on eBay!
Pages: [1]
Print
Author Topic: Best XO Video Encoding Parameters  (Read 6328 times)

Best XO Video Encoding Parameters

Mizutsuki
Commenter

Posts: 19


May 29, 2008, 09:51:43 AM

Hello,
I'm trying to come up with the perfect video encoding settings for video playback with the XO.  I've got a large DVD collection, and I want to create a script that I can run with input of just the DVD track(s) I want ripped and then have it go through and make a very standard video using mencoder.
So far here are my thoughts:
MP3(128 k/sec) LAME + XviD(1024 k/sec) at 600x450(600x348), two passes
My knowledge of video encoding is fair, but not excellent, so I wanted to come here and see what people had to say.  Should I use a different encoder?  Should I use a different audio codec?  Is there anything y'all think I should be careful of in encoding the video in terms of overworking the processor.  Having very high quality smooth video playback is the goal, so I'm looking for the best quality that the laptop is sure to run at full speed.
BTW, about the resolution, my thought was that there's that weird color swizzling thing that I don't really get, but my understanding is that I'm only guaranteed to have each color in 1/4 of the pixels, so if the video always comes onto the screen doubled in size from the content, then every pixel's color is guaranteed to be expressed.  Do I have a misunderstanding?
Thanks for your input.
Logged

#1 Re: Best XO Video Encoding Parameters

StewieGriffin
Contributor
*
Posts: 80


May 29, 2008, 12:24:24 PM

That sounds about right.   You should get excellent results.  To limit skipping, keep your res around 640x360 for 16:9 or 512x384 for 4:3.
Logged

#2 Re: Best XO Video Encoding Parameters

baroing
Commenter

Posts: 27



May 29, 2008, 12:36:44 PM

I found I had to scale my .avi videos to ~500 X 300 to get them to play in VLC player on my XO without skipping/dropping frames.

Being able to batch process video files would be handy!  I would love to see your mencoder script if you are willing to share it...
Logged

#3 Re: Best XO Video Encoding Parameters

Mizutsuki
Commenter

Posts: 19


May 29, 2008, 02:06:43 PM

I definitely intend on watching them with mplayer, so I think that'll give me a leg up in terms of performance.  About the resolution: I was hoping to get some feedback specifically about the color swizzle effect and if my supposition is right that a multiply by 2 (600x450) would give better color than the multiply by 2.34... that would be the result of using 512x384.  I've read the discussions about it, but I'm not sure I really get it.
Thanks
Logged

#4 Re: Best XO Video Encoding Parameters

teapot
OLPC News Forum Expert
****
Posts: 662



WWW
May 29, 2008, 03:17:09 PM

With mplayer it helps to have .mplayer/config with:

ao=alsa
framedrop=1
lavdopts=skiploopfilter=all
lavdopts=fast=1
Logged

#5 Re: Best XO Video Encoding Parameters

StewieGriffin
Contributor
*
Posts: 80


May 30, 2008, 08:11:43 AM

I've found that the playback ability highly varies depending on which OS you are using...

If you are using the original Fedora + XFCE, you need to use the recompiled mplayer for the XO in fullscreen only - VLC will be too slow.

If you use the Ubuntu 7.10 build plus backported video driver, you can run mplayer in a window, but VLC is still too slow.

If you use Teapot's Ubuntu 8.10, then you will have perfect accelerated video - VLC runs fullspeed, and you can turn on all compositing effects too, like transparent backgrounds and window shadows!
Logged

#6 Re: Best XO Video Encoding Parameters

Mizutsuki
Commenter

Posts: 19


May 30, 2008, 01:35:06 PM

Ok, so I think I'm going to go with xvidenc, which is a bit more thinking per disk than I originally intended, but this is just such a stellar script.  When I went to encode, though, it told me that the best quality video has a resolution where width and height are both divisible by 16.  I did some searching, and I think that's right.  So I couldn't figure out how to figure out what resolutions would work on my own, so I just wrote a small c application that told me.  There are only 9 possible 4:3 resolutions below 720x480 (the distribution resolution.)  They are as follows:
64x48
128x96
192x144
256x192
320x240
384x288
448x336
512x384
576x432
Obviously nothing less than 320x240 will do, so there are 5 resolutions to choose from.  Never mind the swizzle effect, I'm going with 576x432.  I'm encoding my first test movie right now.  I'll let you know how it goes.
Oh, also, the situation is considerably worse for 16:9:
256x144
512x288
So... 512x288 it is!  Any thoughts?
Thanks.
Logged

#7 Re: Best XO Video Encoding Parameters

Mizutsuki
Commenter

Posts: 19


June 01, 2008, 02:23:18 PM

Ok, turns out I suck at shell scripting.  I fell in love with xvidenc, and I'm using that.  I come up with a different resolution for every video I encode, and because I'm better at C than at sh, I wrote a small, only partially functional system of figuring out what viable resolutions exist:
Code:
#include<stdio.h>
#include<math.h>
#include<string.h>

int main() {
/*printf("%f\n", 640.0F/480.0F);*/
/*printf("%f\n", 672.0F/448.0F);*/
/*printf("%f\n", fabs(672.0F/448.0F - 640.0F/480.0F));*/
char originalRes[128];
float precision;

printf("Enter the videos original resolution/aspect-ratio (default 4:3): ");
if(scanf("%s", originalRes) == EOF)
strcpy(originalRes, "4:3");
int ox = atoi(strtok(originalRes, ":x"));
int oy = atoi(strtok(NULL, ":x"));

printf("Enter the tolerance (default 0.01): ");
if(scanf("%f", &precision) == EOF)
precision = 0.01F;

int x, y = 1;
for(x = 1; x <= 720; x++) {
for(y = 1; y <= 480; y++) {
if(
x % 16 == 0 &&
y % 16 == 0 &&
(fabs((float)x/(float)y - ((float)ox/(float)oy)) < precision)
) {
printf("%dx%d\n", x, y);
}
}
}
return 0;
}

Hope that helps anyone.
BTW, using 2pass very high quality, doing a crop and a 3:2 pulldown in xvidenc, and accepting every default in terms of audio.
Logged

#8 Re: Best XO Video Encoding Parameters

tangomike
Contributor
*
Posts: 77


June 03, 2008, 07:33:58 AM

I have a 3" pocket viewer from China (like an ipod, but $45 delivered to my door). I use HandBrake on a laptop to rip dvd's to SD cards to watch them on it. It uses 3gp (cell phone video codec). Here's my Handbrake command line:

HandBrakeCLI -i /dev/scd0 -t 1 -w 360 -l 240 \
-o /media/sdc1/VIDEO/some-name.mp4

(the backslash \ indicates that this should all be on one line)


Note that t 1 is for title, if handbrake can't figure it out. Also 320 might be better than 360. /dev/scd0 is my dvd drive, and /media/sdc1 is my SD card mount point.

I tried these on my XO, using VLC, and they play near full screen with stereo sound, in Ubuntu, with no dropped frames.
Logged

#9 Re: Best XO Video Encoding Parameters

Mizutsuki
Commenter

Posts: 19


July 01, 2008, 09:20:05 AM

I know it's been a long time and this will probably be considered a resurrection, but I've come up with my results and I wanted to share them with y'all.
As you can probably tell from my previous C application, I'm not too handy with the programming.  But that program, and the script I'm about to paste in, get the job done.  This is my process:
I create a directory on my 500 gig external with the name of the movie I'm going to rip.  Then I enter it and type
Code:
vobcopy -m
  then I start making modifications to the script.
My base script looks like this,
Code:
#!/bin/bash

TITLE="Movie Title"
IN_FILE="dvd://1 -dvd-device MOVIE_TITLE/"
OUT_FILE="movieTitle.mkv"
CROP="698:480:6:0"
SCALE="400:272"
#VF_FRAMECONVERT=""
VF_FRAMECONVERT="pullup,"
#VF_FRAMECONVERT="yadif,"
FPS="24000/1001"
#FPS="30000/1001"
BITRATE=800
AID=128
AUDIO_DELAY=200

# Video
mencoder ${IN_FILE} -o /dev/null -ofps ${FPS} -vf ${VF_FRAMECONVERT}crop=${CROP},softskip,scale=${SCALE},harddup -nosound -of rawvideo -ovc x264 -x264encopts pass=1:bitrate=${BITRATE}:turbo=2:me=umh:me_range=24:nodct_decimate:nointerlaced:8x8dct:nofast_pskip:trellis=1:partitions=none:mixed_refs:bime:keyint=240:keyint_min=24:frameref=1:bframes=4:b_adapt:b_pyramid:weight_b:direct_pred=auto:subq=1:brdo:chroma_me:nocabac:nodeblock:nossim:nopsnr:threads=auto

mencoder ${IN_FILE} -o movie.264 -ofps ${FPS} -vf ${VF_FRAMECONVERT}crop=${CROP},softskip,scale=${SCALE},harddup -nosound -of rawvideo -ovc x264 -x264encopts pass=2:bitrate=${BITRATE}:me=umh:me_range=24:nodct_decimate:nointerlaced:8x8dct:nofast_pskip:trellis=1:partitions=none:mixed_refs:keyint=240:keyint_min=24:frameref=4:bframes=4:bime:b_adapt:b_pyramid:weight_b:direct_pred=auto:subq=6:brdo:chroma_me:nocabac:nodeblock:nossim:nopsnr:threads=auto

# Audio
mplayer ${IN_FILE} -aid ${AID} -ao pcm:fast:waveheader:file=audio${AID}.wav -vc null -vo null
oggenc audio${AID}.wav

# Container
mkvmerge --title "${TITLE}" -o ${OUT_FILE} --default-duration 0:${FPS}fps movie.264 -y 0:${AUDIO_DELAY}  audio${AID}.ogg
First I change the title, the name of the vobdirectory and the name of the outfile to the name of the actual movie I'm ripping (oh, and I use lsdvd and change the chapter of the dvd to the correct one.)  I rip first instead of just going directly from the disk because it allows me to use the drive while I'm doing encodes, plus it allows me to quickly rip the DVD and then put it back on the shelf, without having to keep a box out for hours.
Next, I type
Code:
mplayer dvd://1 -dvd-device MOVIE_TITLE/ -vf cropdetect
and I consider the output by using
Code:
mplayer dvd://1 -dvd-device MOVIE_TITLE/ -vf rectangle=698:480:6:0
replacing the rectangle values with the ones suggested by cropdetect.  I almost always find them to be too conservative, so I tweak them until I get a reasonable amount of crop.  Note here that I am not constrained to mod 16 resolutions because I have to resize.  I plug the crop value into the script and then I run the C application I posted earlier.  Maybe someone can make that into a fully functioning sh script, but I don't know how.  Anyway, I give it .02 for tolerance and if there's a value within 15,000 pixels of 100,000 then I use than, otherwise I just keep upping the tolerance until I do.  This is probably the number 1 factor I've found in my tests: lower resolution makes almost any configuration playable.  So my key to success here has been keeping the resolution to 100,000 pixels.
Next is the most complicated part: taking care of framerate.  I basically follow this guide: http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-telecine.html
And then I just comment and uncomment until it makes sense.  Sorry I can't provide a simple guide to this.
I generally leave everything else the same, though you might have to tweak the audio track, and I find that I can't tell when the bitrate is any higher so I've just consistently used 800.
At this point, it's pretty well ready.  Enter the directory with the ripped video and execute the script.
Now, this is the most irritating part.  For whatever reason, no matter what I do, the movies I encode always end up with AV sync problems that aren't performance related.  Generally the audio is 200 millies shy of the video so I've just introduced an automatic delay, and that works for most movies.  However, many movies require some guess and check work.  When it doesn't work, I use the following command repeatedly until I get the right sync:
Code:
mkvmerge -o movieTitle.resync.mkv -y 2:xxx movieTitle.mkv
continuously replacing "xxx" with 3-4 digit numbers until the video looks right, checking with mplayer every time.  If someone knows a better way to do this, I'm all ears (btw, I tried mplayers + and - keys for AV sync, but they only work up to about 400 millies, and then they start ignoring the delay for whatever reason, so I had to go to guess and check.)

So, I hope that helps someone.  If you have any questions I'd be happy to answer.
Logged

#10 Re: Best XO Video Encoding Parameters

goney3
Master Contributor
***
Posts: 363


G1G1D48


September 25, 2008, 05:11:40 AM

Handbrake v0.9.1 on my Mac works pretty great encoding useing the "iPod Low-Rez" preset.

Rips DVD's in about 1 hour on a old Mac-mini... file size around 680+ Mb when finished.
Plays fine under VLC Smiley

v0.9.2 is out now and is supposed to be a bit faster.
Logged

Pages: [1]
Print
Jump to:  

Members
Total Members: 2406
Latest: sembik
Stats
Total Posts: 31943
Total Topics: 3843
Online Today: 24
Online Ever: 238
(April 18, 2011, 09:48:50 PM)
Users Online
Users: 0
Guests: 20
Total: 20