Open Arc-2023 opened 1 year ago
I have an example of using ffmpeg's libplacebo filter here, relevant snippet:
ffmpeg -y -init_hw_device vulkan -i images/anime/mountain_adventurer.webp -vf 'crop=128:128:y=128,format=yuv420p,gblur=0.625,hwupload,libplacebo=w=128:h=128:custom_shader_path=$?,hwdownload,format=yuv420p,scale=256:256:flags=neighbor' $@
($?
and $@
are replaced by the shader path and the output filename respectively.)
So you need to specify a vulkan device with -init_hw_device
, you need to do hwupload
first, you need to do hwdownload
after libplacebo
, and you may need to specify an appropriate format
before and/or after. Also you put libplacebo=custom_shader_path=
twice in your command.
Is it using the upscaling algorithm in libplacebo first, before applying anime4k? How can I achieve my original goal that only use anime4k to upscale?
If your output resolution (libplacebo's w
and h
parameters) is 2x the input resolution and you apply a shader that does a 2x upscale, then the shader should be doing all of the upscaling.
I have an example of using ffmpeg's libplacebo filter here, relevant snippet:
ffmpeg -y -init_hw_device vulkan -i images/anime/mountain_adventurer.webp -vf 'crop=128:128:y=128,format=yuv420p,gblur=0.625,hwupload,libplacebo=w=128:h=128:custom_shader_path=$?,hwdownload,format=yuv420p,scale=256:256:flags=neighbor' $@
(
$?
and$@
are replaced by the shader path and the output filename respectively.)So you need to specify a vulkan device with
-init_hw_device
, you need to dohwupload
first, you need to dohwdownload
afterlibplacebo
, and you may need to specify an appropriateformat
before and/or after. Also you putlibplacebo=custom_shader_path=
twice in your command.Is it using the upscaling algorithm in libplacebo first, before applying anime4k? How can I achieve my original goal that only use anime4k to upscale?
If your output resolution (libplacebo's
w
andh
parameters) is 2x the input resolution and you apply a shader that does a 2x upscale, then the shader should be doing all of the upscaling.
if i don't use -init_hw_device vulkan
, 'hwpoload' and 'hwdownload' these three options for transcoding, I noticed some GPU usage. Does this mean shaders are being used for processing?
Seeing GPU usage is a good sign but you should compare the output to the input to ensure that the shaders are working, you should also see that the output resolution is 2x the input resolution.
Thank you for the reply, but I am still not clear about the specific functions of hwupload and hwdownload. The information I could find only provides simple descriptions of their roles. If I don't add these options, why would the GPU still be occupied? Does this mean adding or not adding these parameters does not affect shader invocation? Or does ffmpeg automatically upload streams to VRAM for processing when handling video and audio streams? If so, what is the significance of manually specifying upload and download?
Also, I noticed that if I directly remove hwdownload, there are still no issues. Does this mean hwdownload is unnecessary?
Discussed in https://github.com/bloc97/Anime4K/discussions/199