Script to scale videos with waifu2x.
It allows you to scale your videos using Waifu2x, without the need to export all images(10Gb-50Gb), as well as the possibility to detect duplicate frames, and save processing time.
Work with any command line program(Windows), such as:
waifu2x-conver-cpp, waifu2x-caffe, waifu2x-ncnn-vulkan. (This is supported by CUDA,CUDNN, GPU AMD, Vulkan)
"waifu2x.- Image Super-Resolution for Anime-style art using Deep Convolutional Neural Networks. And it supports photo"
https://github.com/nagadomi/waifu2x
Note: The code can be easily modified to work with any program, including gimp.
The script exports a single image, then it is processed with the program, and then the processed image is loaded.
Link Tutorial.
https://www.youtube.com/watch?v=kdbhFVZ4vIM
In the description of the YouTube video, comes a compressed file with all the necessary files (dlls)
Code:
#~ SAMPLE CODE
LoadPlugin("ffms2.dll")
LoadPlugin("CALL_25.dll")
NameVideo= "c:\My path\My Video.mp4"
FFIndex(NameVideo)
FFVideoSource(NameVideo,fpsnum=24000,fpsden=1001)
Scale=2
Noise=0
#~ directory Temp
InputImage="c:\temp\Temp.bmp"
OutputImage="c:\temp\Temp.png"
Space=" "
DirectoryProgram=""" "C:\Program Files\waifu2x-converter\" """
NameProgram="waifu2x-converter-cpp.exe"
PImageInOut = "-i" + Space + "'" + InputImage + "'" + Space + "-o" + Space + "'" + OutputImage + "'" + Space
Parameters ="-m noise-scale -v 3 --noise-level" + Space + string(Noise) + Space + "--scale-ratio" + Space + string(Scale)
LineCommand= DirectoryProgram + Space + NameProgram + Space + Parameters + Space + PImageInOut
ConvertToRGB32()
ScriptClip("""ImageWriter(InputImage+"%n",start =current_frame, end =current_frame)""",after_frame = true)
#~ Same scale and color necessary
BilinearResize(last.Width*Scale,last.Height*Scale)
ScriptClip("""Call( "cmd /C title Frame:" + string(current_frame)+ "/" + string(last.FrameCount) + " & start /wait /B /D " + LineCommand, string(current_frame))""",after_frame = True)
ScriptClip("""ImageSourceAnim(OutputImage).BilinearResize(last.Width,last.Height)""",after_frame =true)
You can easily include the audio as well as video clippings.
Code:
AudioDub(last,A).trim(0,0)