Log in

View Full Version : MeGUI\x264 Aspect Ratio


Half-Light Agent
13th July 2013, 02:22
Some (MeGUI\x264) MKVs playback as a thin horizontal line, apparently due to an error in the encoded original dispaly aspect ratio value. (In one case, MediaInfo reports the source as 16:9 but the encode as ODAR as 1778:1 with DAR 16:9.)

What might cause this? Can the ODAR be edited after encoding?

sneaker_ger
13th July 2013, 17:53
You can edit wrong container info using the header editor of mkvmerge gui.

Half-Light Agent
13th July 2013, 17:57
@sneaker_ger: It seems the problem is not in the header, but in the x264 stream itself.

I'm not sure what causes the original display aspect ratio to be encoded incorrectly but it seems to be what causes the playback issue. The problem can be corrected by demuxing the MKVs and then remuxing them with MKVmerge, adding --engage remove_bitstream_ar_info in Extra options\User defined options of the x264 track - thus removing the incorrect original display aspect ratio data.

sneaker_ger
13th July 2013, 18:44
That should also work when remuxing directly from mkv to mkv (mkvtoolnix >= 6.2.0).

There's also a tool to change the SAR info in the bitstream, but it is not stable:
http://forum.doom9.org/showthread.php?t=152419

If you only deal with SAR 1:1 using the mkvmerge option is probably the easiest way, though.

Half-Light Agent
13th July 2013, 19:19
@sneaker_ger: If I add the MKV I wish to strip directly in MKVmerge 6.3 and add --engage remove_bitstream_ar_info to Extra options\User defined options of the x264 stream, the orginal display aspect ratio remains in the remuxed file.

Thank you for indicating the other option. Looking into it.

sneaker_ger
13th July 2013, 19:56
@sneaker_ger: If I add the MKV I wish to strip directly in MKVmerge 6.3 and add --engage remove_bitstream_ar_info to Extra options\User defined options of the x264 stream, the orginal display aspect ratio remains in the remuxed file.

Hmm, looks like you found a bug in mkvtoolnix. I have made a report and will see what the author has to say about this. I only followed the changelog that says it was fixed in 6.2.0, but never actually bothered to test the fix.

https://trac.bunkus.org/ticket/868

/edit:
The author already answered: he won't spent any more time on this feature, so we will not get a fix.

Half-Light Agent
13th July 2013, 21:16
I'm not sure how this figures in the whole, but in MKVmerge x26\Format specific options display width/height is reported as 1280160/720. (1280160 / 720 = 1778, the bad aspect ratio which MediaInfo reports for the MKV.)

Guest
13th July 2013, 21:45
It seems the problem is not in the header, but in the x264 stream itself. ... I'm not sure what causes the original display aspect ratio to be encoded incorrectly but it seems to be what causes the playback issue. Then we must ask what settings did you use when originally encoding the source x264 stream?

sneaker_ger
13th July 2013, 21:52
I'm not sure how this figures in the whole, but in MKVmerge x26\Format specific options display width/height is reported as 1280160/720. (1280160 / 720 = 1778, the bad aspect ratio which MediaInfo reports for the MKV.)

Mkvmerge always tries to copy those from the source file it reads. This can be the SAR info of a raw H.264 stream or the same fields of a Matroska source file. So if the raw H.264 stream has a "weird" SAR info and you mux that stream with mkvmerge while not specifying the correct AR yourself, it will use the "weird" values of the source file to set the container AR.

So a correct remux with (the currently broken) mkvmerge should be:
1. demux to raw .h264 file
2. remux with:
--engage remove_bitstream_ar_info (global, removes bitstream AR)
--display-dimensions 0:1280x720 (track, sets container AR, called "Display width/height:" in the GUI)

If only the container AR is wrong you can set it without remuxing using the header editor like I said in my first post.

Half-Light Agent
13th July 2013, 22:03
@sneaker_ger: The source seems fine. No obviously wrong values, either widhth/height or aspect ratio. (See the next-after-next post.) The error seems to be coded into the x264 stream.

