And now for something completely different: motion interpolation in mpv
Alright, this one is not going to be about programming, but hey – when was the last time I actually wrote anything about programming anyway, right? It's a crying shame – or at least I'd like to think it is – but programming during the day exhausts one so much that I'd have to be a supernatural being to be in a mood to write about programming in the evening, too. I mean, more supernatural than I already am, of course.
It doesn't mean it's not going to be about an interesting topic, however. The topic is motion interpolation and without going into all of the boring technical details, I'd rather just tell you what is it and why you can't live without it in 2015. You're probably well aware of the fact that most movies and TV series are still shot in 24 frames per second (which is far, far away from a high enough number) and the illusion of motion is not accomplished by rapid displaying of different images as much as it is done by utilizing an effect known as motion blur. But what would happen if we took away the motion blur and increased the number of frames per second instead?
Well, we may never know that, at least not in the foreseeable future, because getting rid of motion blur in already recorded movies would be… somewhat complicated to say the least, but we can at least artificially increase the number of frames per second. Okay, but hold on – if the missing frames are not present in the source material, where would they come from? From the aforementioned interpolation, of course!
Now, let's set up a video player to perform the real-time interpolation for you. I'll be using mpv in this tutorial as that's objectively the best video player for OS X out there (stop arguing, you're just being ridiculous with your VLC) but it might be possible to accomplish similar results with other players. But it probably isn't, ha!
We'll need to get some additional tools first – namely VapourSynth to filter the video just before mpv plays it for you and MVTools to provide the best motion interpolation filters for VapourSynth. Since we need mpv to support VapourSynth, we can't use Coalgirls' pre-built binary – we'll have to go back to the square one and compile our own binary from source. Open Terminal.app and if you don't use the Homebrew package manager already, please go sit in the corner and feel an appropriate level of embarassment. When you're back, install Homebrew with the following command:
cd /usr/local/Cellar/vapoursynth/26/lib/vapoursynth ln -s /usr/local/Cellar/mvtools/HEAD/lib/libmvtools.dylib .
And create VapourSynth configuration script in your ~/.mpv directory (create the directory with mkdir ~/.mpv if it doesn't exist). I called mine mvtools.vpy and it looks like this:
The indentation is important because… reasons. Now edit your mpv configuration file, it should reside in the ~/.config/mpv/ directory under the mpv.conf name. Make it look like this:
If you've placed the MVTools script to another location, you might want to reflect that change in the configuration file as well. Just a hint. Well, at this point you should be good to go, really – that is, unless I forgot some step along the way (let me know in the comments if that's the case). Feel free to set up mpv as your default video player as well – actually forget that, chances are it's your video player to go for a long time, right?
I'll leave with a few quick notes that I gathered during my first two days of usage:
yes, you can use it with Popcorn-Time, but you might want to add the idle=yes and keep-open=always options into your mpv configuration file;
no, it's not one hundred percent stable, you may expect issues in particular whenever a different source file is loaded within the same mkv container;
yes, you can use it to play YouTube video files as well, just brew install youtube-dl and brew reinstall ffmpeg --with-openssl; also consider adding ytdl-format=299+bestaudio/137+bestaudio/298+bestaudio/22/135+bestaudio/18/best to your mpv config file;
no, I did not report the aforementioned bug, please don't hit me reported, pull request not accepted as of yet;
yes, you could even be able to use it with Crunchyroll and other services, if you installed youtube-dl with the --with-rtmpdump option; and finally
no, you won't be able to watch any video with measly 24 FPS after this anymore, it would just feel weird.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming