x265 - Cut points could not be checked?

Started by diego_mux, October 24, 2020, 02:33:01 AM

Previous topic - Next topic

diego_mux

Avidemux 2.7.6 on Windows 10. I'm having an issue trying to cut any and all videos that I generate with ffmpeg version 4.3.1 and libx265. It seems that, for all such videos, no matter which keyframes I choose for the cut, I always get the dialog box "Cut points could not be checked...".

If I go ahead and cut and then save using "copy" for output, the resulting video seems to playback smoothly, without any issues at the cut points. So... why am I getting the above message every time?

I think this issue may be related to the following item from the release notes:

* New Feature:Detect and warn when cut points in HEVC video streams may result in grave playback issues despite being on keyframes

If that's the case, then I'm wondering - what are the "grave playback issues despite being on keyframes" being referred? Is there something I need to do in ffmpeg in order to avoid the warning in Avidemux? My ffmpeg command line is very simple - I pretty much just select the libx265 codec and disable audio (-an).

Also, at the time I get the dialog box from Avidemux, it logs the following to admlog.txt:

[extractH265FrameType] 02:37:15-705 Zero length NAL unit?
[ADM_Composer::checkSegmentStartsOnIntra] 02:37:15-705 Cannot get HEVC frame type and Picture Order Count value.

I can reproduce the issue at will - all I have to do is encode any video in ffmpeg with libx265 and .mkv and then try to cut the file in Avidemux at any keyframes.

eumagga0x2a

Quote from: diego_mux on October 24, 2020, 02:33:01 AM[extractH265FrameType] 02:37:15-705 Zero length NAL unit?

We were getting the NAL length size from codec extradata with the output of the recent libx265 wrong (it worked by accident with older versions), should be fixed in future nightlies by [coreUtils/infoExtractorH265] Fix HEVC extradata offset to get valid NAL length size.

Quote from: diego_mux on October 24, 2020, 02:33:01 AMwhat are the "grave playback issues despite being on keyframes" being referred?

If open GOP is used (default with libx265), the picture order count (POC) of all frames after the cut point must be greater than before, else FFmpeg-based players will drop all frames until POC increases as expected. This is libavcodec-specific and as such also totally valid, but other implementations do users a favour by detecting POC discontinuity and resetting MCO (memory control operations).

Quote from: diego_mux on October 24, 2020, 02:33:01 AMIs there something I need to do in ffmpeg in order to avoid the warning in Avidemux?

If you want to cut in copy mode, you really should disable open GOP in libx265 ("--no-open-gop" x265 option). This is not related to the particular bug in Avidemux, but it is the only way to get fully valid (without a few damaged pictures after the cut due to missing references) HEVC or H.264 streams after editing.

Thank you for your report.

diego_mux

Quote from: eumagga0x2a on October 24, 2020, 08:27:27 AMThank you for your report.

Thank you for the informative response! So basically, all I need to do is to disable open GOP in my x265 encodes. And as for the issue with the dialog box being raised by Avidemux, it's a bug which is going to be fixed in a future release of Avidemux, and not an indication of a problem with my files, right?

eumagga0x2a

Quote from: diego_mux on October 25, 2020, 08:47:34 PMAnd as for the issue with the dialog box being raised by Avidemux, it's a bug which is going to be fixed in a future release of Avidemux, and not an indication of a problem with my files, right?

The bug is fixed (fixed in code), there just haven't been any official nightlies which include this change as of this writing yet. You can build Avidemux from source on Linux for Windows yourself anytime (either installed in a virtual machine or on bare metal for more comfort and speed) and have a working tool instantly. Future releases will include the fix too, of course.