How to creat a video with code

Hi, today I was trying to make a video or gif.
but the thing is that I couldn’t I don’t really now why but here’s the code I got:

cap = ScreenCapture.ScreenCaptureLogic().createVideo(30,‘extra’,‘C:\Program Files\Slicer 4.10.2’,‘image_%05d.mp4’,‘vid.mp4’)

#what it’s in the repository is :
def createVideo(self, frameRate, extraOptions, outputDir, imageFileNamePattern, videoFileName)

it gives me the next error:

Traceback (most recent call last):
File “”, line 1, in
File “C:/Program Files/Slicer 4.10.2/bin/…/lib/Slicer-4.10/qt-scripted-modules/”, line 1100, in createVideo
raise ValueError("Video creation failed: ffmpeg executable path is invalid: "+ffmpegPath)
ValueError: Video creation failed: ffmpeg executable path is invalid: C:\Program Files\Slicer 4.10.2

if someone could give me an example of how to use it, that would help a lot.

You need to install ffmpeg (it cannot be bundled with Slicer due to video codec licensing issues) and tell the module where to find it. The easiest is to export a video using the Screen Capture module GUI first, which will offer automatic download and install of ffmpeg.

#that gives me this but it dose not open
Requesting download ffmpeg from

#so i went to :

i don’t really undertand how to install this

You can download and unzip any of the ffmpeg packages and set the path to ffmpeg.exe in the Screen Capture module GUI.

Alternatively, you can update the download URL in file in your installed Slicer:

i got it, thanks for the information it was really helpfull
i leave the code:
cap = ScreenCapture.ScreenCaptureLogic().createVideo(30,’-codec mpeg4 -qscale 3’,‘C:/Users/aldot/Desktop/ICBM/python/img’,‘image_%05d.png’,‘vid.mp4’)