Medical Imaging Interaction Toolkit  2023.12.99-0ad8945f
Medical Imaging Interaction Toolkit
mitk::VideoRecorder Class Reference

Record the contents of a render window as video using FFmpeg as external command-line application. More...

#include <mitkVideoRecorder.h>

Public Types

enum  OutputFormat { OutputFormat::WebM_VP9, OutputFormat::MP4_H264 }
 

Public Member Functions

 VideoRecorder ()
 
 ~VideoRecorder ()
 
 VideoRecorder (const VideoRecorder &)=delete
 
VideoRecorderoperator= (const VideoRecorder &)=delete
 
std::filesystem::path GetFFmpegPath () const
 
void SetFFmpegPath (const std::filesystem::path &path)
 
std::filesystem::path GetOutputPath () const
 
void SetOutputPath (const std::filesystem::path &path)
 
OutputFormat GetOutputFormat () const
 
void SetOutputFormat (OutputFormat format)
 
std::string GetRenderWindowName () const
 
void SetRenderWindowName (const std::string &renderWindowName)
 
int GetFrameRate () const
 
void SetFrameRate (unsigned int fps)
 
void StartRecording ()
 
void RecordFrame () const
 
int StopRecording ()
 

Static Public Member Functions

static std::string GetFileExtension (OutputFormat format)
 Get the file extension corresponding to the specified video output format. More...
 

Detailed Description

Record the contents of a render window as video using FFmpeg as external command-line application.

Before recording, set the render window, the path to FFmpeg, the path to the video output file, its format/codec, and frame rate.

Most settings have decent defaults, e.g., the royalty-free and open VP9 video codec in a WebM container as output format and a frame rate of 30 frames per second.

If not set explicitly, the FFmpeg path and output format are queried from the preferences, if available.

Call StartRecording() to begin a recording session, record each frame with RecordFrame(), and end the recording session with a call to StopRecording(). StopRecording() is a blocking call that may take a long time to return since it calls FFmpeg to encode the recorded frames into a video. Consider calling it from a separate thread.

The VideoRecorder throws an Exception on any error. It is advised to use it within a try/catch block.

Definition at line 40 of file mitkVideoRecorder.h.

Member Enumeration Documentation

◆ OutputFormat

Enumerator
WebM_VP9 
MP4_H264 

Definition at line 43 of file mitkVideoRecorder.h.

Constructor & Destructor Documentation

◆ VideoRecorder() [1/2]

mitk::VideoRecorder::VideoRecorder ( )

◆ ~VideoRecorder()

mitk::VideoRecorder::~VideoRecorder ( )

◆ VideoRecorder() [2/2]

mitk::VideoRecorder::VideoRecorder ( const VideoRecorder )
delete

Member Function Documentation

◆ GetFFmpegPath()

std::filesystem::path mitk::VideoRecorder::GetFFmpegPath ( ) const

◆ GetFileExtension()

static std::string mitk::VideoRecorder::GetFileExtension ( OutputFormat  format)
static

Get the file extension corresponding to the specified video output format.

Returns
A file extension string like ".webm" or ".mp4".

◆ GetFrameRate()

int mitk::VideoRecorder::GetFrameRate ( ) const

◆ GetOutputFormat()

OutputFormat mitk::VideoRecorder::GetOutputFormat ( ) const

◆ GetOutputPath()

std::filesystem::path mitk::VideoRecorder::GetOutputPath ( ) const

◆ GetRenderWindowName()

std::string mitk::VideoRecorder::GetRenderWindowName ( ) const

◆ operator=()

VideoRecorder& mitk::VideoRecorder::operator= ( const VideoRecorder )
delete

◆ RecordFrame()

void mitk::VideoRecorder::RecordFrame ( ) const

◆ SetFFmpegPath()

void mitk::VideoRecorder::SetFFmpegPath ( const std::filesystem::path &  path)

◆ SetFrameRate()

void mitk::VideoRecorder::SetFrameRate ( unsigned int  fps)

◆ SetOutputFormat()

void mitk::VideoRecorder::SetOutputFormat ( OutputFormat  format)

◆ SetOutputPath()

void mitk::VideoRecorder::SetOutputPath ( const std::filesystem::path &  path)

◆ SetRenderWindowName()

void mitk::VideoRecorder::SetRenderWindowName ( const std::string &  renderWindowName)

◆ StartRecording()

void mitk::VideoRecorder::StartRecording ( )

◆ StopRecording()

int mitk::VideoRecorder::StopRecording ( )

The documentation for this class was generated from the following file: