How to add a text-info into the View1 before I try to capture a video

Operating system: Windows
Slicer version: 4.11.0-2019-06-23 r28335
Expected behavior: text inside View1
Actual behavior: no idea

@all Hi all,
I am a new in Slicer community. I would like to add some text info into View1 region, how may I do that?
Thanks a lot

I’m on my phone so I don’t have the options in front of me, but if the windows version of slicer uses ffmpeg to make videos, you can feed all sorts of options to it to do text overlays. In the screen capture module, there’s a box to add options to give to ffmpeg. Sorry this post is short on specifics, but hopefully it will point you in the right direction. Check out the ffmpeg documentation, and there are lots of examples of text overlays using ffmpeg if you search around.

There is an example here of specifying extra ffmpeg options for Screen Capture module to display a logo in the corner of the video.

For adding titles, subtitles, and transitions we used Windows Movie Maker (free, now replaced by Microsoft Photos) nowadays we mostly switched to Camtasia (not free, but quite good and simple to learn).

Thanks a lot, I will try as you suggested.


@lassoan Hi Thanks a lot again for the hint.

I tried as you suggested using drawtext from ffmpeg. Sort of I did reach my aim right after the original ffmpeg running in Screen Capture (Thanks a lot one more time, LOL), I did one more time running of ffmpeg as to add drawtext to the *.mp4 file to make a new file. The code is as follows (excuse my non-professional coding way since I am still kind new to python.)

    print('..........................before second ffmpeg running ....................................')
    #No idea how to decide arialbd.ttf location
    #use an alternate way: copy a *.ttf to the current working dir
    #that is, copy my arialbd.ttf to the outputDir
    ttf_dirname =outputDir + '\\arialbd.ttf'
    if not os.path.isfile(ttf_dirname):
        from shutil import copyfile
        src = os.path.dirname(ffmpegPath)+'\\arialbd.ttf'
        dst = ttf_dirname
        print('copying file =' , src )
        print('to here = ', dst)
        copyfile(src , dst )

    #run_ffmpeg2 = 'C:\\Anaconda3\\envs\\aiden_00\\Scripts\\ffmpeg.exe '+ ' -i '+  outputVideoFilePath \
    run_ffmpeg2 = ffmpegPath + ' -i '+  outputVideoFilePath \
      + ' -y -vf \"format=yuv420p, drawtext=fontfile=arialbd.ttf:text=\'DigiM 2019\':fontcolor=yellow@0.7:fontsize=28:x=15:y=20, format=yuv420p\" '\
      + ' -c:v libx264 -c:a copy -movflags faststart '\
      + outputVideoFilePath.replace('.mp4', '_digim.mp4')
    print('...................... before second ffmpeg running........................................')

    p2 = subprocess.Popen(run_ffmpeg2, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=outputDir)
    stdout2, stderr2 = p2.communicate()
    if p2.returncode != 0:
      self.addLog("ffmpeg error output: " + stderr2.decode())
      raise ValueError("ffmpeg returned with error")
      self.addLog("Video export succeeded to file: "+ outputVideoFilePath.replace('.mp4', '_digim.mp4') )
      logging.debug("ffmpeg standard output: " + stdout2.decode())
      logging.debug("ffmpeg error output: " + stderr2.decode())

    print('Supposed to be done successfully!')

The big issue I encountered was how to set up the ttf file in drawtext between two ’ " ’ which always brought me trouble with escaping.
I have not still figure out how to set up that drawtext format, especially with the ttf-file part. So alternately I copied a ttf to the current working directory. It works fine but not professional. So please, if anybody, know how to figure it out, I will be well grateful and appreciate the help and effort.

Thanks a lot.

There is no need to modify any source code. You can add any extra options to “Video extra options” field in advanced section. You can hardcode full path of .ttf file there (enclosed in double-quotes if the path contains space).

This topic will be closed right after this new updated from my exploration experience:

the other way to show text in the view is to use ConerAnnotation:

Set text to “Something”


Set color to red


Update the view


1 Like

Good idea!

You can also add a logo as described on the screen capture module documentation page.