Log in

View Full Version : Changing AVC Metadata Without Re-encoding


Richard1485
5th March 2018, 14:00
Is there a way to change the metadata of an AVC elementary stream without re-encoding? For example, it would be useful to be able to slow down a 25p stream encoded with PAFF/MBAFF and flag it as progressive. Of course, eac3to can accomplish the slowdown, but the stream still reads as interlaced. (Changing AR would be another potential use.)

In short, it would be nice to have something that does for AVC what Restream did for MPEG-2. Is this possible? I tried searching for a tool to accomplish this but drew a blank.

Selur
5th March 2018, 20:35
frame rate can be changed with: https://forum.doom9.org/showthread.php?t=152419, no clue about changing interlaced to progressive,..

Richard1485
5th March 2018, 21:41
Thanks! I came across that tool but (like you) saw nothing about changing interlaced to progressive. It does sound useful though. :)

mkver
5th March 2018, 21:47
You don't need that ancient ffmpeg build; ffmpeg now has a bitstream filter h264_metadata for changing AR and framerate.
Regarding flagging from interlaced to progressive: If your stream is MBAFF and uses only progressive encoding (no interlaced macroblocks) -- e.g. if you use x264's fake-interlaced-option, then it should be possible to change the stream to progressive, but there isn't any tool that I know of that does this. If you are really using interlaced encoding (in particular with PAFF), there is no chance to change the bitstream to make it appear progressive. Your best option is to try to signal at the container level that your content is actually progressive.

sneaker_ger
5th March 2018, 22:18
If your stream is MBAFF and uses only progressive encoding (no interlaced macroblocks) -- e.g. if you use x264's fake-interlaced-option
Isn't x264 --fake-interlaced is PAFF?

mkver
6th March 2018, 00:44
I just tested it and it is indeed PAFF with every picture coded as frame. So maybe it is enough to change the frame_mbs_flag to 1, eliminate the mb_adaptive_frame_field_flag, update the pic_height_in_map_units_minus1, update the vertical cropping flags (attention: if frame_mbs_only_flag is set to 0, then the frames will be padded to mod 32, so that when the fake-interlaced is reversed, it may be that one crops 16 or more pixels away vertically; this is not against the H.264 spec, but AFAIK some players don't like it;1080 is well behaved in this regard), update the slice headers (delete the field_pic_flag). For cabac one also needs to ensure the byte alignment condition of the slice data. And of course all of this has to be done on the SODB or RBSP level, not the NAL level. Have I missed something?

SeeMoreDigital
6th March 2018, 10:10
In short, it would be nice to have something that does for AVC what Restream did for MPEG-2. Is this possible? I tried searching for a tool to accomplish this but drew a blank.
Agreed... Such a tool for AVC and even HEVC (with a simple UI) would be most useful :)

kolak
13th March 2018, 11:13
Seeing this I assume it can be done (just a matter of an effort and price):

https://hdr.avtop.com/hdr_solutions_avtop

Richard1485
18th March 2018, 02:18
^Thanks! That's tool looks great but rather expensive.

Is it possible to change scan-type/store-method from separated fields to interleaved fields?

EDIT: Here's a post (https://forum.doom9.org/showthread.php?p=1819151#post1819151) that outlines the difference (though my primary interest in not in decoding, and these are not my files).

EDIT: Is there a free tool that displays detailed information about the stream? MediaInfo has its uses, but the information that it presents is quite limited. Of course, x264-encoded streams contain information about how they were encoded, but this is not the case with all h.264 streams.

sneaker_ger
18th March 2018, 13:18
free: ffmpeg trace_headers bitstream filter (https://ffmpeg.org/ffmpeg-bitstream-filters.html#trace_005fheaders), h264_parse (http://www.w6rz.net/h264_parse.zip); Allegedly buggy, leaving for reference: https://sourceforge.net/projects/h264streamanalysis/
expensive (but with free demos): Zond (https://www.dektec.com/products/applications/Zond/), CodecVisa

Richard1485
18th March 2018, 13:30
^ That's really useful. Thanks!

EDIT: I might as well add links to the other two tools (for future reference).

CodecVisa (http://www.codecian.com)

Zond (http://www.solveigmm.com/en/products/zond/)

mkver
18th March 2018, 16:41
And there is also an ffmpeg bitstream filter for this: trace_headers.