Log in

View Full Version : Adding Aspect Ratio-Flag to H264-RAW-Streams


LessThanJake
8th September 2008, 01:30
Hi,

when creating H264-streams with x264 and anamoprhic settings such as --sar 16:11 there will be AR-Information present in the bitstream after encoding.

aspect_ratio_info_present_flag: 1
aspect_ratio_idc:4 (--sar 16:11)

Without using "-engage keep_bitstream_ar_info", when muxing with mkvmerge this info will be removed from the bitstream but sets it into the Container.

So, is there a little tool existing, that can add the ar-information back into the stream?

greets
LTJ

Kurtnoise
8th September 2008, 09:07
h264info (https://sourceforge.net/project/showfiles.php?group_id=138139&package_id=225029)...

LessThanJake
8th September 2008, 14:35
I already tested this tool before posting here.
Unfortunately this tool does its job not correct.
After patching the Stream the AR is correct, but playing the File with mpc+ffdshow, VLC, mplayer as RAW and muxed to MKV with -engage keep_bitstream_ar_info, results in grey frames combined with macroblock-salad.
H264Info changes something in the bitstream, but doesnīt add the correct entry into the SPS-NALU as posted above.

Iīm wondering a little bit that there is no real solution for this, I am already looking for such a tool for a while.

For a good C++ programmer it should be no problem to write a little tool that offers the ability to add / remove these little VUI-Parameters. As far as I know, decoding the SPS-NALU is not very hard. There are only signed and unsigned integer and a few Exp-Golomb coded bits.
Donīt get me wrong, I would do this by myself, but I would need weeks, perhaps month, with my extremly bad C++ - knowledge :(.

greets
LTJ

Kurtnoise
8th September 2008, 16:44
remux your stream with MP4box first to create a mp4. This tool is able to specify par value via command line. Then, remux it to mkv with mmg...

LessThanJake
8th September 2008, 19:07
This way everything works correct.
Thank you. :)

greets
LTJ