Home
AV module

VideoCapture

Cross-platform video device capturer backed by FFmpeg avdevice.

VideoCapture

#include <icy/av/videocapture.h>
class VideoCapture

Defined in src/av/include/icy/av/videocapture.h:26

Inherits: MediaCapture

Cross-platform video device capturer backed by FFmpeg avdevice.

List of all members

NameKindOwner
VideoCapturefunctionDeclared here
VideoCapturefunctionDeclared here
VideoCapturefunctionDeclared here
~VideoCapturefunctionDeclared here
openVideofunctionDeclared here
openVideofunctionDeclared here
PtrtypedefDeclared here
ClosingvariableInherited from MediaCapture
MediaCapturefunctionInherited from MediaCapture
~MediaCapturefunctionInherited from MediaCapture
MediaCapturefunctionInherited from MediaCapture
operator=functionInherited from MediaCapture
MediaCapturefunctionInherited from MediaCapture
operator=functionInherited from MediaCapture
openFilefunctionInherited from MediaCapture
closefunctionInherited from MediaCapture
startfunctionInherited from MediaCapture
stopfunctionInherited from MediaCapture
runfunctionInherited from MediaCapture
getEncoderFormatfunctionInherited from MediaCapture
getEncoderAudioCodecfunctionInherited from MediaCapture
getEncoderVideoCodecfunctionInherited from MediaCapture
setLoopInputfunctionInherited from MediaCapture
setLimitFrameratefunctionInherited from MediaCapture
setRealtimePTSfunctionInherited from MediaCapture
setOpenOptionsfunctionInherited from MediaCapture
setPassthroughVideofunctionInherited from MediaCapture
formatCtxfunctionInherited from MediaCapture
videofunctionInherited from MediaCapture
audiofunctionInherited from MediaCapture
stoppingfunctionInherited from MediaCapture
errorfunctionInherited from MediaCapture
_mutexvariableInherited from MediaCapture
_threadvariableInherited from MediaCapture
_formatCtxvariableInherited from MediaCapture
_videovariableInherited from MediaCapture
_audiovariableInherited from MediaCapture
_errorvariableInherited from MediaCapture
_stoppingvariableInherited from MediaCapture
_loopingvariableInherited from MediaCapture
_realtimevariableInherited from MediaCapture
_ratelimitvariableInherited from MediaCapture
_passthroughVideovariableInherited from MediaCapture
_openOptionsvariableInherited from MediaCapture
_videoStreamvariableInherited from MediaCapture
openStreamfunctionInherited from MediaCapture
emitfunctionInherited from MediaCapture
PtrtypedefInherited from MediaCapture
emittervariableInherited from ICapture
ICapturefunctionInherited from ICapture
~ICapturefunctionInherited from ICapture
startfunctionInherited from ICapture
stopfunctionInherited from ICapture
openFilefunctionInherited from ICapture
closefunctionInherited from ICapture
getEncoderFormatfunctionInherited from ICapture
getEncoderAudioCodecfunctionInherited from ICapture
getEncoderVideoCodecfunctionInherited from ICapture
openAudiofunctionInherited from ICapture
openVideofunctionInherited from ICapture
onStreamStateChangefunctionInherited from ICapture
openStreamfunctionInherited from ICapture
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
~PacketStreamAdapterfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
getEmitterfunctionInherited from PacketStreamAdapter
retentionfunctionInherited from PacketStreamAdapter
onStreamStateChangefunctionInherited from PacketStreamAdapter
_emittervariableInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
startfunctionInherited from Startable
stopfunctionInherited from Startable
RunnablefunctionInherited from Runnable
~RunnablefunctionInherited from Runnable
runfunctionInherited from Runnable
cancelfunctionInherited from Runnable
cancelledfunctionInherited from Runnable
exitvariableInherited from Runnable

Inherited from MediaCapture

