Can anime4K enlarge the video and save it?
xiaowu2001 opened this issue · 11 comments
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
I have tried to use ffmpeg to upscale video, but something went wrong,here is my command:
set anime4kpath=C:\anime4kv4 set shader1="%anime4kpath%\Anime4K_Clamp_Highlights.glsl" set shader2="%anime4kpath%\Anime4K_Restore_CNN_M.glsl" set shader3="%anime4kpath%\Anime4K_Upscale_CNN_x2_M.glsl" set shader4="%anime4kpath%\Anime4K_AutoDownscalePre_x2.glsl" set shader5="%anime4kpath%\Anime4K_AutoDownscalePre_x4.glsl" set shader6="%anime4kpath%\Anime4K_Upscale_CNN_x2_S.glsl" (ffmpeg -i input.mp4 -init_hw_device vulkan -vf hwupload,libplacebo=custom_shader_path=%shader1%, libplacebo=custom_shader_path=%shader2%, libplacebo=custom_shader_path=%shader3%, libplacebo=custom_shader_path=%shader4%, libplacebo=custom_shader_path=%shader5%, libplacebo=custom_shader_path=%shader6%,hwdownload -vcodec libx264 anime4kout.mp4 )
Can you tell me what's wrong with my code?
I don't know how ffmpeg work, maybe my command of ffmpeg is not right.
I want to upscale a video(1280:720) to 1440P:
mpv input.mp4 --glsl-shader="shaders/Anime4K_Upscale_CNN_x2_M.glsl" -vf scale=2560:1440 --o output.mp4
However, the clarity doesn't improve while the resolution has been upscaled to 1440P.
But I found mpv input.mp4 --glsl-shader="shaders/Anime4K_Upscale_CNN_x2_M.glsl" -vf scale=2560:1440
this command can improve the clarity and play in MPV.
In a word, I can use MPV to play videos with anime4k but can't use mpv to output videos.
mpv input.mp4 --glsl-shader="shaders/Anime4K_Upscale_CNN_x2_M.glsl" -vf scale=2560:1440 --o output.mp4
In encoding mode, currently --glsl-shader
must be combined with --vf=gpu
Working example with A+A mode for lower-end GPU:
mpv input.mp4 \
--glsl-shaders="~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl:~~/shaders/Anime4K_Restore_CNN_S.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl" \
--vf=gpu -vf scale=2560:1440 --o=output.mp4
mpv input.mp4 \ --glsl-shaders="~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl:~~/shaders/Anime4K_Restore_CNN_S.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl" \ --vf=gpu -vf scale=2560:1440 --o=output.mp4
--glsl-shaders seen not work
Working example with A+A mode for lower-end GPU:
mpv input.mp4 \ --glsl-shaders="~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl:~~/shaders/Anime4K_Restore_CNN_S.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl" \ --vf=gpu -vf scale=2560:1440 --o=output.mp4
Thanks for your reply, but I still failed to run the command. Here is my GPU device, how can I use the command "--vf=gpu"
--vf="Intel(R) UHD Graphics 630"
and --vf=gpu
went wrong. What's the correct command on my computer?
--vf="Intel(R) UHD Graphics 630"
and--vf=gpu
went wrong. What's the correct command on my computer?
Maybe --vf
means --vo
, but I'm not sure, glsl doesn't work when --vo=gpu
.
Working example with A+A mode for lower-end GPU:
mpv input.mp4 \ --glsl-shaders="~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl:~~/shaders/Anime4K_Restore_CNN_S.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_S.glsl" \ --vf=gpu -vf scale=2560:1440 --o=output.mp4
I used this method but changed "--vf=gpu -vf scale=2560:1440" to "--vf=gpu=w=2560:h=1440" and now mpv is able to encode the video with the shaders applied
I used this to enlarge.
ffmpeg.exe -y -i D:\video\input/1.mp4 -init_hw_device vulkan -c:v h264_nvenc -cq 26 -preset slow -vf scale="1920:1080",format=yuv420p,hwupload,[SHADERS],hwdownload,format=yuv420p D:\video\output/1.mp4
h264_nven
for Nvidia GPU hwupload,[],hwdownload
to hardcoded
if your GPU not Nvidia, run some like this
ffmpeg.exe -y -i D:\video\input/1.mp4 -c:v h264 -crf 24 -preset slow -vf scale="1920:1080",format=yuv420p,hwupload,[SHADERS],hwdownload,format=yuv420p D:\video\output/1.mp4
and this is SHADERS path
libplacebo=custom_shader_path=
full path on below, one day you will write a script to generate this long long spell
"libplacebo=custom_shader_path=input/shaders/Anime4K_Clamp_Highlights.glsl,libplacebo=custom_shader_path=input/shaders/Anime4K_Restore_CNN_UL.glsl,libplacebo=custom_shader_path=input/shaders/Anime4K_Upscale_CNN_x2_M.glsl,libplacebo=custom_shader_path=input/shaders/Anime4K_Darken_HQ.glsl,libplacebo=custom_shader_path=input/shaders/Anime4K_Denoise_Bilateral_Median.glsl"