Skip to content
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

Control over bitrate budget with variable frame rate #191

Closed
roman380 opened this issue Nov 6, 2019 · 3 comments

Comments

@roman380
Copy link

@roman380 roman380 commented Nov 6, 2019

We are typically using H.264 encoder in AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR mode with setup including specific resolution, frame rate, target bitrate.

During encoding it might so happen that some input frames are not available (skipped), including for good reason. I am under impression that encoder is unable to take into account the missed frame in the part of updating bitrate budget. For example, if I skip every second input frame, output bitstream is generally valid (playable) but its bitrate is less than half of target bitrate per second. There is no specific ratio but it is clear that target bitrate is dramatically underused. Even worse, at low bitrate settings output quality is extremely poor even with such bitrate headspace.

It does not seem to help to set SetPts correctly so that it could indicate a frame skip. PTS/duration values have seemingly transparent meaning - just to get passed to output interface without interpretation.

I would appreciate some advice on how to address frame skipping and use the target bitrate budget as bits per second rather than bits per fps number of frames.

@roman380

This comment has been minimized.

Copy link
Author

@roman380 roman380 commented Nov 6, 2019

Going over properties, I stumbled on AMF_VIDEO_ENCODER_RATE_CONTROL_SKIP_FRAME_ENABLE which sounds as possibly relevant, even though I think it's not. A comment on its effect would also be appreciated as documentation is not too generous.

Do I understand it correctly that it lets encoder to skip input frame (accept input and not produce output) in the case of, for example, encoder panic and its going rather low on budget during encoding?

@MikhailAMD

This comment has been minimized.

Copy link
Contributor

@MikhailAMD MikhailAMD commented Nov 6, 2019

SKIP_FRAME_ENABLE option enables rate control to insert SKIP frame if VBV buffer is almost full.
AMF encoder doesn't check PTS for encoding. In a sense it is not a real-time object but a library that tries to encode as fast as possible. The frame rate parameter is used for rate control only.
If your app skips a frame, then rate control will not know about it and will treat the following frame as the next one. One way to avoid rate control issues is to repeat previous frame. Then encoder will detect a lot of similarities and provide a good compression without bit rate confusion.

@roman380

This comment has been minimized.

Copy link
Author

@roman380 roman380 commented Nov 6, 2019

I used to repeat input frames and generally it used to work well in terms of bitrate control and otherwise, however it was my intent to reduce load on the encoder and avoid input duplication when it is not needed. We also take advantage, in a special way, of the frame skips on the decoding side. Repetitions would force to produce full rate instead.

Thank you for the quick feedback nonetheless.

@roman380 roman380 closed this Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.