PDA

View Full Version : Aspect ratio issue with re-encoded HD files


sploo
25th August 2008, 00:05
I've got a Hauppauge WinTV NOVA-HD-S2 card, and I've been using it to record BBC HD here in the UK.

The card came with CyberLink's PowerCinema 5, which is producing .mpg files (I understand these to be H264).

DGAVCIndex will happily load these files and produce a .dga. With Avisynth, I can now get the files into VirtualDub and re-encode them with DixV to much lower bitrates.

However, the original .mpg files have been 16:9, but the resulting .avi plays back as 4:3.

When selecting the compression type in VirtualDub (and therefore using the DivX options window) I've selected just about every combination of input and output ratios (square, 4:3, 16:9 etc.) but I just can't get it to produce an output .avi that will play at 16:9. I can use a VirtualDub resize filter to get a 1920x1080 output video, but that's not really the best solution.

Anyone know the way to make this work?

BTW Here's some extra info...

Here's what DGAVCIndex logs for one of the files (many lines removed for clarity):

Stream Type: Transport [188]
Profile: High
Level: 4
Frame Size: 1440x1080
SAR: 15:11
Display Size: 1963x1080
Frame Rate: 25.000000 fps
Colorimetry: BT.709* [2]
Frame Structure: MBAFF
Frame Type: I
Bitrate (Avg): 15.622
Audio Stream: 52: MPA L2 2ch 48 256

It seems to indicate that the original .mpg video is 4:3 resoluton (1440x1080) but Windows Media Player (presumably using the Cyberlink H264 codec) plays the file back with the correct aspect ratio (16:9).

If I transfer the original .mpg file to another machine (that doesn't have the Cyberlink driver, but had ffdshow installed a long time ago) it instead plays back as 4:3!

I'm guessing there's a setting in the file header telling the codec to set an aspect ratio, which is being lost/ignored by VirtualDub and is unknown to the ffdshow codec?

EDIT: Checking the DGAVCIndex manual (imagine that... someone reading a manual ;)) it indicates that the SAR field in the log is the "sample aspect ratio specified in the AVC stream.". This explains the "Frame size" and "Display size" values: 1440 * (15/11) = 1963. So, is it the SAR field that's being ignored by VirtualDub/ffdshow?

[P]ako
25th August 2008, 16:49
Why isn't resizing the best solution? If you don't like Vdub's resizing filters (I don't blame you if you do), use avisynth's internal filters, like lanczosresize (check the avisynth's wiki). Or, you could mux your avi into a mkv and flag it to display at 16:9.

SeeMoreDigital
25th August 2008, 18:46
According to DGindex's report, your streams are actually being captured as "transport streams" and not "program streams" as the .MPG file extension suggests.

As you mentioned, DGIndex has detected that your captured stream contains (SAR) aspect ratio signalling... So that's good.

Given that FFdshow's "H.264" filter can detect aspect ratio signalling when used in-conjunction with a software media player, I can only assume that VirtualDub does indeed ignore any form of aspect ratio signalling and displays everything in square pixels.... Leaving it up to the user to manually re-size.


Cheers

Gavino
25th August 2008, 20:06
Isn't it just a question of setting the display AR to 16:9 in the output codec configuration?

VDub will display assuming square pixels, but when you play the resulting file with a player that respects the AR setting, it will stretch it accordingly.

Or are you saying you've tried that and it doesn't work?

sploo
26th August 2008, 17:01
ako;1174908']Why isn't resizing the best solution?

I guess I generally prefer to do as little as possible to a vid clip. Resizing the video means more pixels for the new codec to deal with, so more data to compress. How damaging that would be in terms of reduced quality I don't know, but resizing the frames just feels like the wrong solution.

Good point about mkv and the aspect ratio though. I was playing using Windows Media Player (WMP), but I'd be quite happy to use another player. From what I've been, mplayer has the ability to be told the aspect to use for playback, so I'll probably try it in the next few days.


Given that FFdshow's "H.264" filter can detect aspect ratio signalling when used in-conjunction with a software media player, I can only assume that VirtualDub does indeed ignore any form of aspect ratio signalling and displays everything in square pixels.... Leaving it up to the user to manually re-size.

That's interesting - because it would surely indicate that playing back the original MPG file on my PC with the ffdshow codec should give the correct aspect (but it displays square pixels). However, that PC hasn't been updated in ages, so the version of ffdshow could be very old.

As for VirtualDub, you can select the aspect it displays, but I suspect that's just for display and not encoding. I guess as the MPG is being served to VDub by AviSynth, the aspect info is being lost. ***Hmmm... that's just given me an idea - I wonder if you can specify the aspect in the AviSynth script? Will look into that.***

However, having set multiple different aspect ratios in the DivX codec settings window, and found that WMP always plays it as square pixels, maybe any setting won't help, and using mplayer with a forced aspect is the solution.

BTW I have also tried MPEG4 Modifier (to set different aspect ratios). This didn't make any different to WMP.

Isn't it just a question of setting the display AR to 16:9 in the output codec configuration?

VDub will display assuming square pixels, but when you play the resulting file with a player that respects the AR setting, it will stretch it accordingly.

Or are you saying you've tried that and it doesn't work?

Yup, I think that's probably where I've gotten to! I'll check any aspect stuff in AviSynth, but it looks like a player that does respect the AR info, or can be forced, is on the cards.

Cheers for all the replies!

HymnToLife
26th August 2008, 18:37
If it's H.264 and if it is acceptable for you (i.e. if you're just going to play it on a PC), you could mux it into Matroska, which will let you specify the display size and (I'm speaking only from personal experience here) will dosplay correctly on pretty much all configurations.

[P]ako
26th August 2008, 22:20
Good point about mkv and the aspect ratio though. I was playing using Windows Media Player (WMP), but I'd be quite happy to use another player. From what I've been, mplayer has the ability to be told the aspect to use for playback, so I'll probably try it in the next few days.

VLC player can do it too (videolan.org).

HymnToLife
27th August 2008, 00:10
Woops, seems I should read a bit more carefully :p Anyway, AFAIK it's the splitter that sets the display size, so which player you use shouldn't matter (at least I know this works in WMP).

sploo
28th August 2008, 10:50
Right, mplayer is the answer!

I've got quite a number of different AVI files (that I've converted from MPG) around at the moment - each having been done with slightly different aspect settings.

mplayer brings them up in a variety of aspects, so I can only presume it's honouring the settings in the file (I can't remember which ones were created with which aspect ratio). In any event, the aspect can be forced with the -aspect flag, so all is well.

The only strange thing I notice is that it will also happily play the original MPG streams, but unlike Windows Media Player, any attempts to skip around the file result in it exiting with an error (it can't sync). I'll take a look into that.

BTW It also looks like you can use a remote with it (there's config stuff to use an Apple remote). It would be nice to see if it'll work with the remote from my NOVA card.

Will report back if I have any success. Cheers for all the help!