Skip to main content

Advanced Settings of Command Line Interface

Justin62628About 5 min

Warning

This page is for advanced content. Please read the detailed explanation of advanced content first.

SVFI supports calling via the command line

Tips

To avoid possible performance loss, performing tasks using pure OLS command line is the fastest.
In possible cases, using the full VSPipe workflow is the fastest.

Environment Setup

  1. Create a new steam_appid.txt in the SVFI installation root directory and fill in the following content:

1692080

Tips

Filling in this text file will cause SVFI to start in standalone application mode to avoid interference from the Steam client.

This can achieve special operations such as multiple instances of the software, software installation location migration, and software version retention.

  • Software version preservation: After reverting to a specified branch in Steam operations, copy the entire SVFI installation folder and ensure that steam_appid.txt exists. From then on, you can click SVFI.Professional or SVFI.Community in this folder to run this version of SVFI.
  • It is recommended to turn off the forced exit option in the preference settings to avoid all OLS processes exiting after the SVFI task is completed.
  1. Start the command prompt cmd in the SVFI installation root directory (if the installation location is not on the system drive, administrator privileges are not required). Enter one_line_shot_args -h and press Enter. You should be able to see the following similar content:
usage: #### SVFI CLI tool by Jeanna #### [-h] -i INPUT --config CONFIG -t TASK_ID [--concat-only] [--extract-only] [--render-only]
[--force-args FORCE_ARGS [FORCE_ARGS...]] [-p] [--pipe-in] [--pipe-out] [--pipe-iwPIPE_IN_WIDTH]
[--pipe-ih PIPE_IN_HEIGHT] [--pipe-in-fps PIPE_IN_FPS]
[--pipe-in-pixfmt {rgb24,rgb48be,rgb48le,gbrp,gbrp16le}] [--pipe-rgb]
[--pipe-colormatrix {470bg,170m,2020ncl,709}]

To enhance Long video/image sequence quality

options:
  -h, --help            show this help message and exit

Basic Settings:
  -i INPUT, --input INPUT
                        Path of input video/image sequence folder. leave '-' for stdin.
  --config CONFIG       Path of config, should be.ini or.json file.
  -t TASK_ID, --task-id TASK_ID
                        13-digit Task id, can not leave blank
  --concat-only         Concat Chunk only
  --extract-only        Extract input to frames Only
  --render-only         Render only without VFI process
  --force-args FORCE_ARGS [FORCE_ARGS...]
                        Force to update config. Examples: --force-args output_chunk_cnt=-1 interp_start=-1
  -p, --preview         [Dilapidated] Preview Settings.

Pipe Settings:
  Set the follow parameters when '-mid' is assigned, or you will encounter exceptions.Output Y4M at YUV444P10

  --pipe-in             This enables OLS to obtain input data from stdin, use with '-i -'
  --pipe-out            This enables OLS to pipe y4m or rgb/rgb48be output to stdout
  --pipe-iw PIPE_IN_WIDTH
                        Width of input raw RGB, effective and mandatory when --pipe-in appointed
  --pipe-ih PIPE_IN_HEIGHT
                        Height of input raw RGB, effective and mandatory when --pipe-in appointed
  --pipe-in-fps PIPE_IN_FPS
                        Input stream FPS, effective and mandatory when --pipe-in appointed
  --pipe-in-pixfmt {rgb24,rgb48be,rgb48le,gbrp,gbrp16le}
                        Pixel format of input raw RGB input, effective and mandatory when --pipe-in appointed
  --pipe-rgb            Pipe pixel format of rgb or rgb48be raw data to stdout, otherwise pipe y4m. Effective when --pipe-out appointed
  --pipe-colormatrix {470bg,170m,2020ncl,709}
                        Colormatrix for RGB-YUV Conversion, effective when --pipe-in appointed and --pipe-rgb NOT appointed

Explanation of typical usage scenarios

Running multiple instances of SVFI

The one_line_shot_args (hereinafter referred to as OLS) program supports running multiple instances after completing the above configuration and supports synchronous operation of multiple tasks. Please note that this may cause significant resource consumption.