One-Click profile:
<?xml version="1.0"?>
<GenericProfileOfOneClickSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Pixie (2pass 2000 ABR, Progressive)</Name>
<Settings>
<VideoProfileName>x264: Pixie (2pass 2000 ABR)</VideoProfileName>
<AvsProfileName>AviSynth: *scratchpad*</AvsProfileName>
<PrerenderVideo>false</PrerenderVideo>
<AudioProfileName>migrated</AudioProfileName>
<AudioEncodingModeString>migrated</AudioEncodingModeString>
<AudioSettingsString>
<OneClickAudioSettings>
<AudioEncodingModeString>IfCodecDoesNotMatch</AudioEncodingModeString>
<Language>[default]</Language>
<Profile>Nero AAC: Pixie</Profile>
<UseFirstTrackOnly>true</UseFirstTrackOnly>
</OneClickAudioSettings>
</AudioSettingsString>
<DontEncodeVideo>false</DontEncodeVideo>
<SignalAR>false</SignalAR>
<AutomaticDeinterlacing>false</AutomaticDeinterlacing>
<AutoCrop>false</AutoCrop>
<KeepInputResolution>true</KeepInputResolution>
<OutputResolution>1280</OutputResolution>
<Filesize xsi:nil="true" />
<SplitSize xsi:nil="true" />
<ContainerCandidates>
<string>MKV</string>
</ContainerCandidates>
<LeadingName>Pixie.</LeadingName>
<WorkingNameReplace />
<WorkingNameReplaceWith />
<UseChaptersMarks>true</UseChaptersMarks>
<UseNoLanguagesAsFallback>false</UseNoLanguagesAsFallback>
<DisableIntermediateMKV>false</DisableIntermediateMKV>
<DefaultWorkingDirectory />
<DefaultOutputDirectory>D:\[Content]\XXXXXXXXXXXXX\Downloads</DefaultOutputDirectory>
<DefaultAudioLanguageString>
<string>English</string>
</DefaultAudioLanguageString>
<DefaultSubtitleLanguageString>
<string>[none]</string>
</DefaultSubtitleLanguageString>
<IndexerPriorityString>
<string>DGI</string>
<string>D2V</string>
<string>FFMS</string>
<string>AVISOURCE</string>
<string>DGA</string>
</IndexerPriorityString>
</Settings>
</GenericProfileOfOneClickSettings>

x264 profile:
<?xml version="1.0"?>
<GenericProfileOfx264Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Pixie (2pass 2000 ABR)</Name>
<Settings>
<EncodingMode>4</EncodingMode>
<BitrateQuantizer>2000</BitrateQuantizer>
<KeyframeInterval>240</KeyframeInterval>
<NbBframes>3</NbBframes>
<MinQuantizer>10</MinQuantizer>
<MaxQuantizer>51</MaxQuantizer>
<V4MV>false</V4MV>
<QPel>false</QPel>
<Trellis>false</Trellis>
<CreditsQuantizer>40</CreditsQuantizer>
<Logfile>.stats</Logfile>
<VideoName />
<CustomEncoderOptions />
<FourCC>0</FourCC>
<MaxNumberOfPasses>3</MaxNumberOfPasses>
<NbThreads>0</NbThreads>
<x264PresetLevel>veryslow</x264PresetLevel>
<x264Tuning>migrated</x264Tuning>
<x264PsyTuning>FILM</x264PsyTuning>
<QuantizerCRF>2000</QuantizerCRF>
<InterlacedMode>progressive</InterlacedMode>
<TargetDeviceXML>0</TargetDeviceXML>
<BlurayCompatXML>False</BlurayCompatXML>
<NoDCTDecimate>false</NoDCTDecimate>
<PSNRCalculation>false</PSNRCalculation>
<NoFastPSkip>false</NoFastPSkip>
<NoiseReduction>0</NoiseReduction>
<NoMixedRefs>false</NoMixedRefs>
<X264Trellis>2</X264Trellis>
<NbRefFrames>5</NbRefFrames>
<AlphaDeblock>-1</AlphaDeblock>
<BetaDeblock>-1</BetaDeblock>
<SubPelRefinement>7</SubPelRefinement>
<MaxQuantDelta>4</MaxQuantDelta>
<TempQuantBlur>0</TempQuantBlur>
<BframePredictionMode>3</BframePredictionMode>
<VBVBufferSize>0</VBVBufferSize>
<VBVMaxBitrate>0</VBVMaxBitrate>
<METype>2</METype>
<MERange>16</MERange>
<MinGOPSize>24</MinGOPSize>
<IPFactor>1.4</IPFactor>
<PBFactor>1.3</PBFactor>
<ChromaQPOffset>0</ChromaQPOffset>
<VBVInitialBuffer>0.9</VBVInitialBuffer>
<BitrateVariance>1.0</BitrateVariance>
<QuantCompression>0.6</QuantCompression>
<TempComplexityBlur>20</TempComplexityBlur>
<TempQuanBlurCC>0.5</TempQuanBlurCC>
<SCDSensitivity>40</SCDSensitivity>
<BframeBias>0</BframeBias>
<PsyRDO>1.0</PsyRDO>
<PsyTrellis>0.00</PsyTrellis>
<Deblock>true</Deblock>
<Cabac>true</Cabac>
<UseQPFile>false</UseQPFile>
<WeightedBPrediction>true</WeightedBPrediction>
<WeightedPPrediction>2</WeightedPPrediction>
<NewAdaptiveBFrames>1</NewAdaptiveBFrames>
<x264BFramePyramid>0</x264BFramePyramid>
<x264GOPCalculation>1</x264GOPCalculation>
<ChromaME>true</ChromaME>
<MacroBlockOptions>0</MacroBlockOptions>
<P8x8mv>true</P8x8mv>
<B8x8mv>true</B8x8mv>
<I4x4mv>true</I4x4mv>
<I8x8mv>true</I8x8mv>
<P4x4mv>true</P4x4mv>
<AdaptiveDCT>true</AdaptiveDCT>
<SSIMCalculation>false</SSIMCalculation>
<QuantizerMatrix>Flat (none)</QuantizerMatrix>
<QuantizerMatrixType>0</QuantizerMatrixType>
<DeadZoneInter>21</DeadZoneInter>
<DeadZoneIntra>11</DeadZoneIntra>
<OpenGop>False</OpenGop>
<X264PullDown>0</X264PullDown>
<SampleAR>0</SampleAR>
<ColorMatrix>0</ColorMatrix>
<ColorPrim>0</ColorPrim>
<Transfer>0</Transfer>
<AQmode>1</AQmode>
<AQstrength>1.0</AQstrength>
<QPFile />
<Range>auto</Range>
<x264AdvancedSettings>true</x264AdvancedSettings>
<Lookahead>40</Lookahead>
<NoMBTree>true</NoMBTree>
<ThreadInput>true</ThreadInput>
<NoPsy>false</NoPsy>
<Scenecut>true</Scenecut>
<Nalhrd>0</Nalhrd>
<X264Aud>false</X264Aud>
<X264SlowFirstpass>false</X264SlowFirstpass>
<PicStruct>false</PicStruct>
<FakeInterlaced>false</FakeInterlaced>
<NonDeterministic>false</NonDeterministic>
<SlicesNb>0</SlicesNb>
<MaxSliceSyzeBytes>0</MaxSliceSyzeBytes>
<MaxSliceSyzeMBs>0</MaxSliceSyzeMBs>
<Profile>2</Profile>
<Level>migrated</Level>
<AVCLevel>L_40</AVCLevel>
<TuneFastDecode>false</TuneFastDecode>
<TuneZeroLatency>false</TuneZeroLatency>
</Settings>
</GenericProfileOfx264Settings>

