-
Notifications
You must be signed in to change notification settings - Fork 576
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
Implement hardware acceleration #412
base: integration
Are you sure you want to change the base?
Conversation
Managed to get full transcoding working. It doesn't provide as much of a speed up as accelerated encoding and decoding, but for long videos it'll definitely be super useful. |
BenchmarksNote: when writing CommandsInstead of modifying the program and testing every single time, I modified the effective ffmpeg command used, and implemented my modifications after getting everything working. These following commands are executed for the Acceleration offThis is used by FileConverter by default. ffmpeg.exe -y -stats -i "input.mp4" -c:v libx264 -preset medium -crf 31 -c:a aac -qscale:a 0.75 -vf "scale=trunc(iw*1/2)*2:trunc(ih*1/2)*2,format=yuv420p" "output.mp4" -benchmark HW accelerated encoding and decoding, CPU scalingffmpeg.exe -y -stats -hwaccel cuda -i "input.mp4" -c:v h264_nvenc -preset medium -crf 31 -c:a aac -qscale:a 0.75 -vf "scale=trunc(iw*1/2)*2:trunc(ih*1/2)*2,format=yuv420p" "output.mp4" -benchmark Fully HW accelerated transcodingffmpeg.exe -y -stats -hwaccel cuda -hwaccel_output_format cuda -i "input.mp4" -c:v h264_nvenc -preset medium -crf 31 -c:a aac -qscale:a 0.75 -vf "scale_cuda=trunc(iw*1/2)*2:trunc(ih*1/2)*2:format=yuv420p" "output.mp4" -benchmark Results
To Mp4 (low quality) (1x scaling)
To Mp4 (lowER quality) (0.5x scaling)This preset I made changes the scaling from 100% to 50%.
|
I compiled @tacheometry's version and ran a few tests. 3x runs on |
@Tichau Can I get a review on this? |
I thinks the easiest way is replace the ffmpeg file in file-converter with a self-complied version that enable all gpu-video-process feature enable. So it will work on any machine even it have NVIDIA or Intel or AMD graphic card. |
The Magick.NET compilation guide doesn't exist anymore ¯_(ツ)_/¯ |
Yo. The Magick.NET compilation guide exists again ^_^ |
This PR addresses Issue #392.
I've added some Nvidia CUDA FFMPEG arguments for the mp4 format for now, but this is a good start. What remains is:
scale
toscale_cuda
, orcrf
intoqp
for example. I tried doing this but couldn't get it to not error. It requires much experimentation.All help is greatly appreciated 😀 This is the first C# program I edit...
The results I got adding these arguments (which accelerate only the encode/decode part of the process) are 2-3x faster than before, transcoding a 176 MB video into ~8MB using the
To Mp4 (low quality)
preset.Development
I couldn't find much information on how to contribute to this program, but this is what I've learned so far:
Installation
The
Magick.Native-Q16-x64.dll
file must be copied tobin/x64/Debug
for the program to compile. To obtain this file you need to follow the Magick.NET compilation guide and then grab it fromC:\Users\xxxx\.nuget\packages\magick.native
.Testing
The project can be built in its entirety, and then the installer can be run, but this requires a system restart. A more efficient option is calling
FileConverter.exe
directly. After building theFileConverter
solution, you should be able to findApplication/FileConverter/bin/x64/Debug/FileConverter.exe
Opening this file will give you the tutorial window. But if you run it from the command line like so:
It is equivalent to right clicking a preset in the context menu, without all the extra steps.
Resources: