Get Video Data Post-Compression Pre-Writing

Hello,

I have a video stream that I’m compressing and writing to a video file. Is there a way to get the data post-compression but prior to writing the video file? Or is ffmpeg compressing and then writing without any opencv hooks in between?

As far as I know, cv::VideoWriter doesn’t expose the encoded packets: it hands raw frames to the backend (FFmpeg, GStreamer, etc.) which encodes and muxes them internally, so there is no hook between the two steps. If you need the compressed data, the usual options are to encode yourself with FFmpeg/libav (or PyAV) and write the packets wherever you like, or to use a GStreamer pipeline with an appsink after the encoder element and open it via VideoWriter with CAP_GSTREAMER. Which one fits depends on whether you need H.264 packets or just an MJPEG-style stream.