For environments without a full PyTorch setup, you can use the NCNN portable executables. This requires a three-step workflow: extracting frames, running inference, and merging frames.
Create a tmp_frames directory and extract frames from your source video:
ffmpeg -i onepiece_demo.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 tmp_frames/frame%08d.png
Step 2: Run NCNN Inference
Download the appropriate executable for your OS (Windows, Linux, or MacOS) and run:
./realesrgan-ncnn-vulkan.exe -i tmp_frames -o out_frames -n realesr-animevideov3 -s 2 -f jpg
Note: Ensure the out_frames directory exists before running.
Step 3: Merge frames back into video
- Determine the original video's FPS using
ffmpeg -i <input_video>. - Merge the enhanced frames:
ffmpeg -r 23.98 -i out_frames/frame%08d.jpg -c:v libx264 -r 23.98 -pix_fmt yuv420p output.mp4
- To include audio from the original video:
ffmpeg -r 23.98 -i out_frames/frame%08d.jpg -i onepiece_demo.mp4 -map 0:v:0 -map 1:a:0 -c:a copy -c:v libx264 -r 23.98 -pix_fmt yuv420p output_w_audio.mp4
# Step 1: Extract
ffmpeg -i onepiece_demo.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 tmp_frames/frame%08d.png
# Step 2: Inference
./realesrgan-ncnn-vulkan.exe -i tmp_frames -o out_frames -n realesr-animevideov3 -s 2 -f jpg
# Step 3: Merge with audio
ffmpeg -r 23.98 -i out_frames/frame%08d.jpg -i onepiece_demo.mp4 -map 0:v:0 -map 1:a:0 -c:a copy -c:v libx264 -r 23.98 -pix_fmt yuv420p output_w_audio.mp4