-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: AV1 encodes which require using alignment mode 1080p
or unrestricted
don't signal the correct resolution
#423
Comments
ref: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9185 an AMD staff said:
It looks like it's a hardware issue, There's very little AMF can do. |
Yes, this Wiki describes the behavior and mitigation: https://github.com/GPUOpen-LibrariesAndSDKs/AMF/wiki/AV1%20Encoder#av1-specific-api |
I noticed that there is some new code in Mesa repository about rdna 3.5 (gfx11.5) in the Linux kernel, will this issue be fixed in rdna 3.5? |
Cannot comment on unreleased HW or SW, sorry. |
Hmm... For me Adrenaline software (7800XT) records not 1920*1082 for AV1, but 1920x1088 instead. And 1082 cannot even be aligned to x16 as 1082/16=67.625, while 1088/16=68. I also just tested ways to not fix, but at least make result more... compatible with sources like players or YouTube for example in terms of their interpretation of source. So... Maybe it is possible to add metadata compatability trick to compensate for HW issue? Here is example: Sadly, using container level crop doesn't work, but for some reason forced aspect ratio does? Small UPD: Container level crop seems to be working, but you MUST specify resolution too, for some reason. Container crop + forced 1920x1080 - https://drive.google.com/file/d/1YX4I4sHLQO_t_msfhOU7baM-ow59iKtA/view?usp=sharing Also, based on YouTube sample and amount of pixels left with force 16:9 and crop and force 1920x1080, forcing aspect ration if overall better, unless i cropped wrong row. Simply because under row of quick slots gap between numbers and end of frame is noticeably smaller in crop+force resolution sample compared to force aspect ratio. |
|
[AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_NO_RESTRICTIONS, videos with any resolution can be coded. However, for those videos whose resolution is not 64x16 aligned, their output resolution will be extrapolated to be 64x16 aligned and padded with black pixels. The exception is for resolution of 1080p, which will be padded to 1082p, as in the case of MODE 2.]
P.S. Ah yeah, also a question. Where are these 2 or 8 row of pixels are being added relative to video? Should be at bottom but by cutting bottom 8 rows i lost part of real video it seems, and not filled data. Unless container cut didn't apply at all, and fixed resolution just worked this way unlike aspect ratio one? Congratulations with upcoming New Year! |
#2 in NO_RESTRICTIONS mode ask for 1080 will generate 1082, ask for 1088 will generate 1088. ReLive implemented the latter. The black rows from 2 to 8 are added at the bottom of the frame. Ideally, you don't need to play with aspect ratio. If reading app respects container cropping, it should just cut these lines. |
Thanks for answer! |
#2 - this was ReLive team design choice. |
Has the patch been updated? Or Could you tell me when it will be updated? |
Well, there was some work done in ffmpeg patch history https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=9848 |
We tested the Nvenc AV1 encoder, QuickSync AV1 encoder and AMD AV1 encoder. According to our tests, Nvenc and QuickSync work properly with 1920x1080 resolution with no padding. AV1 headers indicate the correct 1920x1080 size (FrameWidth/FrameHeight, RenderWidth/RenderHeight, max frame width/height fields) in both cases.
|
Recently FFmpeg added generic way to propagate crop info and implemented the support in some containers. |
Thanks, i tried to write long answer, but in process of on confirming information you answered first.
But RTMP by itself is a protocol, not container. It should teoretically pass container metadata with packets. Question is, will RTMP even support passing AV1 stream properly? Answer for that is... I don't really know... There is this project: https://github.com/veovera/enhanced-rtmp But i don't really know if it can do that. Well, i checked VCEEncC quick reencode of FLV source into AV1 1080 (1082p) FLV output, and it does show me 1080p in MediaInfo. I even exxagerated and encoded 1858*1074 video (aka still 1920x1088)... This time it encoded in 1088p, as override only applies to 1080 height. On other hand it shows me original resolution in decoder information (and 1920x1088 for exxagerated sample):
I am waiting for an hour for YouTube to process these 2.5 minute long FLV video samples. . . Because i really want to know where YouTube looks when processing them. I know for a fact that more than year ago, YouTube would reencode 1920x1082 down to 1916x1080 or so. Players ignored MediaInfo with intended resolution and played output with padding because within codec resolution had been reported as aligned. Which is probably worst part of this fiasco, i think. I guess i can update this comment when it will be finished... Sheesh Btw @MikhailAMD as this is unexpectedly fitting topic and i had this question for a while... Is there particular reason why padding of misaligned AV1 video by width to the right starts with green pixels, transitiniong to black? |
It should be black. Could you please share the stream? |
Stream in what manner? Bitstream of frame? I can try to check it, but i won't know what to look at, sorry. Here is encoded sample. Hmm, let me try TranscodeHW, just in case. But i did use AMF_FSR scalar this time. Big_Buck_Bunny_1080_10s_10MB_processed.mp4Yup, can confirm same with TranscodeHW: |
I meant output video. But I can repro with your command line. Will file an internal ticket. |
Describe the bug
It seems that when using the
AMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE
set toAMF_VIDEO_ENCODER_AV1_ALIGNMENT_MODE_NO_RESTRICTIONS
, the video is extended by adding rows/columns of black pixels to fit into a whole number of transforms. However, the height and width signalled in the Sequence Header OBU is set to the extended resolution rather than the original height/width. This means that when a video is encoded using a non-64x16 alignment and then decoded, it will feature a black strip at the edge of the video at some resolutions (for example 1920x1080, 960x540, 320x180 etc). Instead the Sequence Header OBU should signal the original resolution so that the frame is cropped appropriately to avoid the black edges being displayed. It is also important that the original resolution is signalled because some applications require that the original input resolution is maintained in the output.To Reproduce
Steps to reproduce the behavior:
Setup (please complete the following information):
Debug Log (please upload or paste):
Attached here
Expected behavior
The output video has resolution 320x180 (the same as the input video). No black edge extension is visible while playing the output video.
Additional context
Note a similar effect occurs when using the
64x16A1080P
alignment mode one 1080p video. In that case, the video is extended to 1920x1082 and a similar 2-pixel tall row of black pixels is added to the bottom of the video.The text was updated successfully, but these errors were encountered: