mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Fast motion interpolation with mpv?

Open feckpown opened this issue 2 years ago • 16 comments

I have a large set of video clips that all needs to be motion interpolated to the same frame-rate (60 fps). Their frame-rate is all pretty random, 23.88, 53.88, etc. The ffmpeg command:

ffmpeg -i input.mp4 -crf 21 -filter:v "minterpolate=fps=60:mi_mode=mci" -crf 21 output.mp4

Does exactly what needs to be done with good output result, the problem is that it takes 11 hours to finish each file, and it only runs on 1 core.. Changing the mi_mode to blend makes it go fast, but the output quality is really bad.

Is it possible to do motion interpolation for changing frame-rate with MPV, but faster?

feckpown avatar Aug 04 '22 01:08 feckpown

There's SVP which is like minterpolate but GPU-accelerated. Other than that I don't know of anything besides the default blend-style interpolation.

haasn avatar Aug 04 '22 10:08 haasn

Maybe not. mpv's encoding mode seems always to be slower than ffmpeg(similar config?).

hooke007 avatar Aug 04 '22 11:08 hooke007

Maybe with hybrid using vapoursynth scripts? If You are in Windows then I can reccomend stax RIP, is fast enough that My Celeron can interpolate to 60 fps at almost real time with quicksync encoder

lavilao avatar Aug 04 '22 12:08 lavilao

video-sync=display-resample
interpolation=yes
tscale=oversample

Check out the documentation for interpolation if oversample is not "smooth" enough for you.

Be aware that good interpolation heavily depends on the viewer and the display in question so you won't find any "perfect" answers here or anywhere else - try them all and see what works best for your configuration.

My personal configuration to get my OLED stutter free with 120Hz output looks like this:

interpolation=yes
interpolation-preserve=yes
interpolation-threshold=0.005
tscale=oversample
vo = gpu-next
gpu-api = vulkan
vulkan-swap-mode=fifo-relaxed
hwdec = auto-safe
video-sync = display-resample

daddy-cool avatar Aug 06 '22 16:08 daddy-cool

tscale=oversample

mpv's interpolation is sth like blending, not motioned-based interpolation.

hooke007 avatar Aug 06 '22 16:08 hooke007

Not here to argue. If what mpv does isn't good enough for you there is always SVP and all its artifacts to please you.

https://ffmpeg.org/ffmpeg-all.html#minterpolate You'd better check ffmpeg's doc first. And then you should know why he is using mci instead of blend Also you could check mpv's doc to see the difference of blending and motion compensation interpolation. https://github.com/mpv-player/mpv/wiki/Interpolation

hooke007 avatar Aug 06 '22 16:08 hooke007

The cool kids use RIFE anyway..

Hrxn avatar Aug 06 '22 16:08 Hrxn

There's SVP which is like minterpolate but GPU-accelerated. Other than that I don't know of anything besides the default blend-style interpolation.

I've tried SVP and it works very fast and the output result is ok, much better than FFMPEG with blend interpolation, looks pretty much like FFMPEG with mci interpolation, but about 600x faster.

The main issue with SVP is that it's a GUI, i need it to be programmable, i.e. running via terminal commands. From the log it seems SVP is also somehow using MPV? So that's why i figured i'd come here to ask :-)

feckpown avatar Aug 07 '22 02:08 feckpown

Maybe with hybrid using vapoursynth scripts? If You are in Windows then I can reccomend stax RIP, is fast enough that My Celeron can interpolate to 60 fps at almost real time with quicksync encoder

All my machines are linux, strangely there seems to be a lot of options for windows but not so much for linux

feckpown avatar Aug 07 '22 02:08 feckpown

video-sync=display-resample
interpolation=yes
tscale=oversample

Check out the documentation for interpolation if oversample is not "smooth" enough for you.

Be aware that good interpolation heavily depends on the viewer and the display in question so you won't find any "perfect" answers here or anywhere else - try them all and see what works best for your configuration.

What would be the commands for doing default frame-rate conversion with motion interpolation? I basically just need the output to become:

Fixed 60 FPS (Force the exact value) CRF 18

Can this be accomplished with one or more command line entries?

feckpown avatar Aug 07 '22 02:08 feckpown

https://ffmpeg.org/ffmpeg-all.html#minterpolate You'd better check ffmpeg's doc first. And then you should know why he is using mci instead of blend Also you could check mpv's doc to see the difference of blending and motion compensation interpolation. https://github.com/mpv-player/mpv/wiki/Interpolation

Yes indeed there is a huge difference. The ffmpeg blend mode introduces large visual artifacts, shadows that move around. All those video clips are of sports with fast movements, the mci mode with ffmpeg gives much much better results. Unfortunately the mci mode it is also something like 500x slower than the blend mode.

feckpown avatar Aug 07 '22 02:08 feckpown

The cool kids use RIFE anyway..

I actually did try RIFE using the implementation here https://github.com/megvii-research/ECCV2022-RIFE :-) It works good too, it's faster than FFMPEG minterpolate, though still substantially slower than SVP. The main issue is that it interpolates fixed 2x, 4x, 8x, etc. I need those thousands of little 1-3 minute clips with various random variable frame-rates to be transcoded to 60fps fixed frame-rate exactly

feckpown avatar Aug 07 '22 02:08 feckpown

Maybe with hybrid using vapoursynth scripts? If You are in Windows then I can reccomend stax RIP, is fast enough that My Celeron can interpolate to 60 fps at almost real time with quicksync encoder

All my machines are linux, strangely there seems to be a lot of options for windows but not so much for linux

Yes, it's sad the lack of linux options compares to Windows. From what I understand from your precios comments You want a cli tool right? Then mpv+svp might be your chance "but it has a gui" You might Say, well not necesarialy if You use mpv to encode and add the svp vapoursynth scripts as a filter then You would have basically a svp cli tool. For info on the svp script location You can check on the svp logs. Btw if You are able to use vaapi encoding please let me know how You did ir.

lavilao avatar Aug 07 '22 02:08 lavilao

Maybe with hybrid using vapoursynth scripts? If You are in Windows then I can reccomend stax RIP, is fast enough that My Celeron can interpolate to 60 fps at almost real time with quicksync encoder

All my machines are linux, strangely there seems to be a lot of options for windows but not so much for linux

Yes, it's sad the lack of linux options compares to Windows. From what I understand from your precios comments You want a cli tool right? Then mpv+svp might be your chance "but it has a gui" You might Say, well not necesarialy if You use mpv to encode and add the svp vapoursynth scripts as a filter then You would have basically a svp cli tool. For info on the svp script location You can check on the svp logs. Btw if You are able to use vaapi encoding please let me know how You did ir.

Yes exactly! Ok that's a good suggestion, will give it a try

feckpown avatar Aug 07 '22 05:08 feckpown

Did you manage to make it work?

Traneptora avatar Aug 14 '22 16:08 Traneptora

Did you manage to make it work?

Traneptora avatar Aug 19 '22 03:08 Traneptora

See also #11060

philipl avatar Jan 09 '23 01:01 philipl

Can you achieve something similar to SVP for 60fps playback but using only free tools, plugins, libraires?

TheRealMaN avatar Nov 28 '23 06:11 TheRealMaN