Log in

View Full Version : Problem preserving aspect ratio after change in DVB-T TS stream


zzuser
5th November 2006, 13:41
Hi all!

I've been recording some free to air DVB-T TS streams to disk in order to transcode them to Xvid and/or x264. I am however having a hard time preserving aspect ratio on the streams.

Typically the aspect ratio in a given stream will change from 4:3 (commercials) to 16:9 (TV content) mutiple times. The problem is that the whole output clip will be transcoded at whatever aspect ratio was found first. Thus I usually end up with 4:3 output files, as most programs start with commercials, regardless of the fact that most of the content should be at 16:9.

I've tried different tricks with mencoder in order to maintain proper aspect ratio to no avail. The manual has a chapter, 13.10. Preserving aspect ratio, with autoaspect modifiers, but this does not seem to help either.

"13.10. Preserving aspect ratio

mencoder sample-svcd.mpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect -vf crop=714:548:0:14 -oac copy -o output.avi"

http://www.mplayerhq.hu/DOCS/HTML/en/aspect.html

I've tried different versions of mencoder on different platforms, but the problem persists. I've even tried the newest subversion SVN r20607, but this only fixes the bug with resolution changes in TS streams, not the aspect ratio problem.

I suppose I could split the TS stream into separate parts with different aspect ratios, encode them separately and merge the result. This does however require a new set of tools as well as player support for the resulting output file.

The other option if mencoder can't deal with aspect ratio changes is to force a certain aspect ratio for the whole file. This would mangle the aspect ratio of the commercials, but that I can live with. Anybody know of a way to read the aspect ratio data from a TS stream with a Linux CLI tool? I suppose I could sum up the occurences of different aspect rations and force the most prevalent.

Or is the problem simply that I'm using the wrong tool (mencoder) for the job?

I've put up a small sample clip (1.2Mb, 2 sec.) that demonstrates a typical aspect ratio change in a TS stream if somebody wants to have a go at encoding.
http://zzuser.tripod.com/aspect.ts

I need to be able to play back the resultant file with VLC, which I use for the original TS streams.

- Zed

PhillipWyllie
5th November 2006, 18:27
Using ProjectX (availble from the download page) -> PreSettings/ video and under spect ratio: set the AR to what you want(16:9 in this case). This will set the whole stream(demultiplexed) to one aspect ratio.

zzuser
5th November 2006, 19:52
Using ProjectX (availble from the download page) -> PreSettings/ video and under spect ratio: set the AR to what you want(16:9 in this case). This will set the whole stream(demultiplexed) to one aspect ratio.

Thanks for the tip Phillip, I shall have a look at ProjectX.

I apologize that I was unclear in my previous message. Not all content is with 16:9 aspect ratio. Some is 4:3 and some is 16:9. The problem is that I do not know in advance which it is going to be. It is not feasible to go and manually check every TS stream in advance. I really need a tool to extract the correct aspect ratio for this solution to work. As such I can use mencoder to force the proper aspect ratio, but I need to know in advance whether it is going to be 4:3 or 16:9.

Forcing the aspect ratio is not the preferred solution. I would prefer a solution where the encoder autodetects the aspect ratio as it is changed.

- Zed

PhillipWyllie
6th November 2006, 14:04
If you don't want the AR to change, you can leave the AR setting (in ProjectX) to unchanged. If you want to see the AR change then play the TS file in Video Lan client. I assumed you're cutting the ads out so the AR should be constant. It doesn't matter if you get the AR wrong, you can always run the demuxing again or pass the demuxed video stream through ProjectX again. Also I don't think XVid supports ARs( let alone changing ones) so you'll have to resize. You could do a quick encode of a short clip and change if necessary. As all broadcasts vary you'll have do some initial investigations on every project. Oh I have trouble downloading your sample clip( I get a page full of garbage).

zzuser
8th November 2006, 18:42
If you don't want the AR to change, you can leave the AR setting (in ProjectX) to unchanged.

I do want the aspect ratio to change. I would like the content to appear just as it was originally broadcast.


If you want to see the AR change then play the TS file in Video Lan client.

Yes, playing the original TS file in VLC works just dandy, but I want the transcoded content to play correctly too.


I assumed you're cutting the ads out so the AR should be constant. It doesn't matter if you get the AR wrong, you can always run the demuxing again or pass the demuxed video stream through ProjectX again.

Nope, no ad cutting here, just pure transcoding. However I do not want to waste time on checking and re-encoding content. I want to get it right the first time.

Also I don't think XVid supports ARs( let alone changing ones) so you'll have to resize.

Quite possible. Whether or not XviD supports aspect ratio changes I would expect x264 to support them as HDTV DVB broadcasts using h.264 must support aspect ratio changes.

You could do a quick encode of a short clip and change if necessary. As all broadcasts vary you'll have do some initial investigations on every project.

Unfortunately as I pointed out earlier this is not feasible. Luckily for me I have figured out how to autodetect the aspect ratios in the TS stream. Thus I can always force the majority aspect ratio in a quick and dirty workaround.

Oh I have trouble downloading your sample clip( I get a page full of garbage).

This is probably because the hosting site send the wrong MIME type. If you want to download the clip you have to select "Save link as.." in your browser.