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

  7. Just Vervaart
    February 18th, 2010 at 09:38 | #7

    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

    • February 19th, 2010 at 01:23 | #8

      I'll be giving that a try next time I'm converting a video.
      Thanks for the tip

  8. March 9th, 2010 at 17:12 | #9

    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.

    • March 10th, 2010 at 07:36 | #10

      Thanks for the tip Stephen, I'll have to check that out.

  9. Matt
    March 24th, 2010 at 21:53 | #11

    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. :)

    • March 25th, 2010 at 04:37 | #12

      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.

  10. Logicc87
    April 22nd, 2010 at 16:38 | #13

    Hi morris, thank you for the tutorial one question the keeping the aspect ratio should it be checked or not?

    • April 23rd, 2010 at 07:08 | #14

      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.

      • Logicc87
        April 23rd, 2010 at 15:15 | #15

        yeah, i just tried the auto crop and it worked very good, thanks for your fast response.

  11. dvd creator
    May 28th, 2010 at 01:32 | #16

    Thanks for the writing this! I’m new at this game so am trying to catch up.

  12. May 28th, 2010 at 16:39 | #17

    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.

    • May 29th, 2010 at 13:44 | #18

      Thanks for the comment Erik, glad to hear the settings worked for you.

  13. logicc87
    June 14th, 2010 at 05:48 | #19

    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.

    • June 14th, 2010 at 18:27 | #20

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

      • logicc87
        June 15th, 2010 at 21:01 | #21

        ok thank you, one silly question, how will it benefit me to increase the bitrate? meaning what good does it do to the video?

        • June 16th, 2010 at 23:16 | #22

          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.

  14. logicc87
    June 17th, 2010 at 22:15 | #23

    Thank you.

  15. bjbilbo
    July 8th, 2010 at 11:00 | #24

    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

  1. January 13th, 2010 at 16:18 | #1
  2. April 5th, 2010 at 04:55 | #2