Tutorial: how to easily encode on nvidia or intel GPU using s_options

Questions and answers on how to get the most out of FFAStrans
Post Reply
emcodem
Posts: 1812
Joined: Wed Sep 19, 2018 8:11 am

Tutorial: how to easily encode on nvidia or intel GPU using s_options

Post by emcodem »

Dears,

it is an unfortune that we still don't have native GPU (or how i call it: ASIC) encoder support in FFAStrans. This will need to wait until either steinar drops his personal requirement to introduce resource controlling OR actually implement resource controlling for the utilized GPU's.

Since the latest release, we can already utilize our GPU's encoding capabilities pretty easy. Before 1.4.0.4 release, it was a hassle: One had to generate his own ffmpeg command with all the needed stream mapping and execute it in a cmd executor, so workflows that wanted to use GPU encoders were more or less restricted to one single Source File Format.

Now, since 1.4.0.4 there is a new feature called s_options. It is not yet documented but the main purpose from a users perspective is to be able to change the internally calculated encoding command of ffastrans. I personlally use this in production to insert "pre input" options (before -i options) as well as a duration (-t) which allows me to record from Blackmagic decklink using any inbuilt encoding processor.

However, the following example showcases not live recording with decklink but instead it shows how i utilize an inbuilt encoder and change the codec from "libx264" to "h264_nvenc".
emcodem_gpu_encode.json
(6.35 KiB) Downloaded 364 times
What it does:
  • disable encoding and capture the calculated encoding command by setting s_options to "skip_encoding=True|save_enc_cmd=True"
  • after the h264 encoder, change the calculated command by just replacing libx264 by h264_nvenc
  • execute the changed encoding command
Yes, we need 4 processors now instead of a single encoder processor but this way enables us to utilize the core power of ffastrans (filter_builder) and change it to our needs. GPU powered encoding will be added to ffastrans at some point in time, s_options will stay anyway because it is much more than just that. This is just one example how mighty you become with the new s_options and save_enc_cmd technology.

In case you do not have nvidia card but intel processor with quicksync feature, you can try h264_qsv instead of h264_nvenc.
Please note that most of the options of h264 processor will work but definitely not all of them, x264 and h264_nvenc encoders in ffmpeg have slightly different detailed parameters that should not matter for most of the users out there.

@taner and all other interested users, please let me know any questions
emcodem, wrapping since 2009 you got the rhyme?
kalamazandy
Posts: 6
Joined: Tue Jun 18, 2024 6:24 pm

Re: Tutorial: how to easily encode on nvidia or intel GPU using s_options

Post by kalamazandy »

I just want to say a Huge thank you for posting that. I went from about 1.2fps to around 62fps by doing this.
Post Reply