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

Writegear - use hardware encoder #19

Closed
mj43 opened this issue Jun 4, 2019 · 2 comments
Closed

Writegear - use hardware encoder #19

mj43 opened this issue Jun 4, 2019 · 2 comments
Labels
QUESTION ❓ User asked about the working/usage of VidGear APIs. SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!

Comments

@mj43
Copy link

mj43 commented Jun 4, 2019

Writegear uses libx264 or libx265 encoders. Is it possible to make use of existing hardware encoders - for example on an Intel CPU the h264_vaapi encoder. I ask as using libx264 my CPU is saturating and the output video is dropping frames. In tests I have done outside of Writegear, using the h264_vaapi encoder significantly reduces the CPU load.

@abhiTronix abhiTronix added the QUESTION ❓ User asked about the working/usage of VidGear APIs. label Jun 4, 2019
@abhiTronix
Copy link
Owner

abhiTronix commented Jun 4, 2019

@mj43

Writegear uses libx264 or libx265 encoders.

That's incorrect, WriteGear DOES NOT exclusively use libx264 or libx265 encoders, but only use them as fallback encoders when no -vcodec parameter is passed in output_param dict.

Is it possible to make use of existing hardware encoders - for example on an Intel CPU the h264_vaapi encoder.

(The solution is in docs, kindly refer it for more details.)

How to change Output Codec?

Changing codec is a piece of cake in VidGear, just pass the encoder -vcodec:h264_vaapi in output_param dict in WriteGear class. Also you can specify the device/harware to be used with '-vaapi_device':'/dev/dri/renderD128'or other features such as '-vf':'format=nv12,hwupload' in output_param dict. You can easily find such options in FFmpeg docs with a little bit of googling._ But first remember to check if your FFmpeg supports VAAPI encoders as below.

Important ⚠️

Kindly first confirm that your FFmpeg supports VAAPI encoders, with command as follows:

ffmpeg  -hide_banner -encoders | grep vaapi 

 V..... h264_vaapi           H.264/AVC (VAAPI) (codec h264)
 V..... hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)
 V..... mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
 V..... mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
 V..... vp8_vaapi            VP8 (VAAPI) (codec vp8)

💡 Finally, Remember You can alter almost any parameter that is supported by FFmpeg itself with VidGear library!

@mj43
Copy link
Author

mj43 commented Jun 4, 2019

Many thanks for this guidance.

@mj43 mj43 closed this as completed Jun 4, 2019
@abhiTronix abhiTronix added the SOLVED 🏁 This issue/PR is resolved now. Goal Achieved! label Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QUESTION ❓ User asked about the working/usage of VidGear APIs. SOLVED 🏁 This issue/PR is resolved now. Goal Achieved!
Projects
None yet
Development

No branches or pull requests

2 participants