e00E / obs-amf

GNU General Public License v2.0
90 stars 13 forks source link

No H264/AVC B-frame options in latest 0.2.0 release #16

Open cs9kc opened 2 years ago

cs9kc commented 2 years ago

Hello! Thank you so much for updating your plugin to the latest version of AMF!

I see in your code that you do have some information about B-frames already inserted, but the code is currently commented out. If you have the time, could I request that you enable control of B-Frames and their associated parameters, please?

Thank you so much for your hard work!

e00E commented 2 years ago

It is helpful to know that people actively want to use these options. I'm curious, could you tell me why they are important?

For context, the comment you are referring to is probably https://github.com/e00E/obs-amf/blob/4df64931216a5d39b30160a15856f1c15c5a6a15/source/encoder_avc.cpp#L152 .

cs9kc commented 2 years ago

That is the line I was referring to, yes!

I would like use of B-Frames as they use less bitrate pr-frame than P-frames, which gives each GOP more overall bitrate use on P frames, as well as use on reference P and B frames. Likewise, B-frames, in combination with other encoder features that help distribute bitrate over a GOP, benefit from needing to use less of the GOP's bitrate on B-frames.

TL;DR: B-frames are important when streaming and/or recording at low bitrates; streaming to Twitch, for example.

e00E commented 2 years ago

I think b frames already enabled even without manually setting those settings.

cs9kc commented 2 years ago

I think b frames already enabled even without manually setting those settings.

When using the Transcoding preset, as your plugin does, B-frames should be enabled by default, but no combination of settings over about 2 hours of testing could provoke the GPU into using B-frames, using OBS Studio 27.2.3 and the latest build of your plugin, with new AMD Radeon drivers.

I read through the AMF AVC encoder documentation several times trying what appeared to be proper combinations of...

sigh I think I am an idiot sandwich. In being distracted during the making of the post above, I went back and re-read the release notes from AMF Release 1.4.24. The comment about B-frames reads "Support for consecutive B-frames and adaptive miniGOP for AVC Encoder". I think I read what I wanted to, and did not read what was actually stated.

I do not believe Navi 1x/2x have B-frame support with AVC yet. My apologies.

cs9kc commented 2 years ago

I am going to re-open this ticket, as B-frames are available on RDNA2 GPU's

It appears that I was right to begin with, from the AMD AMF github:

image

e00E commented 2 years ago

Like I wrote in my previous post I still think that b frames are already being used. The commented out part merely allows extra configuration of b frames. It does not disable b frames. A definitive test could be done by analyzing a recording with a tool that can output frame information like ffmpeg.

We can keep this issue open because it would still be nice to enable the configuration.

cs9kc commented 2 years ago

I did spend a few hours before I submitted this ticket, using your 0.2.0 plugin version with the latest OBS Studio, trying to provoke H264 to use B-frames. I used the following command on each recording (the same I used to monitor B-Frames with Nvidia) to no avail:

ffprobe -show_frames -show_entries frame=pict_type "InputFile".mkv > outputfile.txt

The only thing I could think of, was an old rumor that previous generation AMD GPU's only used B-frames with CQP, but I could not find any documentation on that comment specifically, nor could I provoke my RX 6900 XT into using B-frames with any combination of rate control, based on settings from AMD's documentation that should allow the encoder to use B-frames.

I can give it another try today and see what results I come up with.

e00E commented 2 years ago

If you have already tested it then you don't need to again. I can try the same command.

cs9kc commented 2 years ago

I think, as a test, if you added the following into your plugin, hopefully this may nudge the encoder to use B-frames, since it does not do so by default. (I did run more tests last night, to no avail)

Line 157: AMF_VIDEO_ENCODER_MAX_CONSECUTIVE_BPICTURES L"MaxConsecutiveBPictures" // amf_int64; Maximum number of consecutive B Pictures

From: https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/public/include/components/VideoEncoderVCE.h

macchky commented 2 years ago

I think, as a test, if you added the following into your plugin, hopefully this may nudge the encoder to use B-frames, since it does not do so by default. (I did run more tests last night, to no avail)

Line 157: AMF_VIDEO_ENCODER_MAX_CONSECUTIVE_BPICTURES L"MaxConsecutiveBPictures" // amf_int64; Maximum number of consecutive B Pictures

From: https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/public/include/components/VideoEncoderVCE.h

@e00E @cs9kc This is new option for b-frame for Newer GPU. As @e00E mentioned first, comented AMF_VIDEO_ENCODER_B_PIC_PATTERN option is for OLDER Radeon GPU like HD7000 series(has b-frame capable) As long as I remenber, I can encode with b-frame when I used HD7850.

I tested self compiled FFMPEG without AMF_VIDEO_ENCODER_MAX_CONSECUTIVE_BPICTURES option only with latest AMF on 6700XT, but no b-frame.

So we can not encode with b-frame as long as we can set AMF_VIDEO_ENCODER_MAX_CONSECUTIVE_BPICTURES.

cs9kc commented 2 years ago

I tested self compiled FFMPEG without AMF_VIDEO_ENCODER_MAX_CONSECUTIVE_BPICTURES option only with latest AMF on 6700XT, but no b-frame.

You can certainly build ffmpeg with the latest AMF package, but the rest of the code in ffmpeg itself is not set up to interface with the new options in the latest AMF version. With RDNA/2 GPU's, b-frames almost certainly do not and will not work with ffmpeg-based encoding until AMD's AMF team work with ffmpeg to get the program itself updated to interface properly with the latest AMF version.