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

  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

    • HTC Wallpapers
      November 1st, 2010 at 20:22 | #9

      Thank you! =)

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

    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 | #11

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

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

    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 | #13

      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 | #14

    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 | #15

      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 | #16

        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 | #17

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

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

    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 | #19

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

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

    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 | #21

      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 | #22

        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 | #23

          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 | #24

    Thank you.

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

    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

    • July 31st, 2010 at 00:32 | #26

      Hi Bjbilbo,
      I have not experienced this before, but the only potential issue I can think of is the source video isn't being interpreted correctly by Handbrake, or the source file is too small. Try various other files and codecs and see if you can isolate the issue.

  16. logicc87
    July 30th, 2010 at 01:12 | #27

    Sam, me again lol, quick question, how would you increase the volume quality on a video by higher bitrate or just my messing around with the audio settings?

    • July 30th, 2010 at 17:55 | #28

      Hi Logicc87,
      The volume of the audio isn't connected to the bitrate. The bitrate will influence the overall size of an audio file, and quality of the sound. If you want to adjust the volume you'll need an application that can manipulate video. Applications like After Effects, or Final Cut will be able to do this, but are overkill.

      I don't know of a good program that can do this for video, but ideally it would be something with a queue for videos and compressor to change the amplitude of the audio. This would allow you to run a handful of videos through the application and all would end up with similar audio levels…If I find an application that can do what I'm describing, I'll post a link.

  17. logicc87
    August 4th, 2010 at 19:22 | #29

    Thank you for your reply, will you be posting a tutorial similar to this one for the Evo? i would like to know how to covert a HD video to try to watch it on the evo since its hd capable.

    • August 10th, 2010 at 20:28 | #30

      Hey Logic,

      I almost got an Evo, but then decided to wait until the next Sprint phone comes out around Oct. There's 2 changes you'll want to make for the Evo and any other new phones. The Evo's resolution is higher than the Hero (800×480 – WVGA), so you can adjust the size of your video accordingly. The second is the phone runs faster, so you can increase the bitrate, which effects quality and the phone won't lag. The only side effect of increasing quality is of course the filesize of the video will increase as well.

      So in conclusion…
      -Set the width of your video to the max width of the phone (800px for the Evo)
      -Increase the quality (bitrate) to take advantage of the phone's faster hardware (but loose to SD card space)

  18. Scott
    October 8th, 2010 at 10:44 | #31

    The volume in handbrake is controlled with the “DRC” slider in Handbrake under “Audio”. In the script, it’s the “-D 1″ setting, and it can be a value from 1-4.

    DVDs are set with the sound pretty quiet, so that when an explosion or something happens, it can be QUITE loud. That “Dynamic Range” is pretty wide, and DRC=Dynamic Range Compression.

    For a DVD source, I usually work with a value of 2.5 to raise the volume up a bit. If it’s an existing file that I’m transcoding via Handbrake, the volume is usually OK and I leave it at 1.

    BTW: instead of an average bitrate, I’ve usually be using a constant quality setting of about 59%.This gives you a varying file size, but it efficiently max a small file for letterbox movies and a larger file for full-screen.

    • October 11th, 2010 at 14:32 | #32

      Nice tips Scott, I was not aware Handbrake had compression settings built into it.

  19. December 16th, 2010 at 06:45 | #33

    You made several nice points there. I did a search on the theme and found mainly people will agree with your blog.

  20. James
    December 30th, 2010 at 17:49 | #34

    Outstanding! Profile saved and working with a Mac OS 10.6 x64 version of Handbrake 0.9.4.

    I've had an HTC G2 Touch (A Hero very lightly rebranded, Android 2.1) but have been dragging around an old Touch for viewing videos on longer journeys. Now my girlfriend has discovered Angry Birds, I don't have the Touch much any more. :-) Time to fill the SD with some nerdy videos (in my case Time Team — I don't seem to be able to get enough of that show)!

  21. Mike Kingscott
    January 11th, 2011 at 15:22 | #35

    Hey, just saying thanks for this post, works like a charm on Handbrake 0.9.5 :-)

  22. balu
    February 25th, 2011 at 13:51 | #36

    Thanks for this writing, it was an awesome help!
    In Handbrake 0.9.5 you also need to uncheck the "weighted P-frame" box to play it properly with hardware acceleration.

  1. No trackbacks yet.