Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can anime4K enlarge the video and save it? #167

Open
xiaowu2001 opened this issue Mar 22, 2022 · 11 comments
Open

Can anime4K enlarge the video and save it? #167

xiaowu2001 opened this issue Mar 22, 2022 · 11 comments

Comments

@xiaowu2001
Copy link

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.

@hooke007
Copy link

mpv-player/mpv#9589

@xiaowu2001
Copy link
Author

xiaowu2001 commented Mar 23, 2022

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.

@studentnice05
Copy link

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.

@hooke007
Copy link

hooke007 commented Mar 23, 2022

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

@OrangeFlag
Copy link

OrangeFlag commented Jul 17, 2022

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

@yooooooLeon
Copy link

yooooooLeon commented Jul 17, 2022 via email

@98mxr
Copy link

98mxr commented Jul 24, 2022

低端 GPU的 A+A 模式的工作示例:

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

@studentnice05
Copy link

studentnice05 commented Jul 25, 2022

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"
image

--vf="Intel(R) UHD Graphics 630" and --vf=gpu went wrong. What's the correct command on my computer?

@98mxr
Copy link

98mxr commented Jul 25, 2022

--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.

@calvindo95
Copy link

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

@Thisisawa
Copy link

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants