Skip to content

How to process videos (Mac App Store version)

Yi Xie edited this page Dec 27, 2021 · 7 revisions

Overview

The macOS version (App Store) supports video processing via command line. Input video is provided through STDIN. Result video is written to STDOUT.

To learn about general usage of the command line, please go to this page.

The video filter in the app is a bit slower than the one in this repo (Waifu2xFilter) but it requires way less video RAM to work.

Usage

Arguments

Use --raw to enable video mode. The model type, scale factor and noise level should also be specified. Real-ESRGAN variant should be specified if applicable. All models support video processing starting from version 5.1.1.

Data format

Frames are in 32-bit RGBA format. If --16-bit flag is present, frames must be in 64-bit little endian RGBA format instead.

You must specify the resolution of input frames through command line arguments --width and --height. You must also calculate the size of resulting frames and provide it to the downstream program. Frame rate must also be provided if the downstream program is an encoder.

Examples

You can pipe two ffmpeg instances as decoder and encoder with waifu2x.

1080p -> 2160p using Real-ESRGAN anime 2x video model

With software encoding 10-bit 4:4:4 h264:

alias waifu2x=/Applications/waifu2x.app/Contents/MacOS/waifu2x
ffmpeg -i input.mkv -pix_fmt rgba64le -f rawvideo -loglevel quiet - |
  waifu2x -m real_esrgan -v anime_2x_video --raw --width 1920 --height 1080 --16-bit |
  ffmpeg -f rawvideo -pix_fmt rgba64le -s:v 3840x2160 -r 23.98 -i - -c:v libx264 output.mp4

With hardware encoding 8-bit 4:2:0 h264:

alias waifu2x=/Applications/waifu2x.app/Contents/MacOS/waifu2x
ffmpeg -i input.mkv -pix_fmt rgba -f rawvideo -loglevel quiet - |
  waifu2x -m real_esrgan -v anime_2x_video --raw --width 1920 --height 1080 |
  ffmpeg -f rawvideo -pix_fmt rgba -s:v 3840x2160 -r 23.98 -i - -c:v h264_videotoolbox output.mp4

Sample output from M1 MacBook Air with ANE:

Merge the audio track

The result video will not contain any audio track. You can combine it with audio from the original video.

ffmpeg -i input.mkv -vn -c:a flac audio.flac
ffmpeg -i output.mp4 -i audio.flac -c:v copy -c:a copy output.mkv