Three required parameters:

  • --input: The folder where the video file or image sequence to be processed for image quality is located.
  • --config: The configuration file generated by the SVFI GUI program, generally located in the Configs folder of the installation directory.
  • --task-id: The task ID, a non-empty string used to distinguish different tasks.

Pipe input

SVFI supports inputting RGB streams from other processes. Currently, it supports five pixel formats of raw stream input: rgb24, rgb48be, rgb48le, gbrp, gbrp16le.

You must fill in --pipe-in to enable the SVFI pipe input function and additionally specify --pipe-iw for the input image pixel length, --pipe-ih for the width, and --pipe-in-fps for the input stream frame rate (only floating-point numbers are supported), and --pipe-in-pixfmt for the input pixel format.

Tips

  • rgb48be, rgb48le, gbrp16le indicates that the input data is 48-bit and 16-bit high-precision input.

  • When using VSPipe to output an RGB stream and OLS accepts the RGB stream, if you are unsure about the RGB output channel order of VSPipe, please specify the --pipe-in-pixfmt parameter of ols as gbrp or gbrp16le.

Pipe output

SVFI supports outputting rgb24 or rgb48be or YUV444P10 Y4M streams to stdout.

You must fill in --pipe-out to enable this function.

  • If you need to output YUV444P10, please specify --pipe-colormatrix for SVFI to perform correct color conversion from RGB to YUV streams. Y4M output is the default operation.
  • If you want to output an RGB stream, please specify --pipe-rgb. The specific output pixel format is controlled by various options in the configuration file. Generally, if the high-precision workflow is enabled, rgb48 is output; otherwise, rgb24 is output if the non-high-precision workflow is used.

Forcibly specifying the GPU number used by SVFI

  • Select the first item in the GPU drop-down list in the SVFI interface to start the task, generate a task configuration file, and then create another command line cmd according to the online tutorial.
  • Enter set CUDA_VISIBLE_DEVICES=1 and press Enter.
  • Call OLS to run SVFI on the GPU in the second slot of PCIE.
  • This method can solve the problem of not being able to specify which graphics card to use when using int8 quantization.

Command line examples

Batch processing all mp4, webm, and gif files in a folder using the same set of settings

for %i in ("folder path/*.mp4" "folder path/*.webm" "folder path/*.gif") do (one_line_shot_args.exe --input "%i" --task-id "%~ni" --config "SVFI_Config_vfi_sr.ini")

Among them:

  • It should be executed using the command prompt cmd in the root directory of the SVFI installation software.
  • SVFI_Config_vfi_sr.ini is the setting file exported by clicking the export settings button below the advanced settings.
  • This operation will output all files to the folder specified in the configuration file.

Example 1: ffmpeg->OLS->ffmpeg

Use ffmpeg for high-precision 16-bit frame extraction, input OLS for only compression processing, and output high-precision rgb48be to ffmpeg for compression.

ffmpeg -loglevel error -vsync passthrough -hwaccel auto -i test.mp4 -map 0:v:0 -sws_flags +bicubic+full_chroma_int+accurate_rnd -vf copy,format=yuv444p10le,format=rgb48be,minterpolate=fps=24.000:mi_mode=dup -f image2pipe -pix_fmt rgb48 -vcodec rawvideo - | one_line_shot_args.exe -i - --config "Configs/SVFI_Config_pipe_test.ini" -t pipe_2 --pipe-in --pipe-iw 1920 --pipe-ih 1080  --pipe-in-fps 24 --render-only --pipe-out --pipe-rgb --pipe-in-pixfmt rgb48be | ffmpeg.exe -y -vsync cfr -s 1920x1080 -vsync cfr -pix_fmt rgb48be -f rawvideo -r 24 -i - -preset:v slow -c:v hevc_nvenc -pix_fmt yuv420p -crf 16 output.mp4 -y -loglevel error -hide_banner -y

Example 2: ffmpeg->OLS->OLS->ffmpeg

