FFmpeg av1_nvenc encoder sometimes generates undecodeable bitstreams

Summary of the bug: av1_nvenc output with some inputs will occasionally produce unplayable files. Attached files result in latest stable VLC decoding blocks, but not any frames. Windows’s built-in Media Player plays back sample fine, but with full file as input, audio in output file will not be played back in Media Player but video will, while VLC will play audio but not video.

comment:13 by Timo R.

It instead writes a HEVC time_code SEI message into the AV1 bitstream.
So something is definitely messed up there in the driver.

FFmpeg developer believe this is a driver issue and need to report it to NVIDIA. Therefore, I’m forwarding this issue here, which includes steps to reproduce the problem and samples. Hopefully, some NVIDIA developers will take a look at it.

Hi @nyanmisaka, thank you for bringing this to our attention. I will keep you update of our progress on this issue.

Hi @nyanmisaka,

Thank you again for the report and samples. After further investigation, this appears to involve two separate issues.

  1. The case where a HEVC time_code() SEI message is written into an AV1 bitstream is an FFmpeg-side bug, not a driver bug. For AV1, FFmpeg needs to emit the proper AV1 timecode metadata payload instead of HEVC SEI syntax.

  2. There is also a separate NVIDIA driver issue in the AV1 metadata OBU path. The current implementation assumes the supplied AV1 metadata payload is always byte-aligned and appends a fixed 0x80 trailing byte. That assumption is not valid for all conformant AV1 metadata payloads, since AV1 trailing_bits() depends on the actual payload bit length, not only the byte length.

A current workaround for this reproducer is to disable S12M timecode insertion, which avoids the problematic metadata path:

./ffmpeg -i ./test_input.mkv -c:v av1_nvenc -s12m_tc 0 av1_nvenc.mkv

With -s12m_tc 0, the issue is avoided for this case.

So there are two distinct problems here: one on the FFmpeg side and one on the driver side.

We at NVIDIA are working on a proper solution for the driver-side issue.

Thanks again for helping surface this.

Thank you for your investigation. I saw in another thread that 610.xx driver includes some encoder fixes. Do they help with issue 2 here? Also, has the fix for issue 1 been added to ffmpeg?

Hi @nyanmisaka, no, the current version of the 610 driver does not fix issue 2. We are still working on how to properly solve it. If the solution demands an API change, it might be available only in the next Video Codec SDK. I will keep you posted.