[Question]: How to set hwaccel to StreamGear for utilizing GPU, Using the option ?
PraveenSuryawanshi-Dev opened this issue · 2 comments
PraveenSuryawanshi-Dev commented
Issue guidelines
- I've read the Issue Guidelines and wholeheartedly agree.
Issue Checklist
- I have searched open or closed issues for my problem and found nothing related or helpful.
- I have read the Documentation and found nothing related to my problem.
- I have gone through the Bonus Examples and FAQs and found nothing related or helpful.
Describe your Question
"-hwaccel auto" before the inputs (-i ) tries to use hardware accelerated but when applied stream_params goes in last which makes problem for ffmpeg and does not utilize GPU.
Terminal log output(Optional)
fmpeg.exe', '-y', '-i', 'sample-mp4-file-small.mp4', '-vcodec', 'libx264', '-vf', 'format=yuv420p', '-aspect', '4:3', '-crf', '20', '-tune', 'zerolatency', '-preset', 'veryfast', '-acodec', 'copy', '-map', '0', '-s:v:0', '320x240', '-b:v:0', '115k', '-b:a:0', '128k', '-map', '0', '-s:v:1', '640x480', '-b:v:1', '500k', '-b:a:1', '96k', '-map', '0', '-s:v:2', '1280x720', '-b:v:2', '500k', '-b:a:2', '128k', '-map', '0', '-s:v:3', '1920x1080', '-b:v:3', '500k', '-b:a:3', '128k', '-bf', '1', '-sc_threshold', '0', '-keyint_min', '30', '-g', '30', '-seg_duration', '5', '-use_timeline', '1', '-use_template', '1', '-adaptation_sets', 'id=0,streams=v id=1,streams=a', '-f', 'dash', '-hwaccel', 'auto', 'dash_out.mpd'
Python Code(Optional)
# Activate Single-Source Mode with valid video input
stream_params = {
"-hwaccel": "auto",
"-video_source": video_src,
# "-livestream": True,
"-streams": [
{"-resolution": "640x480", "-video_bitrate": "500k"},
{"-resolution": "1280x720", "-video_bitrate": "500k"},
{"-resolution": "1920x1080", "-video_bitrate": "500k"},
],
}
# describe a suitable manifest-file location/name and assign params
streamer = StreamGear(
output=save_path, format="dash", logging=True, **stream_params
)
# trancode source
streamer.transcode_source()
# terminate
streamer.terminate()
VidGear Version
0.3.0
Python version
3.9.12
Operating System version
Windows 10 x64
Any other Relevant Information?
No response
welcome commented
Thanks for opening this issue, a maintainer will get back to you shortly!
In the meantime:
- Read our Issue Guidelines, and update your issue accordingly. Please note that your issue will be fixed much faster if you spend about half an hour preparing it, including the exact reproduction steps and a demo.
- Go comprehensively through our dedicated FAQ & Troubleshooting section.
- For any quick questions and typos, please refrain from opening an issue, as you can reach us on Gitter community channel.
abhiTronix commented
@PraveenSuryawanshi-Dev Actually, -hwaccel auto
is a flag for decoder not for encoder, and StreamGear is a encoder API. Use hardware accelerated FFmpeg encoders like CUDA's NVENC
instead with StreamGear API. Here's a example: https://abhitronix.github.io/vidgear/latest/gears/streamgear/rtfm/usage/#usage-with-hardware-video-encoder