# Handbrake aspect ratio problem



## jasonrn (Feb 3, 2007)

Hi all. I am still trying to get my Tivo shows on my ipod classic correctly and am having an issue with the aspect ratio. I send the tivo file through Video redo, then use handbrake to convert the file. The aspect ratio is messed up. Everyone looks too tall. I have tried messing with different settings and copping values, nothing I've done results in a file that looks correct on my Ipod Classic. I am using Handbrake 0.93. I don't know if it is because many tv shows now are letterboxed? I don't remember this being a problem before. It has been a while since I've tried this though.

Any thoughts?


----------



## jasonrn (Feb 3, 2007)

I tried Handbrake 0.92 and this fixed the problem. The two versions report the aspect ratios differently.


----------



## dlfl (Jul 6, 2006)

jasonrn said:


> Hi all. I am still trying to get my Tivo shows on my ipod classic correctly and am having an issue with the aspect ratio. I send the tivo file through Video redo, then use handbrake to convert the file. The aspect ratio is messed up. Everyone looks too tall. I have tried messing with different settings and copping values, nothing I've done results in a file that looks correct on my Ipod Classic. I am using Handbrake 0.93. I don't know if it is because many tv shows now are letterboxed? I don't remember this being a problem before. It has been a while since I've tried this though.
> 
> Any thoughts?


Yes, MANY thoughts, and what a coincidence! I was just about to post on this topic in the TVAP thread (see signature).

HB 0.9.3 changed the handling of cropping and aspect ratio. For the gory details of my experience see this thread on the HB forum.

The bottom line is HB computes a pixel aspect ratio (PAR) from the mpeg2 header info that is technically correct but doesn't make any sense for Tivo files. I guess the real culprit is the way TiVo constructs the file.

My Tivo mpeg's are either 352x480 or 480x480 (i.e. SD video) but many are letterboxed and I want to encode a cropped version, e.g., a height of 360 for 16:9 or 272 for 2.35:1. I like a width of 640, so all I needed was

-w 640 -Y 480

and HB 0.9.2 would autocrop and produce the desired encoded dimensions with a PAR of 1:1. pyTivo will pad these as needed and play them fine (letterboxed) on my SD TV. And they play fine in any software player such as WMP or VLC.

This doesn't work in HB 0.9.3 and I haven't found any way to make it automatically do what was so easy to do before. You can force what you want by using

-w 640 -l 360 -P16:1:1 --autocrop 60:60:0:0

(example for 16:9 letterboxed input), but this isn't automatic -- you have to know the amount of cropping needed beforehand. This is a shame because HB has a very good autocrop algorithm that it runs every time you load a file - the results are in the analysis activity window. (If you are processing each file manually using the GUI, you can get the autocrop numbers from there and use them to modify the command line in the Query window per the above example.)

For my purposes, I want this automated in a TVAP post processing batch file that calls the command-line version of HB. I believe I have a solution. You can make HB spit out the analysis information by calling it with arguments:

-i <input.mpg> -t0 -v

So in my batch file I redirect this output into a text file. Then I wrote a little command line utility that parses this file to get the vertical autocrop numbers and outputs them in two tiny text files. The batch file runs this utility and then reads in the numbers from the two tiny text files and uses them to set the HB command line arguments for the encode. All automatic and split-second fast.

I can put an example batch file and the parsing program on a free download site if anyone is interested.


----------



## jasonrn (Feb 3, 2007)

Yes. I notice that version 0.93 reads the aspect ratio as "0.89" whereas 0.92 reads it as "1.33"

Using 0.92 works for my tivo files. I just manually crop them.

Jay


----------



## CanMan00 (Feb 17, 2008)

dlfl said:


> I can put an example batch file and the parsing program on a free download site if anyone is interested.


I would love to see exactly how you're doing that. I'm trying to use HandBrakeCLI to batch compress my edited videos with a PowerShell script so I can watch them on a PS3. 480 SD videos work but 1080 videos don't, so I would like to get HandBrake to use different compression settings on them in one giant batch rather than separating the videos myself.

For some reason, any 1080 videos from my Tivo that get run through HandBrake won't play on the PS3. It'll work if I use Ripbot264, but I can't setup an automatic batch with that program (you have to queue them yourself using the GUI). I can't figure out what x264 commands Ripbot264's presets are using exactly, so I can't duplicate them for the HandBrakeCLI.