Guest
13th July 2013, 22:06
What is your source material?

Half-Light Agent
13th July 2013, 22:15
@neuron:

Source:
General
Unique ID : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Complete name : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Format : Matroska
Format version : Version 1
File size : 2.18 GiB
Duration : 43mn 56s
Overall bit rate : 7 097 Kbps
Encoded date : UTC 2008-12-30 09:31:12
Writing application : mkvmerge v2.4.1 ('Use Me') built on Dec 5 2008 18:30:05
Writing library : libebml v0.7.7 + libmatroska v0.8.1

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings, CABAC : Yes
Format settings, ReFrames : 5 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 43mn 56s
Bit rate : 5 585 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.253
Stream size : 1.67 GiB (77%)
Writing library : x264 core 65 r1063 84a1ca6
Encoding settings : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=7 / psy_rd=1.0:0.0 / mixed_ref=1
/ me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_offset=-2
/ threads=6 / nr=0 / decimate=1 / mbaff=0 / bframes=3 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=1
/ wpredb=1 / keyint=250 / keyint_min=25 / scenecut=40(pre) / rc=2pass / bitrate=5585 / ratetol=1.0
/ qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / pb_ratio=1.30
/ aq=1:1.00
Language : English
Default : Yes
Forced : No

Audio
ID : 2
Format : DTS
Format/Info : Digital Theater Systems
Mode : 16
Format settings, Endianness : Big
Codec ID : A_DTS
Duration : 43mn 56s
Bit rate mode : Constant
Bit rate : 1 509 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 KHz
Bit depth : 24 bits
Compression mode : Lossy
Stream size : 474 MiB (21%)
Default : Yes
Forced : No

Text
ID : 3
Format : UTF-8
Codec ID : S_TEXT/UTF8
Codec ID/Info : UTF-8 Plain Text
Default : No
Forced : No



Encode:
General
Unique ID : XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Complete name : XXXXXXXXXXXXXXXXXXXXXXXXXx
Format : Matroska
Format version : Version 2
File size : 644 MiB
Duration : 43mn 57s
Overall bit rate : 2 048 Kbps
Encoded date : UTC 2013-07-13 03:36:52
Writing application : mkvmerge v6.2.0 ('Promised Land') built on Apr 28 2013 12:22:01
Writing library : libebml v1.3.0 + libmatroska v1.4.0

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.0
Format settings, CABAC : Yes
Format settings, ReFrames : 5 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 43mn 57s
Nominal bit rate : 2 000 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 1778.000
Frame rate mode : Constant
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.091
Writing library : x264 core 133 r2334 a3ac64b
Encoding settings : cabac=1 / ref=5 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=7 / psy=1 / psy_rd=1.00:0.00
/ mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1
/ chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1
/ interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=0 / b_adapt=1 / b_bias=0
/ direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=230 / keyint_min=23 / scenecut=40 / intra_refresh=0
/ rc_lookahead=40 / rc=2pass / mbtree=1 / bitrate=2000 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51
/ qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=25000 / vbv_bufsize=31250 / nal_hrd=none / ip_ratio=1.40
/ aq=1:1.00
Default : Yes
Forced : No

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : HE-AAC / LC
Codec ID : A_AAC
Duration : 43mn 57s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz / 24.0 KHz
Compression mode : Lossy
Delay relative to video : 31ms
Default : Yes
Forced : No

Guest
13th July 2013, 23:02
I am asking you what is the content and where did you get it. If you prefer to answer in PM feel free.

Half-Light Agent
13th July 2013, 23:23
The source is a Blu-Ray rip of a wedding video, obtained from the owner.