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/ScreenCapture.py”, 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.
lassoan
(Andras Lasso)
October 15, 2020, 7:10pm
2
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.
ScreenCapture.ScreenCaptureLogic().ffmpegDownload()
#that gives me this but it dose not open
Requesting download ffmpeg from http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-3.2.4-win64-static.zip …
#so i went to :
i don’t really undertand how to install this
lassoan
(Andras Lasso)
October 15, 2020, 7:56pm
4
You can download and unzip any of the ffmpeg packages and set the path to ffmpeg.exe in the Screen Capture module GUI.
lassoan
(Andras Lasso)
October 15, 2020, 8:07pm
5
Alternatively, you can update the download URL in ScreenCapture.py file in your installed Slicer:
ffmpegTargetDirectory = self.getDownloadedFfmpegDirectory()
filePath = slicer.app.temporaryPath + '/ffmpeg-package.zip'
success = self.unzipFfmpeg(filePath, ffmpegTargetDirectory)
if success:
# there was a valid downloaded package already
return True
# List of mirror sites to attempt download ffmpeg pre-built binaries from
urls = []
if os.name == 'nt':
urls.append('https://github.com/Slicer/SlicerBinaryDependencies/releases/download/ffmpeg/ffmpeg-3.2.4-win64-static.zip')
else:
# TODO: implement downloading for Linux/MacOS?
pass
success = False
qt.QApplication.setOverrideCursor(qt.Qt.WaitCursor)
for url in urls:
success = True
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’)