命令行进阶讲解
大约 5 分钟
注意
此页说明属于进阶内容,请优先阅读高级内容详解
SVFI 支持使用命令行调用
提示
使用纯ols命令行速度最快
环境搭建
- 在SVFI安装根目录新建
steam_appid.txt
,填写如下内容
1692080
提示
填写该文本文件将使SVFI以独立应用程序模式启动,以避免Steam客户端的干扰。
可实现软件多开、软件安装位置迁移、软件版本保留等特殊操作。
- 软件版本保留:在steam操作回退到指定分支后,复制整个SVFI安装文件夹并确保
steam_appid.txt
存在,以后即可点击该文件夹下的SVFI.Professional
或者SVFI.Community
运行该版本的SVFI。
- 在SVFI安装根目录启动命令提示符
cmd
(若安装位置不在系统盘,则无需管理员权限),输入one_line_shot_args -h
并回车,应能够看到以下类似内容:
usage: #### SVFI CLI tool by Jeanna #### [-h] -i INPUT -c CONFIG -t TASK_ID
[--concat-only] [--extract-only]
[--render-only] [-p] [--pipe-in]
[--pipe-out]
[--pipe-iw PIPE_IN_WIDTH]
[--pipe-ih PIPE_IN_HEIGHT]
[--pipe-in-fps PIPE_IN_FPS]
[--pipe-in-pixfmt {rgb24,rgb48be,rgb48le,rgb48}]
[--pipe-rgb]
[--pipe-colormatrix {470bg,170m,2020ncl,709}]
To enhance Long video/image sequence quality
optional arguments:
-h, --help show this help message and exit
Basic Settings:
-i INPUT, --input INPUT
Path of input video/image sequence folder
-c CONFIG, --config CONFIG
Path of config
-t TASK_ID, --task-id TASK_ID
13-digit Task id
--concat-only Concat Chunk only
--extract-only Extract input to frames Only
--render-only Render only
-p, --preview 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
--pipe-out This enables OLS to pipe output to stdout
--pipe-iw PIPE_IN_WIDTH
Width of input raw RGB, effective when --pipe-in
appointed
--pipe-ih PIPE_IN_HEIGHT
Height of input raw RGB, effective when --pipe-in
appointed
--pipe-in-fps PIPE_IN_FPS
Input stream FPS, effective when --pipe-in appointed
--pipe-in-pixfmt {rgb24,rgb48be,rgb48le,rgb48}
Pixel format of input raw RGB, effective when --pipe-
in appointed
--pipe-rgb Pipe RGB Raw data to stdout, effective when --pipe-out
appointed
--pipe-colormatrix {470bg,170m,2020ncl,709}
Colormatrix for RGB-YUV Conversion, effective when
--pipe-in appointed, --pipe-rgb not appointed
典型使用场景说明
多开SVFI
one_line_shot_args
(以下简称OLS)程序在完成以上配置后支持多开,用于多进程任务,请注意这可能会造成极大的资源占用。
有三个必要参数需要输入:
--input
: 待进行画质处理的视频文件或图片序列所在文件夹--config
:SVFI GUI程序生成的配置文件,一般位于安装目录的Configs文件夹--task-id
:任务ID,非空的字符串,用于区分不同任务。
管道输入
SVFI支持从其他进程输入RGB流,目前支持rgb24
, rgb48
, rgb48le
, rgb48be
四种像素格式的裸流输入。
必须填写--pipe-in
以启用此功能,并另行指定--pipe-iw
输入图像像素长,--pipe-ih
宽,--pipe-in-fps
输入流帧率(仅支持浮点型),--pipe-in-pixfmt
输入的像素格式。
管道输出
SVFI支持输出RGB或YUV444P10
的Y4M流到stdout
中。
必须填写--pipe-out
以启用此功能,
- 若需要输出
YUV444P10
,请指定--pipe-colormatrix
用于SVFI进行RGB到YUV流的转换 - 若要输出
RGB
流,请指定--pipe-rgb
,具体的输出像素格式由配置文件各选项控制,一般而言开启高精度工作流则输出rgb48
,非高精度工作流输出rgb24
强行指定SVFI使用的GPU编号
- 在SVFI界面内选择gpu0启动任务,生成任务配置文件,然后按照在线教程另外
- 新建命令行cmd,
- 输入
set CUDA_VISIBLE_DEVICES=1
回车, - 调用ols,将指定在PCIE第二卡位的GPU运行SVFI
- 这个方法可以解决使用int8量化时无法指定使用显卡的问题
命令行示例
使用同一套设置批量处理文件夹内所有mp4、webm、gif文件
for %i in ("文件夹路径/*.mp4" "文件夹路径/*.webm" "文件夹路径/*.gif") do (one_line_shot_args.exe --input "%i" --task-id "%~ni" --config "SVFI_Config_vfi_sr.ini")
其中:
- 要在SVFI安装软件根目录下使用cmd执行
SVFI_Config_vfi_sr.ini
是通过点击高级设置下方导出设置按钮导出的设置文件- 会输出到同一文件夹
ffmpeg
进行高精度拆帧并输入SVFI
进行处理,使用Y4M
输入ffmpeg
进行压制
使用ffmpeg -loglevel error -vsync passthrough -hwaccel auto -i test/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 rgb24 -vcodec rawvideo - | one_line_shot_args.exe -i - -c Configs/SVFI_Config_pipe_test.ini -t pipe_2 --pipe-in --pipe-iw 960 --pipe-ih 540 --pipe-in-fps 24 --pipe-out | ffmpeg.exe -loglevel error -hide_banner -y -vsync cfr -i - -preset:v slow -c:v hevc_nvenc -pix_fmt yuv420p -crf 16 test/output.mp4 -y
ffmpeg
进行高精度拆帧并输入长度为2的SVFI
管道进行处理,输出Y4M
使用ffmpeg
进行压制
使用第一个OLS进程用于超分,第二个OLS进程用于补帧
ffmpeg -loglevel error -vsync passthrough -hwaccel auto -i test/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 - -c Configs/SVFI_Config_pipe_1.ini -t pipe_1 --pipe-in --pipe-iw 960 --pipe-ih 540 --pipe-in-fps 24 --pipe-out --pipe-rgb --pipe-in-pixfmt rgb48be | one_line_shot_args.exe -i - -c Configs/SVFI_Config_pipe_2.ini -t pipe_2 --pipe-in --pipe-iw 960 --pipe-ih 540 --pipe-in-fps 24 --pipe-in-pixfmt rgb48 --pipe-out | ffmpeg.exe -loglevel error -hide_banner -y -vsync cfr -i - -preset:v slow -c:v hevc_nvenc -pix_fmt yuv420p -crf 16 test/output.mp4 -y
Vapoursynth
对输入进行预处理后由ffmpeg
进行高精度拆帧并由SVFI
管道处理
使用使用的Vapoursynth
脚本input.vpy
:
import vapoursynth as vs
from vapoursynth import core
video = core.lsmas.LWLibavSource(r'test.mp4') # 960x540, 24fps
# DO SOMETHING
video.set_output() # output yuv
命令行:
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 - -c Configs/SVFI_Config_pipe_test.ini -t pipe_2 --pipe-in --pipe-iw 960 --pipe-ih 540 --pipe-in-fps 24 --pipe-out | ffmpeg.exe -loglevel error -hide_banner -y -vsync cfr -i - -preset:v slow -c:v hevc_nvenc -pix_fmt yuv420p -crf 16 test/output.mp4 -y
提示
先使用SVFI配置任务参数并启动任务后,使用Configs
文件夹下生成的Config.ini
进行命令行任务