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

add other hardware support #5

Closed
bmegli opened this issue Jan 29, 2019 · 7 comments
Closed

add other hardware support #5

bmegli opened this issue Jan 29, 2019 · 7 comments
Labels
enhancement New feature or request

Comments

@bmegli
Copy link
Owner

bmegli commented Jan 29, 2019

Adding other hardware support should be rather easy but this needs:

  • using correct encoder
  • using correct pixel format for hardware

This is simpler in FFmpeg 4.0 and later.

I don't really need this future so this is distant future (if ever)

@bmegli bmegli added the enhancement New feature or request label Jan 29, 2019
@bmegli
Copy link
Owner Author

bmegli commented Feb 3, 2019

This was already implemented in HVD so just copy the relevant section(s) of code

@bmegli
Copy link
Owner Author

bmegli commented Feb 4, 2019

Some conclusions after quick implementation trial with FFmpeg:

  • this is not so easy
  • the situation is not symmetric to the one with decoders
  • there are different levels of hardware acceleration api support in FFmpeg
    • what we use in HVD for vaapi, vdpau, dxva2, d3d11, videotoolbox is internal type
    • there is no internal support for encoders, there's only standalone

It seems that for the standalone encoders:

  • you can't initialize hardware for particular codec like h264
  • you have to use full codec+hardware like "h264_vaapi", "h264_nvenc" (mingled hardware and codec ready solution)

It is definitely doable in a clumsy hacky way with heuristics:

  • concatenate the hardware and codec string
  • try to find AVCodec by concatenated name
  • have a pixel format association table for the hardware

I don't really like the above solution.

What I really need is VAAPI so this issue is put for later (if ever)

@bmegli
Copy link
Owner Author

bmegli commented Feb 4, 2019

Hack for anybody who needs other hardware.

Know your hardware and check what FFmpeg supports with

ffmpeg -codecs

Or grep by hardware type:

ffmpeg -codecs | grep vaapi
ffmpeg -codecs | grep nvenc
ffmpeg -codecs | grep omx
# ...

Identify the hardware codec you would like to use and:

  • change the "h264_vaapi" in hve.c to your desired codec
  • change the pixel format used for hardware (AV_PIX_FMT_VAAPI) to match your hardware
  • try it out
  • if it breaks fix it (e.g., adjust software pixel format to whatever you hardware accepts)

@bmegli
Copy link
Owner Author

bmegli commented Feb 4, 2019

You can get some idea which format to use with:

ffmpeg -pix_fmts

Look for the ones described with H - Hardware Accelerated Format

@bmegli
Copy link
Owner Author

bmegli commented Dec 30, 2019

After making encoder configurable in ac3a4c1 the only things holding support for other hardware seem to be:

What I need is VAAPI, so I am not going to touch it right now.

If anybody needs other hardware support those are the lines to hack.

bmegli added a commit that referenced this issue Apr 10, 2020
- extend hardware config with input_width, input_height fields
- if specified and different from width/height perform hardware accelerated scaling before encoding
- update examples
- update docs
- update readme

Adds dependency on libavfilter.

Closes #24
Makes #5 more complex
Indirectly related to #25
Indirectly related to #6
@bmegli bmegli mentioned this issue Jan 10, 2023
@bmegli
Copy link
Owner Author

bmegli commented Jan 10, 2023

In #32 library was generalized to support also Nvidia NVENC

Generalizing for more hardware should be even easier now.

@bmegli
Copy link
Owner Author

bmegli commented Mar 15, 2023

Generally Intel, AMD, Nvidia and Nvidia jetson work but may have their quirks

See:

@bmegli bmegli closed this as completed Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant