video

The video I/O subsystem — pipelang VideoFrame plus the input streams that feed it.

For new components, the canonical pieces are VideoFrame (the pipelang type) and FfmpegInputStream (the input you'll reach for in 90% of cases). OCVVideoStream is a GStreamer fallback for the cases where the FFmpeg path doesn't fit.

VideoFrame

Header: pipelogic/video/frame.hpp. Implementation: src/frame.cpp.

The pipelang named type (also re-exported from pipelogic/cv/image.hpp):

using VideoFrameData = pipelang::Record<
    RecordField<"image",     ocv::types::Image>,
    RecordField<"timestamp", UInt64>>;
using VideoFrame = pipelang::Named<"VideoFrame", VideoFrameData>;

The Python mirror is pipelogic.cv.Image. The C++ wrapper class is also ocv::Image — a VideoFrame is just an Image with a microsecond timestamp.

frame.hpp provides constructors and conversion to/from cv::Mat. Lifetime: the underlying pixel buffer is owned by the backend value; cv::Mat views must not outlive the buffer.

videos::InputStream and OutputStream

The base ABC plus operator>> / operator<< sugar:

class InputStream {
public:
  virtual VideoFrame read() = 0;
  virtual bool eof() const = 0;
  virtual ~InputStream() = default;
};

class OutputStream {
public:
  virtual void write(VideoFrame) = 0;
  virtual void close() = 0;
  virtual ~OutputStream() = default;
};

VideoFrame operator>>(InputStream&, VideoFrame&);
OutputStream& operator<<(OutputStream&, const VideoFrame&);

video::FfmpegInputStream

The canonical input stream for files, RTSP/RTSPS, RTMP/RTMPS, and HTTP video.

class FfmpegInputStream : public InputStream {
public:
  explicit FfmpegInputStream(const std::string& url,
                             std::map<std::string, std::string> options = {});

  VideoFrame read() override;
  bool eof() const override;

  int width() const, height() const;
  double fps() const;
  std::string pixel_format() const;
};

url accepts any libav protocol (file, http, https, rtsp, rtsps, rtmp, rtmps, udp, rtp, srt). options is passed verbatim to FFmpeg's AVDictionary — used by input-video-url to set tls_verify, protocol_whitelist, etc.

video::OCVVideoStream

OpenCV-based input via cv::VideoCapture. Reach for it when you specifically need OpenCV's GStreamer integration; otherwise use FfmpegInputStream.

class OCVVideoStream : public InputStream {
public:
  explicit OCVVideoStream(const std::string& url, int api = cv::CAP_ANY);
  // ...
};

Pixel formats

FfmpegInputStream defaults to BGR24 output. Other formats need options["pixel_format"] = "yuv420p" (or similar) at construction. Conversion to BGR via ocv::Image::convert() is the safe fallback.

What's next

Was this page helpful?