Conscience Core
Public Member Functions | List of all members
conscience_core::media_capture::CscCaptureFileRecorder Class Reference

#include <CscCaptureFileRecorder.h>

Public Member Functions

 CscCaptureFileRecorder (CscCaptureEngine *captureEngine, fs::path outputPath, const string &logPrefix)
 
 ~CscCaptureFileRecorder ()
 
void setDurationSeconds (short durationSeconds)
 
void start ()
 
optional< fs::path > tryGetRecording (const fs::path &snapshotOutputPath=fs::temp_directory_path()/("recordingSnapshot_"+to_string(nowMillis())+".mp4"))
 
void close ()
 
fs::path getOutputPath () const
 

Detailed Description

This component records a stream from a capture engine to a video file. It has 2 modes: 1) simple: records everything until close is called 2) rolling: records last X seconds maximum (shorter of course if close is called after start before reaching duration). In this mode, once duration is reached, video file is trimmed so only the last seconds remain. IMPORTANT: this 2nd mode is not suited for long recordings (not efficient for this need). This should only be used for a few seconds. A warning will be printed for duration > 60s

Note
for now, output format is hardcoded to mp4. Please implement other format as needed, ffmpeg natively supports many things (mp4 with H.264, H.265, ...)

Constructor & Destructor Documentation

◆ CscCaptureFileRecorder()

conscience_core::media_capture::CscCaptureFileRecorder::CscCaptureFileRecorder ( CscCaptureEngine captureEngine,
fs::path  outputPath,
const string &  logPrefix 
)
Parameters
outputPathshould end with .mp4

◆ ~CscCaptureFileRecorder()

conscience_core::media_capture::CscCaptureFileRecorder::~CscCaptureFileRecorder ( )

Member Function Documentation

◆ close()

void conscience_core::media_capture::CscCaptureFileRecorder::close ( )

output file is complete, and recorder cannot be used anymore

◆ getOutputPath()

fs::path conscience_core::media_capture::CscCaptureFileRecorder::getOutputPath ( ) const

◆ setDurationSeconds()

void conscience_core::media_capture::CscCaptureFileRecorder::setDurationSeconds ( short  durationSeconds)

Changes recorder mode (mode #2) to enable a rotating recording of X seconds. Only the last X seconds will be in the resulting file. Only possible when recorder is stopped.

Parameters
durationSecondsmaximum duration of the video file. Should not exceed 60 (see WARNING)
See also
class description

◆ start()

void conscience_core::media_capture::CscCaptureFileRecorder::start ( )

◆ tryGetRecording()

optional< fs::path > conscience_core::media_capture::CscCaptureFileRecorder::tryGetRecording ( const fs::path &  snapshotOutputPath = fs::temp_directory_path() / ("recordingSnapshot_" + to_string(nowMillis()) + ".mp4"))

Returns a path to an up to date recording (last X seconds) without stopping recording IMPORTANT: This requires video cut and merge, reuse result if you can. Note: for now, output format is hardcoded to mp4. Please implement other format as needed, ffmpeg natively supports many things (mp4 with H.264, H.265, ...)

Returns
empty if recorder is not opened yet

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