Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > New and alternative a/v containers

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th May 2007, 14:57   #1  |  Link
mcka
Registered User
 
Join Date: Mar 2007
Posts: 27
Patch mp4box to make anamorphic PAR compatible with Quicktime (like NicMP4Box)

Hi!

I know that many people here don't like the "crap from Apple", but I'd like to create MP4/x264 files, that also work with Quicktime (Apple TV...), which supports AVC main profile. The only problem is anamorphic encoding. If I create a mp4 file with an anamorphic video-stream using x264.exe and mp4box (MeGUI), Quicktime does not use the correct PAR/DAR.

There is a way to store the PAR in a MP4-container, to make Quicktime understand it. People from Handbrake have implemented it in their development-version: By adding an atom with a transformation matrix for the PAR to the mp4 container (AFAIK in moov.trak.tkhd.reserved3), Quicktime shows the video correctly (thread in the handbrake forum).

The patch was based on the following information:
http://sourceforge.net/forum/message.php?msg_id=2059542
http://developer.apple.com/documenta...39-CH204-33299

Handbrake uses mpeg4ipv2, there is also an updated patch for that:
http://mpeg4ip.cvs.sourceforge.net/m...?r1=1.4&r2=1.5

I have looked at the source of NicMP4Box, which was very interesting, but does something different (it adds an uuid atom by patching mp4box). Looking at the source of MP4Box, there is a GF_TrackHeaderBox struct with a property reserved3 (u16).

Perhaps there is an easier way since Quicktime 7.1, without such a transformation matrix:

Quote:
New features of QuickTime 7.1 include
[...]
* Support for 'pasp' and 'clap' Image Description extentions supporting aperture mode.
[...]
from: http://developer.apple.com/quicktime/whatsnew.htm

Apple provides some details, about 'pasp' or 'pixel aspect ratio', but I have no idea how to use it with mp4box or something similar:
http://www.devworld.apple.com./docum...nce/index.html

Something else I've found about 'pasp' (but it seems to be older, not sure if it has something to do with 'pasp' mentioned above):
http://developer.apple.com/quicktime...h019.html#pasp

I'm new to mp4box, so I'm not sure how to implement the transformation marix or perhaps pasp into it. But looking at the patch for Handbrake, it should not be very complicated. Does someone have an idea for a patch, similar to NicMP4Box?

Or can the pasp setting be changed without patching anything?

best regards
mcka
mcka is offline   Reply With Quote
Old 12th May 2007, 13:05   #2  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
why dont you simply post a feature request on the gpac/mp4box project:
http://sourceforge.net/tracker/?atid...01&func=browse
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 15th May 2007, 01:07   #3  |  Link
mcka
Registered User
 
Join Date: Mar 2007
Posts: 27
It has already been posted there more than 1 year ago:

http://sourceforge.net/tracker/index...01&atid=571741
https://sourceforge.net/tracker/inde...01&atid=571741

I'd probably forget what I've written about transformation matrix, but concentrate on the new "pasp" feature of MPEG standard ISO/IEC 14496-12 (AMENDMENT 1: Support for timed metadata, non-square pixels and improved sample groups). That seems to be what has been implemented in Quicktime 7.1.

That's what the Paper from ISO states:

Quote:
Originally Posted by ISO/IEC 14496-12/AMENDMENT 1
The pixel aspect ratio and clean aperture of the video may be specified using the ‘pasp’ and ‘clap’ sample
entry boxes, respectively. These are both optional; if present, they over-ride the declarations (if any) in
structures specific to the video codec, which structures should be examined if these boxes are absent.
In the PixelAspectRatioBox, hSpacing and vSpacing have the same units, but those units are unspecified:
only the ratio matters. hSpacing and vSpacing may or may not be in reduced terms, and they may reduce
to 1/1. Both of them must be positive.
They are defined as the aspect ratio of a pixel, in arbitrary units. If a pixel appears H wide and V tall, then
hSpacing/vSpacing is equal to H/V. This means that a square on the display that is n pixels tall needs to be
n*vSpacing/hSpacing pixels wide to appear square.
As the new features are optional, it's no problem to concentrate on pasp only. I think you only have to add a property called pasp from type PixelAspectRatioBox to the VisualSampleEntry class/struct:

Code:
class VisualSampleEntry(codingname) extends SampleEntry (codingname){
   [...]
   PixelAspectRatioBox pasp; // optional
}
The type PixelAspectRatioBox with properties hSpacing and vSpacing has to be defined in an own class/struct:

Code:
class PixelAspectRatioBox extends Box(‘pasp’){
   unsigned int(32) hSpacing;
   unsigned int(32) vSpacing;
}
So you must add the settings for correct PAR to a PixelAspectRatioBox object/struct, and add this to the corresponding VisualSampleEntry (pasp property).

I have looked at the source of mp4box, but I've no idea where to add the PixelAspectRatioBox and I'm not sure how to map the classes from ISO standard to the data structures in mp4box.

best regards
mcka

Last edited by mcka; 15th May 2007 at 01:10.
mcka is offline   Reply With Quote
Old 18th May 2007, 22:52   #4  |  Link
mcka
Registered User
 
Join Date: Mar 2007
Posts: 27
I've added a Feature Request to the Tracker:

http://sourceforge.net/tracker/index...01&atid=571741
mcka is offline   Reply With Quote
Old 7th August 2007, 10:54   #5  |  Link
Stux
Registered User
 
