Android HTC Hero/Eris x264 (h.264) video encoding with HandBrake

Note: This article focuses on the HTC Hero, but should work just as well for the HTC Eris.
The HTC Hero can play a variety of video codecs and formats, but there’s one far better than the rest. That would be the x264 codec, which is the open-source version of the h.264 codec. According to the HTC Hero’s specs it’s able to play x264 mpeg4s (.mp4), so I wasn’t going to settle for anything less. Finding the correct settings turned out to be a close to impossible task, but after some testing I figured it out. My goal was to create a profile in handbrake that could output a video, which would play perfectly smooth, have good quality, and wouldn’t take up too much space.
As for those who don’t know what handbrake is…it’s a open-source application used for encoding and transcoding video into other formats. In my case, going from a DVD to a format that would work on my HTC Hero. handbrake is free, simple, and it isn’t trashy like so many other video converters. It also runs on PC, Mac, and Linux, so it should work on your machine. You can download handbrake from http://handbrake.fr.
Moving on, here’s the end results of my handbrake profile settings. (for creating my x264 HTC Hero videos)
Handbrake Profile Settings
Here’s the same results as above, but in a text based version:
Output Settings
- Format: MP4 File
- Large file size: unchecked
- Web optimized: unchecked
- iPod 5G support: unchecked
Picture Settings
Crop
- Crop: Custom
- Top: 0
- Right: 0
- bottom: 0
- left: 0
Size
- Width/Height: 480 x 272 (note – this is for widescreen videos, if your video isn’t widescreen 480 x 320 may work better)
- Anamorphic: None
Filters
- Detelecine: unchecked
- Decomb: unchecked
- Deinterlace: None
- Denoise: None
- Deblock: Off
Video
Video
- Video Codec: H.264 (x264)
- Framerate (FPS): 24 (note – 15 works fine for most videos too, try both and see which you prefer)
Advanced Encoding Settings
- Grayscale Encoding: unchecked
- 2-Pass Encoding: checked
- Turbo first Pass: checked
Quality
- Target Size (MB): leave blank
- Avg Bitrate (kbps): 384 (note – feel free to play with this setting, but as a warning the hero sees my videos at 536kbps when I specify 384kbps in handbrake.)
- Constant Quality: 0%
Audio & Subtitles
Audio Tracks
- 1: Automatic (or choose english)
- Audio Codec: AAC
- Mixdown: Stereo (if you’re going to be using the phone’s speaker you can choose mono)
- Samplerate (kHz): 44.1
- Bitrate (Kbps): 160
- DRC: 1
Subtitles
- Subtitles: None
Chapters
Chapter Markers
- Create chapter markers: unchecked
Advanced
Advanced H.264 Options
- Reference Frames: 2
- Mixed References: unchecked
- B-Frames: 0
- Motion Estimation Method: Uneven Multi-Hexagon
- Motion Estimation Range: Default (16)
- Subpixel Motion Estimation: Default (16)
- Analysis: Default
- 8×8 DCT: unchecked
- Deblocking: Default (0) x Default (0)
- No Fast-P-Skip: unchecked
- No DCT-Decimate: unchecked
- CABAC Entropy Coding: unchecked (note – having this turned on will result in solid green screen when trying to playback video)
Query Editor
Query Editor
- Click the Generate Query button and your command line should look simular to the following (except the file names and paths will be different).
-i “D:\VIDEO_TS” -t 1 -c 1-21 -o “B:\Hero Video\super_troopers.mp4″ -f mp4 -w 480 -l 272 –crop 0:0:0:0 -e x264 -b 384 -2 -T -r 24 -a 1 -E faac -B 160 -R 44.1 -6 stereo -D 1 -x ref=2:me=umh:cabac=0:bframes=0 -C 8 -v
This profile was created on version 0.93 of handbrake, I plan on doing some more in depth tests when I have the time. If anyone discovers improvements for these settings please let me know!
I had used the default Iphone Ipod Touch settings prior to the 64 bit upgrade. After the upgrade I find my Droid Eris unable to play the default settings. I’ve been running the files through Double Twist to encrypt since but it takes a long time. I wish they hadn’t changed the default settings.
@John Nunley
I just upgraded as well and was unhappy about all my presets being lost. However, I was able to create a new Hero profile. Although a few of the options look different, I managed to use the same settings as before and my videos still work fine. Try using my settings above and it should play fine, or perhaps just compare the updated iPod Touch profile to what I use above.
Hi,
GREAT tutorial, I’ve been fighting with Adobe Media Encoder to get this result.
I am using HandBrake 9.4 and the interface was a little different. I was able to find all the settings you have up above, and they did work with an exception – I had to set the height to 0 (Max Width) with the width set to 480. Otherwise I was getting a black screen with audio. Also, I’m not sure why it’s different now… when I started I was getting .mp4 files, which also didn’t work, now I am getting m4v’s which seem to work fine on my Telus Hero.
After starting over quite a few times I found it easiest to click iPhone & iPod Touch and then change the settings to match what you have above. Starting from scratch didn’t work for me at all.
Thanks so much for this!
Thanks Chris, I’m glad to hear you found it helpful. I also started with Adobe Media Encoder, but gave up after some trial and error. Handbrake seems to be much more in touch with the specific parameters of the x264 codec, than Media Encoder.
Thanks Sam, great post.
I'm using avidemux instead of handbrake, and managed a rough translation from your settings, which resulted in the first video that's played properly on my hero
In avidemux, you need:
- video: x264
config: uncheck Motion & Misc -> CABAC (this was the key!)
filters: mplayer resize (480×320/272), resample fps (24.000)
- audio: AAC, defaults
- format: MP4 (and my hero seems to need a .mp4 file extension too)
That's it
Unticking CABAC makes the difference between a black screen and having a picture.
Cheers,
I'm glad it was helpful Ben, I had the same results with CABAC for other applications as well. Various settings I tested didn't have a significant effect, but CABAC was a guaranteed way to get no video playback.
When encoding 16:9 content (ratio 1.81) to the Hero (ratio 1.5) an crop of 24 pixels left and 24 pixels right gives you a nice fullscreen video
I'll be giving that a try next time I'm converting a video.
Thanks for the tip
This was SO helpful! Thank you for taking the time to mess with the settings and come up with something that works. My initial tests with this on the OSX side of things have worked perfectly. I’m actually syncing video created using this method through an itunes playlist using Salling Media Sync. Check it out if you want a seamless experience for your phone but don’t want to ditch iTunes.
Thanks for the tip Stephen, I'll have to check that out.
hi all thanks for the tips, I am just doing my first conversion and hope it works. Had a hell of a time getting a decent file size once converted as it seems my hero wont take a 500mb file or the converter I was using corrupted the file. Anywho thanks again as other peeps have said for taking the time.
Hi Matt,
Many movies will end up being over 500MB with similar settings to what I have above, depending of the length of the film of course. Your Hero should be able to store files (any type, not just movies) up to 4GB in file size. Files above 4GB will not work due to the limitations of the FAT32 file system, which most phone's memory cards use.
Hi morris, thank you for the tutorial one question the keeping the aspect ratio should it be checked or not?
Try both ways and see what you like better. It depends on each individual movie and your personal preference…
Many movies that are visually impressive (StarWars, Lord of The Rings, etc), will be at a 2.35:1 format. That means even if shown on a 16:9 screen, there will still be black bars.
Occasionally, I turn off the "keep aspect ratio" and intentionally skew my video (squishing it horizontally 10-20%). Otherwise, there will be such large bars that it's unwatchable on the small screen. The bars are meant to be there with a 2.35:1 format, but I find it too small to watch on the Hero's already small screen so I try to compensate for it.
yeah, i just tried the auto crop and it worked very good, thanks for your fast response.
Thanks for the writing this! I’m new at this game so am trying to catch up.
Thanks for all the info. I have an Eris and those settings work perfect. The only two things I changed were to keep the frame rate same as source and use mixed references.
Thanks for the comment Erik, glad to hear the settings worked for you.
Hi sam, do you happened to have these setting but for the EVO? i tried movies i encoded with for the Hero on the EVO and they worked fine, but i would like to know that correct setting for the pixels for the evo… 640 x 480? im not sure, If you know i would appreciated it.
I don't have an Evo to test with although I might soon. The width of the video should be 640px wide, so the full resolution of the screen is used. As for the height, it should be adjusted proportionality. An HD frame scaled down to 640px wide will have a height of 360px, so I would use that as a starting point. In addition, the Evo has a more powerful CPU than the Hero or Eris and you could probably turn up the Average Bitrate from 384 to higher number (assuming you're not concerned with file sizes getting larger).
ok thank you, one silly question, how will it benefit me to increase the bitrate? meaning what good does it do to the video?
The bitrate directly effects the quality of your video. The higher the bitrate value, the less the video will be compressed (resulting in higher quality video, but larger filesize). For example, the Blueray format maxes out at around 40,000kbps, which is responsible for it's amazing quality, but huge filesize. In comparison, a typical low quality video you'll find on YouTube may be around 400kbps.
Thank you.
i have an issue with getting my videos in 480 size the biggest it will let me adjust is 320 also gray pass encoding and 2 pass encoding it wont allow me to check and all my videos come out slow and squarely pixaletd im using handbrake 4.9 i believe