[Solved] Ubuntu uses gym to save the video error: “unknown encoder ‘libx264′”

In the experiment of using gym environment to train the agent and save the video locally, an error was encountered when using monitor to save the video:

Unknown encoder 'libx264'

Considering that the video saved in gym is saved in ffmpeg, I reinstalled it, but still reported an error. Then yes

check the original codes ofwrappers.Monitor

Here we judge the selection method, so we can choose other encoders to save our video. We just need to install CONDA, uninstall ffmpeg, and then use other options

import pkgutil
import distutils.spawn
import imageio_ffmpeg


In my case, after I uninstall ffmpeg in CONDA, what gym calls becomes ffmpeg installed in Ubuntu, and then it can run.

Read More: