PDA

View Full Version : Anamorphic 16:9 results in wrong PAR/DAR


Coert
04-07-2007, 01:05 AM
Anamorphic video seems to lose its display aspect ratio.

In particular, "mediainfo.exe" reports the SAR. Videora Apple TV Converter 2.15 then uses the SAR (instead of DAR) to calculate the rescaling ("-s" flag to ffmpeg).

Converting
720x480 with SAR 1.5 (3:2), PAR 1.185 (32:27), DAR 1.778 (16:9)
with no rescaling results in
720x480 with SAR 1.5 (3:2), PAR 1.5 (3:2)

How can I prevent this? Is there an option to force the correct PAR/DAR?

Tools used: Videora Apple TV Converter 2.15 (FFmpeg SVN-r8435), GSpot 2.70a

Here is a few frames from the source video:
http://users.gotsky.com/cvonk/tmp/wide.avi

EXEC: C:\Program Files\Video\Videora Converter\Tools\MediaInfo\mediainfobatch.bat "C:\Program Files\Video\Videora Converter\Tools\MediaInfo\MediaInfo.exe" "C:\Program Files\Video\Videora Converter\Tools\MediaInfo\parameters.txt" "U:\My Name\Our Video\Video Editing\releases\DV Movies (AVI)\Intro - Johan en Sander [wide].avi"

PlayTime=00:00:10.644

Width=720

Height=480

AspectRatio=1.500

FrameRate=29.970
MediaInfo Command line, MediaInfoLib - v0.7.4.5
MSG - OS - Version: Microsoft Windows NT 5.1.2600 Service Pack 2
MSG - Converter - Version: 2.15
MSG - Converter - Profile: H.264 Apple TV, PAL 16:9 Movie
MSG - MediaInfo - Length: 10s
MSG - MediaInfo - Width: 720 pixels
MSG - MediaInfo - Height: 480 pixels
MSG - MediaInfo - Aspect Ratio: 1.5
MSG - MediaInfo - Framerate: 29.97 fps
MSG - Converter - Automatically Generating Framerate
EXEC: C:\Program Files\Video\Videora Converter\Tools\FFmpeg\ffmpeg.exe -y -i "U:\My Name\Our Video\Video Editing\releases\DV Movies (AVI)\Intro - Johan en Sander [wide].avi" -an -pass 1 -f mp4 -title "Intro - Johan en Sander [wide]" -timestamp "2007-04-07 05:15:16" -vcodec h264 -level 30 -r 30000/1001 -b 1500k -bt 1500k -bufsize 10000k -maxrate 10000k -g 300 -coder 0 -threads 2 "U:\My Name\Not Backed Up\Converted Videos\AppleTV\H264\Intro - Johan en Sander [wide].mp4-1"

FFmpeg version SVN-r8435, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-liba52 --enable-avisynth --enable-libdts --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libogg --enable-libtheora --enable-libvorbis --enable-x264 --enable-xvid --enable-amr_nb --enable-amr_wb --cpu=i686 --enable-memalign-hack --extra-ldflags=-static
libavutil version: 49.3.0
libavcodec version: 51.39.0
libavformat version: 51.11.0
built on Mar 18 2007 22:27:19, gcc: 4.3.0 20070126 (experimental)
Input #0, avi, from 'U:\My Name\Our Video\Video Editing\releases\DV Movies (AVI)\Intro - Johan en Sander [wide].avi':
Duration: 00:00:10.6, start: 0.000000, bitrate: 27701 kb/s
Stream #0.0: Video: dvvideo, yuv411p, 720x480, 29.97 fps(r)
Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s
Output #0, mp4, to 'U:\My Name\Not Backed Up\Converted Videos\AppleTV\H264\Intro - Johan en Sander [wide].mp4-1':
Stream #0.0: Video: h264, yuv420p, 720x480, q=2-31, pass 1, 1500 kb/s, 29.97 fps(c)
Stream mapping:
Stream #0.0 -> #0.0
[h264 @ 009CD840]using cpu capabilities MMX MMXEXT SSE SSE2
Press [q] to stop encoding
frame= 30 fps= 17 q=3.0 size= 159kB time=1.0 bitrate=1344.9kbits/s
frame= 46 fps= 20 q=17.0 size= 301kB time=1.5 bitrate=1641.7kbits/s
:
frame= 317 fps= 30 q=29.0 size= 1883kB time=10.5 bitrate=1463.2kbits/s
frame= 318 fps= 30 q=-14836604.9 Lsize= 1887kB time=10.6 bitrate=1456.5kbits/s

video:1726kB audio:0kB global headers:1kB muxing overhead 9.250677%
[h264 @ 009CD840]slice I:2 Avg QP:25.00 size: 14313
[h264 @ 009CD840]slice P:316 Avg QP:21.76 size: 6012
[h264 @ 009CD840]mb I I16..4: 60.3% 0.0% 39.7%
[h264 @ 009CD840]mb P I16..4: 3.9% 0.0% 0.0% P16..4: 15.4% 0.0% 0.0% 0.0% 0.0% skip:80.8%
[h264 @ 009CD840]final ratefactor: 23.48
[h264 @ 009CD840]SSIM Mean Y:0.9888695
[h264 @ 009CD840]kb/s:1454.0
MSG - Converter - Automatically Generating Framerate
EXEC: C:\Program Files\Video\Videora Converter\Tools\FFmpeg\ffmpeg.exe -y -i "U:\My Name\Our Video\Video Editing\releases\DV Movies (AVI)\Intro - Johan en Sander [wide].avi" -pass 2 -f mp4 -title "Intro - Johan en Sander [wide]" -timestamp "2007-04-07 05:15:27" -vcodec h264 -level 30 -r 30000/1001 -b 1500k -bt 1500k -bufsize 10000k -maxrate 10000k -g 300 -coder 0 -threads 2 -acodec aac -ac 2 -ab 128k "U:\My Name\Not Backed Up\Converted Videos\AppleTV\H264\Intro - Johan en Sander [wide].mp4-1"

FFmpeg version SVN-r8435, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-liba52 --enable-avisynth --enable-libdts --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libogg --enable-libtheora --enable-libvorbis --enable-x264 --enable-xvid --enable-amr_nb --enable-amr_wb --cpu=i686 --enable-memalign-hack --extra-ldflags=-static
libavutil version: 49.3.0
libavcodec version: 51.39.0
libavformat version: 51.11.0
built on Mar 18 2007 22:27:19, gcc: 4.3.0 20070126 (experimental)
Input #0, avi, from 'U:\My Name\Our Video\Video Editing\releases\DV Movies (AVI)\Intro - Johan en Sander [wide].avi':
Duration: 00:00:10.6, start: 0.000000, bitrate: 27701 kb/s
Stream #0.0: Video: dvvideo, yuv411p, 720x480, 29.97 fps(r)
Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s
Output #0, mp4, to 'U:\My Name\Not Backed Up\Converted Videos\AppleTV\H264\Intro - Johan en Sander [wide].mp4-1':
Stream #0.0: Video: h264, yuv420p, 720x480, q=2-31, pass 2, 1500 kb/s, 29.97 fps(c)
Stream #0.1: Audio: aac, 48000 Hz, stereo, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
[h264 @ 009CD840]using cpu capabilities MMX MMXEXT SSE SSE2
Press [q] to stop encoding
frame= 30 fps= 0 q=20.0 size= 62kB time=1.0 bitrate= 521.3kbits/s
frame= 54 fps= 50 q=29.0 size= 120kB time=1.8 bitrate= 553.8kbits/s
:
frame= 304 fps= 33 q=2.0 size= 1639kB time=10.1 bitrate=1327.8kbits/s
frame= 318 fps= 34 q=-14836604.9 Lsize= 1651kB time=10.6 bitrate=1280.9kbits/s

video:1503kB audio:79kB global headers:1kB muxing overhead 4.304157%
[h264 @ 009CD840]slice I:2 Avg QP:12.00 size: 71338
[h264 @ 009CD840]slice P:316 Avg QP:22.27 size: 4617
[h264 @ 009CD840]mb I I16..4: 37.0% 0.0% 63.0%
[h264 @ 009CD840]mb P I16..4: 3.8% 0.0% 0.0% P16..4: 15.8% 0.0% 0.0% 0.0% 0.0% skip:80.4%
[h264 @ 009CD840]SSIM Mean Y:0.9861212
[h264 @ 009CD840]kb/s:1207.6
EXEC: C:\Program Files\Video\Videora Converter\Tools\NicMP4Box\NicMP4Box.exe -itags "Name=Intro - Johan en Sander [wide]" -add "U:\My Name\Not Backed Up\Converted Videos\AppleTV\H264\Intro - Johan en Sander [wide].mp4-1" "U:\My Name\Not Backed Up\Converted Videos\AppleTV\H264\Intro - Johan en Sander [wide].mp4"

Importing ISO File: | | (01/100)
Importing ISO File: | | (02/100)
:
Importing ISO File: |=================== | (98/100)
Importing ISO File: |=================== | (99/100)

Importing ISO File: | | (01/100)
Importing ISO File: | | (02/100)
:
Importing ISO File: |=================== | (98/100)
Importing ISO File: |=================== | (99/100)

