voelin-media: HEVC and AV1 levels and tiers that count the frame rate
VA-API's HEVC and AV1 encoders guessed their level themselves: FFmpeg's AV1 guess reads the frame rate from `AVCodecContext.framerate`, which has no AVOption and so was never set, and its HEVC guess ignores the rate. A 4K240 stream declared a level for 4K60, which a decoder that sizes itself from the level may refuse. The encoder now sets the level and tier from the stream's size, frame rate and bitrate (H.265 Table A.8, AV1 A.3): the lowest level whose Main tier holds the bitrate, else the lowest whose High tier does, else no limits (HEVC 8.5, AV1 level 31) as FFmpeg does. 4K60 at 60 Mbit/s is 5.2 Main, 4K240 and 8K60 6.1. Only for VA-API, whose options take `general_level_idc` and `seq_level_idx`; other wrappers count levels differently. The rate-control buffer is clamped to what its int holds, so a typed bitrate above 1 Gbit/s no longer fails the open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
475122c2a6
commit
12e62522ce
2 files changed
+156
-1
No files matched your search
@@ -477,6 +477,18 @@ the software encoders above are used as before.
|
||||
implementations conventionally do, `h264_vaapi` and `h264_amf` emit `0c`
|
||||
for the former and `libx264` emits `00`, and all three emit `40` or `c0`
|
||||
for the latter. Those bits do not change what a decoder can decode.
|
||||
- HEVC and AV1 levels (VA-API): the level and tier the stream needs, from
|
||||
its size, frame rate and bitrate (H.265 Table A.8, AV1 A.3): the lowest
|
||||
level whose Main tier holds the bitrate, else the lowest whose High tier
|
||||
does, else 8.5 / level 31 (no limits). FFmpeg's own guess counts neither
|
||||
the frame rate (AV1 reads `AVCodecContext.framerate`, which has no
|
||||
AVOption; HEVC ignores it) nor, at a given level, a higher tier, so a
|
||||
4K240 stream declared a 4K60 level. Now 4K60 at 60 Mbit/s is HEVC 5.2 /
|
||||
AV1 5.2 Main, 4K240 6.1, 8K30/60/120 HEVC 6/6.1/6.2; more than 300 fps
|
||||
is beyond every AV1 level (300 frame headers a second). Other wrappers
|
||||
count levels differently (Quick Sync in tenths) and keep choosing their
|
||||
own. The rate-control buffer (`bufsize`, an int) stays at the 2^31-1
|
||||
bits it holds from 1 Gbit/s on instead of failing the open.
|
||||
- Runtime changes: x264, NVENC and Quick Sync take bitrate changes on the
|
||||
running encoder (FFmpeg's wrappers compare `b` / `maxrate` / `bufsize`
|
||||
before each frame); the others reopen at the next keyframe, at once
|
||||
|
||||
Reference in new issue
Block a user