Tutorial: how to easily encode on nvidia or intel GPU using s_options
Posted: Mon Mar 04, 2024 8:27 pm
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". What it does:
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
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". 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
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