Log in

View Full Version : High Quality Iphone 3G x.264 Settings


Bathrone
11th September 2008, 01:32
Gday folks :) Im trying to come up with a high quality Iphone 3G profile, without regard for any other apple devices, taking the most the Iphone can handle.

I see the Iphone 3G is supposed to support:

Baseline Profile Level 3.0
10 MBit/s, 10 MBits buffer
720x480 at 30fps (6 stored)
720x576 at 25fps (5 stored)
Restrictions:
No B-slices
No CABAC
No pixel aspect ratio support
No interlaced
For iTunes sync, average bitrate over whole file must be < 5 MBit/s (iPod classic/nano, not touch/iphone

I have been studying the parameters that x.264 allows. As a test piece Im using the original pngs from Big Buck Bunny - Apricot movie. I have come up with the following:

mencoder mf://*.png -mf w=1920:h=1080:fps=24:type=png \
-vf scale=720:400,harddup -of rawvideo -ovc x264 -o test1.264 -ofps 24 \
-x264encopts level=30:no-cabac:bframes=0:trellis=0:ref=5:mixed-refs:no-fast-pskip:bime:vbv-maxrate=10000:\
vbv-bufsize=10000:me=umh:merange=24:subme=7:partitions=all:direct=auto:threads=auto:deblock:keyint=240:bitrate=5000:\
pass=1 -nosound -endpos 100

mencoder mf://*.png -mf w=1920:h=1080:fps=24:type=png \
-vf scale=720:400,harddup -of rawvideo -ovc x264 -o test1.264 -ofps 24 \
-x264encopts level=30:no-cabac:bframes=0:trellis=0:ref=5:mixed-refs:no-fast-pskip:bime:vbv-maxrate=10000:\
vbv-bufsize=10000:me=umh:merange=24:subme=7:partitions=all:direct=auto:threads=auto:deblock:keyint=240:bitrate=5000:\
pass=2 -nosound -endpos 100

How might I improve this? I am not using the exhaustive ME method due to the time it takes, but in general I dont care about encoding time for any sane level of time it may take.

Sagekilla
11th September 2008, 02:21
Try enabling trellis = 2

Sharktooth
11th September 2008, 02:22
bime option and maybe trellis 1 (fast) or 2 (slow).

Bathrone
11th September 2008, 03:38
Many thanks gents :) Ive added bime and am looking into trellis. I also made the resolution div by 16 to 720:400 to keep x264 happy.

PS Sharktooth : Your enthusiasm for Linux and other reasons prompted me to give it a go. Ive since shifted to this platform and contributing to my chosen distro :) Though I sorely miss GPU accelerated decoding of AVC.

Sagekilla
11th September 2008, 03:51
Ah... 700 isn't mod16 -- It's actually only mod4. What you're looking for is 704x400 probably --- that's mod 16 in both directions. It's also closer to 16:9 than 700x400, just slightly so but it is :)

Bathrone
11th September 2008, 04:07
Sorry that was a typo : meant 720, Ill edit

Bathrone
11th September 2008, 06:08
I feel stupid foe asking this but better safe than sorry. So apparently the iphone can do 10 Mb/s.

I see x.264 parameters work in Kb/s

So, 10Mb/s = 10240 Kb/s as the bitrate?

F J Walter
11th September 2008, 07:05
I feel stupid foe asking this but better safe than sorry. So apparently the iphone can do 10 Mb/s.

I see x.264 parameters work in Kb/s

So, 10Mb/s = 10240 Kb/s as the bitrate?

In my experience, bandwidth in megabits/kilobits is usually expressed as 1,000,000/1,000 bits.

10 Mbit/s would be 10,000 Kbit/s and 10,000,000 bit/s.

This is the case in ffmpeg and (I believe) x264 too. Some people do, however, express bandwidth in megaBYTES (not megabits) per second, in which case they presumably use base 1024.

Inventive Software
11th September 2008, 11:17
Don't use the average bitrate as 10 Mbit, just use it as the max bitrate with the VBV setting.

Sharktooth
11th September 2008, 12:59
PS Sharktooth : Your enthusiasm for Linux and other reasons prompted me to give it a go. Ive since shifted to this platform and contributing to my chosen distro :) Though I sorely miss GPU accelerated decoding of AVC.
Yup, i miss GPU decoding but as all linux users know, some hardware related features may require some time to be ported to linux...
about to the iphone, i forgot to tell you to set the VBV maxrate option to 10000 and VBV buffer to the same value. that will ensure the stream wont exceed the specs for bitrate limits.

Bathrone
13th September 2008, 09:26
Thanks guys Ive added those two params

Q: Though given Ive specified compliance to level 3.0 wouldnt the code restrict it to 10Mb/s automatically?

Comatose
14th September 2008, 08:02
Uh, well, I'm not sure, but I vaguely recall a dev saying x264 doesn't care about the levels when it encodes. It's just a number.
So if you need that restriction in place, you'd have to put it there yourself.