Use ffmpeg for high-precision 16-bit frame extraction, input the first OLS pipeline for upscaling processing, input the second OLS pipeline for frame interpolation processing, and output Y4M to ffmpeg for compression.

ffmpeg -loglevel error -vsync passthrough -hwaccel auto -i test.mp4 -map 0:v:0 -sws_flags +bicubic+full_chroma_int+accurate_rnd -vf copy,format=yuv444p10le,format=rgb48be,format=rgb24,minterpolate=fps=24.000:mi_mode=dup -f image2pipe -pix_fmt rgb48be -vcodec rawvideo - | one_line_shot_args.exe  -i - --config Configs/SVFI_Config_pipe_1.ini -t pipe_1 --pipe-in --pipe-iw 960 --pipe-ih 540 --pipe-in-fps 24 --render-only --pipe-out --pipe-rgb --pipe-in-pixfmt rgb48be | one_line_shot_args.exe -i - --config Configs/SVFI_Config_pipe_2.ini -t pipe_2 --pipe-in --pipe-iw 1920 --pipe-ih 1080  --pipe-in-fps 24 --pipe-out --pipe-in-pixfmt rgb48be | ffmpeg.exe -loglevel error -hide_banner -y -vsync cfr -i - -preset:v slow -c:v hevc_nvenc -pix_fmt yuv420p -crf 16 output.mp4 -y

Example 3: Vapoursynth->ffmpeg->OLS->ffmpeg

Use Vapoursynth for preprocessing the input, input ffmpeg for converting Y4M to high-precision rgb48be, then to low-precision rgb24, input OLS for processing and compression.

The Vapoursynth script input.vpy used:

import vapoursynth as vs
from vapoursynth import core
video = core.lsmas.LWLibavSource(r'test.mp4')  # 960x540, 24fps

# DO SOMETHING

video.set_output()  # output yuv

Command line:

vspipe input.vpy --y4m - | ffmpeg -loglevel error -vsync passthrough -hwaccel auto -i - -map 0:v:0 -sws_flags +bicubic+full_chroma_int+accurate_rnd -vf copy,format=yuv444p10le,format=rgb48be,format=rgb24,minterpolate=fps=24.000:mi_mode=dup -f image2pipe -pix_fmt rgb24 -vcodec rawvideo - |  one_line_shot_args.exe  -i - --config Configs/SVFI_Config_pipe_test.ini -t pipe_2 --pipe-in --pipe-iw 960 --pipe-ih 540  --pipe-in-fps 24

Example 4: Vapoursynth->OLS->ffmpeg

Use Vapoursynth for preprocessing the input, output RGB to OLS, and convert RGB for ffmpeg compression.

The Vapoursynth script input.vpy used:

import vapoursynth as vs
from vapoursynth import core
video = core.lsmas.LWLibavSource(r'test.mp4')  # 960x540, 24fps

# DO SOMETHING

video = mvf.ToRGB(input=video, matrix="709", depth=8, kernel='bicubic')

video.set_output()  # output gbrp

Command line:

vspipe input.vpy - | one_line_shot_args.exe -i - --config "Configs/SVFI_Config_pipe_test.ini" -t pipe_2 --pipe-in --pipe-iw 1920 --pipe-ih 1080  --pipe-in-fps 24 --pipe-out --render-only --pipe-in-pixfmt gbrp --pipe-rgb |  ffmpeg.exe -y -vsync cfr -s 1920x1080 -vsync cfr -pix_fmt rgb24 -f rawvideo -r 24 -i - -preset:v slow -c:v hevc_nvenc -pix_fmt yuv420p -crf 16 output.mp4 -y -loglevel error -hide_banner -y

Tips

  • When using pipes, try to ensure precision alignment and use y4m as much as possible to avoid precision loss when converting y4m to rgb.
  • It is recommended to first use SVFI to configure task parameters and start the task, and then use the Config.ini generated in the Configs folder for command line tasks.
Last update:
Contributors: Justin62628,DAMNCRAB