If anyone out there has been able to get a 1080 video recorded from a TivoHD to compress with HandBrake and then playback on a PS3, please share your x264 settings...


----------



## dlfl (Jul 6, 2006)

CanMan00,

I assume you've been using the HB 0.9.3 and its PS3 preset, correct?

Have you tried the HB forum? (Be sure to post your entire encode log or you will get a cool reception.) Will your 1080 encodes play in software players like VLC Player? What do MediaInfo or mp4box say about the encodes?

I can put my stuff on a free download site, probably later today, although I'm not sure it will help your problems with 1080 encodes. I'm encoding just 480 SD videos.


----------



## dlfl (Jul 6, 2006)

> ... a TVAP post processing batch file that calls the command-line version of HB. I believe I have a solution. You can make HB spit out the analysis information by calling it with arguments:
> 
> -i <input.mpg> -t0 -v
> 
> So in my batch file I redirect this output into a text file. Then I wrote a little command line utility that parses this file to get the vertical autocrop numbers and outputs them in two tiny text files. The batch file runs this utility and then reads in the numbers from the two tiny text files and uses them to set the HB command line arguments for the encode. All automatic and split-second fast.


You can download all the stuff to do this from this link.

The C# source code for the parsing program, ParseAutoCrop.exe, is also included, in program cs. I'm sure there are more elegant ways to do this all in PowerShell, VBScript or Python without requiring the C# program.


----------



## CanMan00 (Feb 17, 2008)

dlfl said:


> The C# source code for the parsing program, ParseAutoCrop.exe, is also included, in program cs. I'm sure there are more elegant ways to do this all in PowerShell, VBScript or Python without requiring the C# program.


Thanks! Looks like that will help me sort out the logic of what I want to do with my own little PowerShell script!

Yes, I've been using HB 0.9.3 with the PS3 preset. I'll sort out the details and do my best to ask the folks on the HB forum in the next day or two. I'll spare the details here, but the gist of the problem is that the preset works with SD videos, but typically doesn't cut down on the file size very much. HD videos shrink quite a but, but then the PS3 won't read them. VLC on my computer can play the files just fine, but the PS3 says the HD videos "not in a compatible format."

I think I'll need different x264 settings for the SD videos and HD videos to get an optimal file size/image quality ratio for each while making sure they'll play on the PS3.

Thanks for your help!


----------



## dlfl (Jul 6, 2006)

Here's a link to a recent thread on the HB forum on these topics.

The bottom line is if you want a WxH encoding you have to specify both dimensions with -w and -l or HB will do its funny aspect ratio business on mpeg2's from .TiVo files.

I also wanted to autocrop files that were letterboxed. HB has a good autocrop algorithm that runs during its analysis run (-t0 option). The purpose of my batch system is to use the analysis phase just to get the vertical autocrop numbers, then force the -w, -l and crop arguments during the encode.

It looks like the -P argument in my batch encode is ignored due to a bug that jbrjake admits to, which is good because if he hadn't put in that bug, the -l argument would have been ignored instead, and I would have lost control of the encoded dimensions, or at least one of them.

Keep us posted on what you come up with!


----------



## AudioNutz (Nov 10, 2008)

I have a question for those that are using "HandBrake" to encode. What is the advantage over ffmpeg? I've been fooling around with it and I've seen the issues with the video being too tall when using the "Out of the Box" encoding profile for "iPod".

I've discovered the way to correct this is by using the "-l 240 -w 320" argument to coerce the video to the correct size/aspect ratio, BUT... If I use that coersion, it doubles the encode time.

I can encode a show in half the time it took to record the show on TiVo with ffmpeg. For example a 30min show takes 15min to encode for iPod. With Handbrake, a 30min show takes 26-30min to encode, even after the commercials have been cut.


----------



## txporter (Sep 18, 2006)

I use it only to convert DVDs to video with hardsubs. I do not ever need to crop video or change resolutions, so I haven't had to deal with that. It is by far the easiest program to use to mass convert DVDs to h.264 with hardsubs. For converting Tivo video to h.264, I have been using XVID4PSP because I can burn in CC with it. If I had an easy way to burn-in CC with ffmpeg, I would be happy to use it. 

Jason


----------

