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

ffmpeg using hwaccel dramatically decreases scaling and encoding time #4

Open
optisynapsis opened this issue Jul 5, 2023 · 2 comments
Milestone

Comments

@optisynapsis
Copy link

Not a python master so not sure how easy this would be to achieve, I presume this could be installed as a dependency through pip?

Obviously, it's possible to just save the frames and not encode the video, and do this manually. The scaling algorithm might be a little better with the original script truth be told, although frame generation time will be pretty high in comparison.

But here's an example of ffmpeg using cuda for anybody who's interested in doing it that way :

ffmpeg -hwaccel cuvid -framerate 30 -i %06d.png -i 'optionalaudio.wav' -vf "hwupload_cuda,scale_cuda=1280:720" -c:v h264_nvenc -c:a aac -b:a 320k output720.mp4

@mwydmuch
Copy link
Owner

mwydmuch commented Jul 6, 2023

Should be quite easy to support it, thanks for suggestion!

@optisynapsis
Copy link
Author

No problem :)

Done some more experimenting. Here's my newest command line (which allows for lanczos scaling and doesn't seem much slower. Quality is noticeably improved.)

ffmpeg -hwaccel cuvid -framerate 30 -i %06d.png -i 'optionalmusic.wav' -vf "scale=1920:1080:flags=lanczos,format=yuv420p" -c:v h264_nvenc -profile:v main -preset slow -cq:v 21 -c:a aac -b:a 320k -movflags +faststart output1080.mp4

Obviously there's a little more to experiment with here. At the moment I'm trying to encode in a manner that's compatible with facebook at 2160p, as it's defaulting to 720p no matter what I upload.

@mwydmuch mwydmuch added this to the 0.4.0 milestone Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants