SMOR.tv  > Blog  > Android HTC Hero/Eris x264 (h.264) video encoding with HandBrake

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

11.21.2009 Bookmark and Share

htc_hero_front

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!

Sam Morris Blog

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

  1. John Nunley
    December 5th, 2009 at 09:49 | #1

    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.

  2. December 5th, 2009 at 12:00 | #2

    @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.

  3. Chris S
    December 24th, 2009 at 11:12 | #3

    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!

  4. December 24th, 2009 at 13:45 | #4

    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.

  5. Ben
    January 9th, 2010 at 16:24 | #5

    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,

  6. January 9th, 2010 at 18:17 | #6

    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.

  1. January 13th, 2010 at 16:18 | #1