-
Notifications
You must be signed in to change notification settings - Fork 6
interfaces for decoder fallback, encoder avoids cuda and vaapi hard coding, improved flush #5
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
Conversation
…aapi hard coding, improved flush
9832669 to
c9dfc79
Compare
hidmic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass. Mostly stylistic. Functionally looks correct.
I'll test it locally.
|
Thanks for looking over the PR! |
928f92a to
782d60a
Compare
782d60a to
5eed638
Compare
src/encoder.cpp
Outdated
| frames_ctx->format = utils::find_hw_config(&usesHardwareFrames_, hwDevType, codec); | ||
|
|
||
| if (usesHardwareFrames_) { | ||
| const auto fmts = utils::get_hwframe_transfer_formats(hw_frames_ref); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@berndpfrommer I finally got around to try this on a machine with an RTX 4090. It failed with "cannot find valid sw pixel format!" when trying to encode images using hevc_nvenc.
After some digging, I think the problem may be in how we look for supported pixel formats. utils::get_hwframe_transfer_formats() hits av_hwframe_transfer_get_formats(). When frames_ctx->format is cuda, there are no transfer formats available (see https://ffmpeg.org/doxygen/trunk/hwcontext__cuda_8c_source.html#l00216). IIUC what goes in goes out (see https://ffmpeg.org/pipermail/libav-user/2018-June/011179.html).
I believe we should be using av_hwdevice_get_hwframe_constraints() to fetch the set of supported pixel formats, but don't quote me on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am able to replicate the issue.
The old code only used hardware frames from vaapi, not for cuda, and it worked. Somehow although nvenc is hardware accelerated, it does not use hardware frames, or open a hardware device. Apparently, no call to av_hwdevice_ctx_create() is necessary for nvenc.
What I don't know is when to use hw frames and when not, and I want to avoid hardcoding "vaapi" as it was before. I'm looking for any flags or other indicators that would tell when to use hwframes.
|
@hidmic I have found a way to tell hevc_nvenc apart from hevc_vaapi by looking at the the hardware formats to transfer TO (rather than FROM). In the case of nvenc one does not even have to open a hardware device. Apparently this is handled internally by the nvenc library. |
|
I have more changes coming. The subject of image formats is really tricky. |
Wonderful. I'll give it a shot.
Understood, but won't this be a blocker for releasing this package against existing LTS distributions?
That sounds reasonable, but do note that |
I really don't know in how far the policies apply only to core ros packages (like rclcpp) or if they apply to all packages. For my packages I usually just bump the major version and release them. The user base is small, and the packages are not mature. If I stuck to the official core policy my humble/jazzy packages would be hopelessly outdated. So far nobody has screamed at me for modifying my APIs on LTS distros.
|
|
I can confirm encoding using On what distro are you testing this @berndpfrommer ? |
|
I'm developing on rolling. |
|
I have successfully tested this PR now under vaapi and nvenc. Merging it into master and will be releasing it on Rolling. |
|
Ah, you beat me to it @berndpfrommer. Working through a long backlog, didn't get back here in time. Sorry for that, and thank you for pushing! What about the |
This PR covers several changes that aim at making the encoder and decoder more generally useful.