[FFmpeg-devel] [PATCH] Write Pixel Aspect Ratio tag to QuickTime files

Baptiste Coudurier baptiste.coudurier
Wed Jul 7 23:35:41 CEST 2010


On 07/07/2010 02:17 PM, Daniel Kristjansson wrote:
> On Wed, 2010-07-07 at 13:37 -0700, Baptiste Coudurier wrote:
>> Hi,
>>
>> On 07/07/2010 10:24 AM, Daniel Kristjansson wrote:
>>>
>>> This allows for non-square pixels in QT containers regardless
>>> of codec. 'pasp' is also a required tag in Apple QT when the
>>> pixels are not square.
>>
>> I doubt this is required.
>> How does quicktime do with mp4 that did only define pasp until recently ?
>
> It's required in the spec, p118 of qtfs.pdf, "Pixel aspect ratio. This
> extension is mandatory for video formats that use non-square pixels."

My specs say MPEG-4 and uncompresed YCbCr. Dated 2007-09-04

> The QuickTime player (shows 1440x1080 MPEG-2 material at 36:27 rather
> than 16:9 without this. I did not test whether NTSC/PAL material is
> played correctly.

What kind of mpeg-2 using which codec ?
Can you share a sample ?

>> 0/1 would set them here, and that's not wanted.
> Oops! Revised patch attached.
>
> -- Daniel
>
>
> mov-pasp-v2.patch
>
>
> --- libavformat/movenc.c.orig	2010-07-07 13:17:32.571296315 -0400
> +++ libavformat/movenc.c	2010-07-07 17:10:15.028245673 -0400
> @@ -747,6 +747,25 @@ static int mov_write_subtitle_tag(ByteIO
>       return updateSize(pb, pos);
>   }
>
> +static int mov_write_pasp_tag(ByteIOContext *pb, MOVTrack *track)
> +{
> +    int64_t pos = url_ftell(pb);
> +    unsigned hSpacing = 1, vSpacing = 1;
> +
> +    if (track->enc->sample_aspect_ratio.den&&
> +        track->enc->sample_aspect_ratio.num) {
> +        hSpacing = track->enc->sample_aspect_ratio.num;
> +        vSpacing = track->enc->sample_aspect_ratio.den;
> +    }
> +
> +    put_be32(pb, 0);     /* size */
> +    put_tag(pb, "pasp"); /* tag  */
> +    put_be32(pb, hSpacing);
> +    put_be32(pb, vSpacing);
> +
> +    return updateSize(pb, pos);
> +}
> +
>   static int mov_write_video_tag(ByteIOContext *pb, MOVTrack *track)
>   {
>       int64_t pos = url_ftell(pb);
> @@ -793,6 +812,8 @@ static int mov_write_video_tag(ByteIOCon
>       else
>           put_be16(pb, 0x18); /* Reserved */
>       put_be16(pb, 0xffff); /* Reserved */
> +    if (track->mode == MODE_MOV)
> +        mov_write_pasp_tag(pb, track);

Move the check for sample_aspect ratio here and don't write the atom if 
it is not set or square.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list