Saving U:\My Name\Not Backed Up\Converted Videos\AppleTV\H264\Intro - Johan en Sander [wide].mp4: 0.500 secs Interleaving
ISO File Writing: | | (01/100)
ISO File Writing: | | (02/100)
:
ISO File Writing: |=================== | (98/100)
ISO File Writing: |=================== | (99/100)

DELETE: U:\My Name\Not Backed Up\Converted Videos\AppleTV\H264\Intro - Johan en Sander [wide].mp4-1

msopnet
04-11-2007, 01:33 AM
Noted in the iPod forum.

See bottom of my signature.

Coert
04-17-2007, 10:19 AM
Thanks. That would beat resizing the width.

When I run the tool it changes the DAR from 16:9 (what it should be) to 3:2 (the SAR). QuickTime displays both files assuming square pixels. Am I missing something?

Here is the screenshot of GSpot. At the top the original file, and the output of fixh264ar at the bottom.

http://users.gotsky.com/cvonk/tmp/par.png

output of mp4dump on original .mp4 file
mp4dump.exe version 1.4.7
:
type stbl
type stsd
version = 0 (0x00)
flags = 0 (0x000000)
entryCount = 1 (0x00000001)
type avc1
reserved1 = <6 bytes> 00 00 00 00 00 00
dataReferenceIndex = 1 (0x0001)
reserved2 = <16 bytes> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
width = 720 (0x02d0)
height = 480 (0x01e0)
reserved3 = <14 bytes> 00 48 00 00 00 48 00 00 00 00 00 00 00 01
compressorName =
reserved4 = <4 bytes> 00 18 ff ff
type avcC
configurationVersion = 1 (0x01)
AVCProfileIndication = 66 (0x42)
profile_compatibility = 192 (0xc0)
AVCLevelIndication = 30 (0x1e)
reserved = 63 (0x3f) <6 bits>
lengthSizeMinusOne = 3 (0x3) <2 bits>
reserved1 = 7 (0x7) <3 bits>
numOfSequenceParameterSets = 1 (0x01) <5 bits>
<table entries suppressed>
numOfPictureParameterSets = 1 (0x01)
<table entries suppressed>
type uuid
data = <4 bytes> 00 00 00 01
type btrt
bufferSizeDB = 128127 (0x0001f47f)
avgBitrate = 5163080 (0x004ec848)
maxBitrate = 1279920 (0x001387b0)
:

output of mp4dump the .mp4 file generated using fixh264ar
mp4dump.exe version 1.4.7
:
type stbl
type stsd
version = 0 (0x00)
flags = 0 (0x000000)
entryCount = 1 (0x00000001)
type avc1
reserved1 = <6 bytes> 00 00 00 00 00 00
dataReferenceIndex = 1 (0x0001)
reserved2 = <16 bytes> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
width = 720 (0x02d0)
height = 480 (0x01e0)
reserved3 = <14 bytes> 00 48 00 00 00 48 00 00 00 00 00 00 00 01
compressorName =
reserved4 = <4 bytes> 00 18 ff ff
type avcC
configurationVersion = 1 (0x01)
AVCProfileIndication = 66 (0x42)
profile_compatibility = 192 (0xc0)
AVCLevelIndication = 30 (0x1e)
reserved = 63 (0x3f) <6 bits>
lengthSizeMinusOne = 3 (0x3) <2 bits>
reserved1 = 7 (0x7) <3 bits>
numOfSequenceParameterSets = 1 (0x01) <5 bits>
<table entries suppressed>
numOfPictureParameterSets = 1 (0x01)
<table entries suppressed>
type uuid
data = <4 bytes> 00 00 00 01
type btrt
bufferSizeDB = 128127 (0x0001f47f)
avgBitrate = 5163080 (0x004ec848)
maxBitrate = 1279920 (0x001387b0)
:

msopnet
04-24-2007, 09:57 AM
Sorry about the delay, what the program does is set PAR=1:1 - so this fix only works if your resolution (SAR) is the same as your DAR. I apparently didn't thoroughly read your initial post. (oops)

So, by the formula DAR=SAR*PAR, you need PAR=(16/9)/(3/2)=32/27

Use a program called Yamb. In the tab it opens at, you can add your video and it will allow you to set PAR. That should work, I believe, but I've only set 1:1 before...

Or, easier yet, I just edited my program to use 32:27 instead and uploaded a copy here:
http://www.msop.net/Fix_H264_Aspect_Ratio_32-27.exe

That might do it easier for you. Just put it in the same folder as the other one (with MP4Box.exe)

Coert
04-26-2007, 12:57 AM
Thanks. It now sets DAR correctly, but PAR remains blank. Looks like QuickTime/Apple TV honor the SAR and PAR instead of DAR.