To encode a section of a movie file to a high-quality webm file, use this simple addon for mpv.
Firstly run this command to create a directory to put the lua script.
mkdir -p ~/.config/mpv/scripts
Then download the required script to the directory we created.
wget -O ~/.config/mpv/scripts/webm.lua https://raw.githubusercontent.com/ElegantMonkey/mpv-webm/master/build/webm.lua
Once this is done, load a movie and press Shift-w to display an OSD interface that displays the keyboard shortcuts to capture a section of a movie to a webm file.
Just press 1 to set the start time of the webm and then quickly press 2 to set the end point and e to encode the file. It is as easy as that.
This is an example of the webm quality I got with this simple addon script. This is a great way to capture a section of a video as a webm file to share online.