Cut+append HEVC 10-bit introduces glitches, even at keyframes

Started by metal450, June 06, 2020, 06:37:08 PM

Previous topic - Next topic

eumagga0x2a

Quote from: mrtoad883 on December 16, 2020, 11:08:41 AMWith HEVC

No, with any codec. The only special thing regarding H.264 and HEVC is that the standard allows non-IDR frames to be keyframes and this feature is widely used (and even the default for x265 output).

Quote from: mrtoad883 on December 16, 2020, 11:08:41 AMavidemux can only cut on IDR frames without encoding

It can cut on non-IDR keyframes too, but with open GOP some artifacts due to missing reference pictures are often unavoidable.

Please note that starting output in copy mode on a non-IDR keyframe is fine. The problem strikes only when either deleting or pasting within a stream / appending to a stream with cut points placed on non-IDR keyframes.

Quote from: mrtoad883 on December 16, 2020, 11:08:41 AMIs there a way to know where an IDR frame is?

Avidemux actually detects the exact type when checking cut points. It is pretty much pointless to communicate it via GUI beforehand as in many streams captured e.g. from broadcasts, you won't encounter even a single IDR frame.

If you wonder why broadcasters are doing such a cruel thing, the purpose is to reduce bitrate fluctuations while using a bandwidth-constrained medium. You can imagine this as spreading an I-frame over multiple frames, some intra-coded macroblocks in each. An IDR frame has to consist only of intra-coded macroblocks, resulting in a huge bitrate spike or restricting quality.

mrtoad883

Thank you so much for the info, I guess I should've been more specific that I am cutting and appending a video and I need to do it on a closed GOP in order for it not to artifact/get all glitchy. As long as I cut and append on a closed GOP it should be ok?

eumagga0x2a

Just in case: are you aware that Avidemux can copy to internal clipboard and paste from it, not just delete ("cut" = "copy to clipboard" + "delete" in one go)? Sometimes people start fiddling with cutting, saving and appending while the only thing they need is copy & paste.

Do you create (including encoder settings!) videos you append yourself or are they given, out of your control?

If the former, you should disable "Open GOP" in x265 settings, of course (this is the default in latest Avidemux nightlies). You must ensure encoder settings for all videos you are going to append in order to save in copy mode are exactly identical.

If the latter, all that complexity is irrelevant if you re-encode the output instead of using the copy mode.

Quote from: mrtoad883 on December 16, 2020, 10:48:55 PMAs long as I cut and append on a closed GOP it should be ok?

Given that codec settings used to create all appended videos are identical, you should be indeed fine if you cut on IDR frames. Keyframes will be IDR frames if "Open GOP" mode has not been used when creating the source.

mrtoad883

I did not encode the video myself here unfortunately, but this is the mediainfo for one of the two videos (i assume the other one is encoding the same since its from the same person):

Writing library : x265 3.2.1+1-b5c86a64bbbe:[Mac OS X][clang 11.0.3][64 bit] 10bit
Encoding settings : cpuid=1049583 / frame-threads=4 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=3840x2160 / interlace=0 / total-frames=0 / level-idc=51 / high-tier=1 / uhd-bd=0 / ref=4 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-hrd / info / hash=0 / no-temporal-layers / open-gop / min-keyint=24 / keyint=240 / gop-lookahead=0 / bframes=8 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=25 / lookahead-slices=4 / scenecut=40 / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=3 / limit-refs=3 / limit-modes / me=3 / subme=3 / merange=57 / temporal-mvp / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / no-sao / no-sao-non-deblock / rd=4 / selective-sao=0 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=1.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=15.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / vbv-maxrate=160000 / vbv-bufsize=160000 / vbv-init=0.9 / crf-max=0.0 / crf-min=0.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=1 / transfer=1 / colormatrix=1 / chromaloc=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / no-hdr / no-hdr-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=5 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00

not sure if you will be able to tell from this if I can still cut and append on idr frames or not

eumagga0x2a

The stream is encoded with Open GOP enabled (else the settings would contain an entry "no-open-gop"). If the stream hasn't been cut since its creation, the first frame must be an IDR, so that append should be possible when you keep the first GOP of the appended video, even if you save in copy mode.

If you need more freedom for editing, you'll have to re-encode, which will result in loss of bit depth as Avidemux' internal pixel format is YV12 (8-bit planar with 1/4 resolution for chroma).

Quote from: mrtoad883 on December 17, 2020, 02:52:50 PMi assume the other one is encoding the same since its from the same person

Avidemux will warn if there is a mismatch and you are going to save in copy mode.

mrtoad883

Quote from: eumagga0x2a on December 17, 2020, 07:48:09 PMIf the stream hasn't been cut since its creation, the first frame must be an IDR, so that append should be possible when you keep the first GOP of the appended video, even if you save in copy mode.

sorry that part is confusing to me. so only the first frame is an IDR, all the other i frames I wont be able to cut on even if they are closed GOP? there are plenty of i frames that are closed in by P frames on each side. for example lower case will be outside frames, capital will be frame im cutting on.

pIBBPBBBBPBBBBBPPibb

isn't that a closed group which means i should be able to cut on it and merge the other video and still be able to do copy mode?

eumagga0x2a

I-frame followed in stream order by a B-frame = Open GOP. You got it right, the first one is an IDR and usually none thereafter.

mrtoad883

So i wont be able to make multiple cuts throughout? youre saying theres only one IDR in the whole video?

eumagga0x2a

Clean, artifact-less cuts – most likely not.

Quote from: mrtoad883 on December 18, 2020, 12:43:28 AMyoure saying theres only one IDR in the whole video?

Probably, yes.