Stux's Avatar
 
Join Date: Dec 2002
Location: Sydney, Australia
Posts: 252
3ivx MPEG-4 5.0.1 now supports Apple QuickTime compatible Aspect-Ratio muxing/demuxing etc.

http://3ivx.com/pr/pr20070730_501.html
QuickTime compatible Aspect Ratio Signaling has been implemented within all components of the 3ivx MPEG-4 DirectShow Filter Suite, allowing Windows application developers to produce and handle Anamorphic content which is compatible with all Windows DirectShow players as well as Apple’s QuickTime and AppleTV.

Its not 'pasp' support, but we found that QT never outputs PASP videos anyway, so we had to implemented the QT6 MP4 "transformation matrix" support. which is used by iPhones et al.
__________________
http://www.3ivx.com
Stux is offline   Reply With Quote
Old 7th August 2007, 12:24   #6  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
Quote:
Originally Posted by Stux View Post
.... but we found that QT never outputs PASP videos anyway, so we had to implemented the QT6 MP4 "transformation matrix" support....
Hi Stux,

Thanks for confirming this. As you know, QuickTime Pro offers quite a few other "Visual and Audio Settings" options. Do you have any plans to incorporate any of these too?


Cheers
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 9th August 2007, 08:36   #7  |  Link
Stux
Registered User
 
Stux's Avatar
 
Join Date: Dec 2002
Location: Sydney, Australia
Posts: 252
Quote:
Originally Posted by SeeMoreDigital View Post
Hi Stux,
QuickTime Pro offers quite a few other "Visual and Audio Settings" options. Do you have any plans to incorporate any of these too?
Be more specific
__________________
http://www.3ivx.com
Stux is offline   Reply With Quote
Old 11th August 2007, 12:29   #8  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
Hi Stux,

QT7 Pro offers the following "Visual Settings": -




And "Audio Settings": -



Obviously, adjustments to any of these settings are only effective when played in QT7 player or the embedded web player.


Cheers
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 11th August 2007, 16:42   #9  |  Link
Stux
Registered User
 
Stux's Avatar
 
Join Date: Dec 2002
Location: Sydney, Australia
Posts: 252
The only one of those settings we will be respecting is the "Aspect Ratio" one. Not the scaling size, nor the volumes and balances.

I believe we do respect track disabled/enabled in the case of multiple audio tracks etc.
__________________
http://www.3ivx.com
Stux is offline   Reply With Quote
Old 7th August 2007, 12:27   #10  |  Link
Drachir
Teetrinker
 
Drachir's Avatar
 
Join Date: Jan 2002
Posts: 258
Quote:
Originally Posted by Stux View Post
Its not 'pasp' support, but we found that QT never outputs PASP videos anyway, so we had to implemented the QT6 MP4 "transformation matrix" support. which is used by iPhones et al.
I would allow the use of the "transformation matrix" only if the the extension and the main brand of the file is set to "m4v". Just guessing that this format from apple allow the usage of the "transformation matrix". Because in the MP4 File Format (ISO/IEC 14496-14) this in not used.

Quote:
Originally Posted by ISO/IEC 14496-14
In MPEG-4 both visual and aural composition are done using the BIFS system. Therefore structures marked as “template” in the ISO Base Media Format which pertain to composition, including fields such as matrices, layers, graphics modes (and their opcolors), volumes, and balance values, from the MovieHeaderBox and TrackHeaderBox, are all set to their default values in the file format. These fields do not define visual or audio composition in MPEG-4; in MPEG-4, the BIFS system defines the composition.
And in
Quote:
Originally Posted by ISO/IEC 14496-12
6.2.2 Data Types and fields
...
Matrix values which occur in the headers specify a transformation of video images for presentation. Not all
derived specifications use matrices; if they are not used, they shall be set to the identity matrix,
...
And the QuickTime File Format should allow the use of transformation matrix .
__________________
Play GO ( http://en.wikipedia.org/wiki/Go_(board_game))
Drachir is offline   Reply With Quote
Old 10th November 2007, 23:32   #11  |  Link
cyril
Registered User
 
Join Date: Jan 2004
Posts: 1
Just a quick message to inform you that the PixelAspectRatioBox (pasp) was implemented in MP4Box and is now interporable with Quicktime 7.3 (not with older versions)
cyril is offline   Reply With Quote
Old 13th November 2007, 11:45   #12  |  Link
mcka
Registered User
 
Join Date: Mar 2007
Posts: 27
Thank you so much!

Is there a compiled version available somwhere? If not I'll try to compile one, never done that on Windows before....

One question: is this feaure allways enabled when using anamorphic encoding, or is there a new command line switch? So is it combined with the old way to use anamorphic encoding (which works in other players), or is it an alternative, so I have to choose if I want to use PASP or the old way?

Again, thank you very much for implementing it!
mcka is offline   Reply With Quote
Old 13th November 2007, 12:15   #13  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
Kurtnoise compiled a new build of MP4Box yesterday: -

http://kurtnoise.free.fr/mp4tools/


Cheers
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 16th November 2007, 14:04   #14  |  Link
mcka
Registered User
 
Join Date: Mar 2007
Posts: 27
Thanks again!

I tried the Version from Kurtnoise with StaxRip, and it worked perfectly! Now I can encode files which work everywhere!
mcka is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:44.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.