KindNameDescription
variableClosingSignals that the capture thread is closing. This signal is emitted from the capture thread context.
functionMediaCapture
function~MediaCapture noexcept override
functionMediaCaptureDeleted constructor.
functionoperator=Deleted assignment operator.
functionMediaCaptureDeleted constructor.
functionoperator=Deleted assignment operator.
functionopenFile virtual overrideOpen a media file for decoding. Automatically detects video and audio streams.
functionclose virtual overrideStop the capture thread and close the media stream and all decoders.
functionstart virtual overrideStart the background capture and decode thread. Throws std::runtime_error if no media streams have been opened.
functionstop virtual overrideSignal the capture thread to stop and join it before returning.
functionrun virtual overrideEntry point for the background capture thread. Reads and decodes packets from the format context until EOF or stop() is called.
functiongetEncoderFormat virtual overrideFill format with the combined encoder-ready video and audio codec parameters.
functiongetEncoderAudioCodec virtual overrideFill params with the decoder's output audio codec parameters. Throws std::runtime_error if audio parameters have not been initialised.
functiongetEncoderVideoCodec virtual overrideFill params with the decoder's output video codec parameters. Throws std::runtime_error if video parameters have not been initialised.
functionsetLoopInputContinuously loop the input file when set.
functionsetLimitFramerateLimit playback to video FPS.
functionsetRealtimePTSSet to use realtime PTS calculation. This is preferred when using live captures as FFmpeg-provided values are not always reliable.
functionsetOpenOptionsSet demuxer options applied at the next openFile() call. Keys map to libavformat AVOption entries (e.g. "rtsp_transport", "fflags", "analyzeduration", "probesize"). Useful for live network sources that need low-latency hints. Pass an empty map to clear.
functionsetPassthroughVideoSkip the video decoder. Encoded video AVPackets from the input stream are emitted directly as [av::VideoPacket](icy-av-VideoPacket.html#videopacket) without decoding. The emitted packets carry the source's encoded payload and a time in microseconds rescaled from the stream's timebase. The iframe flag is set from AV_PKT_FLAG_KEY.
functionformatCtx const
functionvideo const
functionaudio const
functionstopping const
functionerror const
variable_mutex
variable_thread
variable_formatCtx
variable_video
variable_audio
variable_error
variable_stopping
variable_looping
variable_realtime
variable_ratelimit
variable_passthroughVideo
variable_openOptions
variable_videoStream
functionopenStream virtual overrideOpen the underlying media stream.
functionemit virtual overrideEmit an existing packet directly onto the outgoing signal.
typedefPtr

Inherited from ICapture

KindNameDescription
variableemitter
functionICapture inline
function~ICapture virtualDefaulted destructor.
functionstart virtual overrideStart capturing and emitting packets.
functionstop virtual overrideStop capturing and release device resources.
functionopenFile virtual inlineOpen a media file as the capture source.
functionclose virtual inlineRelease the capture source and any associated resources.
functiongetEncoderFormat virtualPopulate iformat with the encoder-ready format derived from this capture source.
functiongetEncoderAudioCodec virtual inlinePopulate params with the encoder-ready audio codec parameters.
functiongetEncoderVideoCodec virtual inlinePopulate params with the encoder-ready video codec parameters.
functionopenAudio virtual inlineOpen an audio capture device with the given parameters.
functionopenVideo virtual inlineOpen a video capture device with the given parameters.
functiononStreamStateChange virtual inline overrideReact to PacketStream state transitions by starting or stopping capture.
functionopenStream virtual inline

Inherited from PacketStreamAdapter

KindNameDescription
functionPacketStreamAdapterConstruct the adapter, binding it to the given packet signal.
function~PacketStreamAdapter virtual inline
functionemit virtualEmit a mutable raw buffer as a packet.
functionemit virtualEmit a read-only raw buffer as a packet (data is copied internally).
functionemit virtualEmit a string as a packet (data is copied internally).
functionemit virtualEmit a flag-only packet carrying no payload data.
functionemit virtualEmit an existing packet directly onto the outgoing signal.
functiongetEmitterReturns a reference to the outgoing packet signal.
functionretention virtual constReturns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.
functiononStreamStateChange virtual inlineCalled by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.
variable_emitter
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

Inherited from Startable

KindNameDescription
functionstart virtualStarts the object (e.g. begins processing or listening).
functionstop virtualStops the object (e.g. halts processing or closes resources).

Inherited from Runnable

KindNameDescription
functionRunnable inline
function~Runnable virtualDefaulted destructor.
functionrun virtualThe run method will be called by the asynchronous context.
functioncancel virtual inlineCancel the current task. The run() method should return ASAP.
functioncancelled virtual const inlineReturns true when the task has been cancelled.
variableexit

Public Methods

ReturnNameDescription
VideoCaptureConstruct without opening a device. Call openVideo() before start().
VideoCaptureConstruct and immediately open the given video device using a VideoCodec params struct.
VideoCaptureConstruct and immediately open the given video device with individual parameters.
voidopenVideo virtual overrideOpen the given video device using a VideoCodec params struct.
voidopenVideo virtualOpen the given video device with individual parameters. Configures the FFmpeg input format and passes device options via AVDictionary. If the device cannot satisfy the requested parameters, pixel format conversion and scaling will be applied by the decoder.

VideoCapture

VideoCapture()

Defined in src/av/include/icy/av/videocapture.h:32

Construct without opening a device. Call openVideo() before start().


VideoCapture

VideoCapture(const std::string & device, const av::VideoCodec & params)

Defined in src/av/include/icy/av/videocapture.h:37

Construct and immediately open the given video device using a VideoCodec params struct.

Parameters

  • device The platform video device identifier (e.g. "/dev/video0" or "0" on Windows).

  • params The desired capture parameters (width, height, fps, pixel format).


VideoCapture

VideoCapture(const std::string & device, int width = 0, int height = 0, double framerate = 0, const std::string & pixelFmt = "")

Defined in src/av/include/icy/av/videocapture.h:45

Construct and immediately open the given video device with individual parameters.

Parameters

  • device The platform video device identifier.

  • width The desired frame width in pixels, or 0 for device default.

  • height The desired frame height in pixels, or 0 for device default.

  • framerate The desired frame rate, or 0 for device default.

  • pixelFmt The desired pixel format string, or "" for "yuv420p".


openVideo

virtual override

virtual void openVideo(const std::string & device, const av::VideoCodec & params) override

Defined in src/av/include/icy/av/videocapture.h:52

Open the given video device using a VideoCodec params struct.

Parameters

  • device The platform video device identifier.

  • params The desired capture parameters.

Reimplements

openVideo

virtual

virtual void openVideo(const std::string & device, int width = 0, int height = 0, double framerate = 0, const std::string & pixelFmt = "")

Defined in src/av/include/icy/av/videocapture.h:63

Open the given video device with individual parameters. Configures the FFmpeg input format and passes device options via AVDictionary. If the device cannot satisfy the requested parameters, pixel format conversion and scaling will be applied by the decoder.

Parameters

  • device The platform video device identifier.

  • width The desired frame width in pixels, or 0 for device default.

  • height The desired frame height in pixels, or 0 for device default.

  • framerate The desired frame rate, or 0 for device default.

  • pixelFmt The desired pixel format string, or "" for "yuv420p".

Public Types

NameDescription
Ptr

Ptr

using Ptr = std::shared_ptr< VideoCapture >

Defined in src/av/include/icy/av/videocapture.h:29