简短的回答是否定的。
首先,VideoWriter 不能同时读写。您可以做的是创建两个使用ipcpipeline 元素相互通信的管道。
例如
cv::VideoWriter out("appsrc ! videoconvert ! video/x-raw,width=1280,height=720 ! v4l2h264enc ! ipcpipelinesink",...);
cv::VideoCapture cap("ipcpipelinesrc ! ... ! appsink")
但这不会为您提供很多选择,因为VideoCapture 支持的数据格式非常有限,如果您查看souce code。
// we support 11 types of data:
// video/x-raw, format=BGR -> 8bit, 3 channels
// video/x-raw, format=GRAY8 -> 8bit, 1 channel
// video/x-raw, format=UYVY -> 8bit, 2 channel
// video/x-raw, format=YUY2 -> 8bit, 2 channel
// video/x-raw, format=YVYU -> 8bit, 2 channel
// video/x-raw, format=NV12 -> 8bit, 1 channel (height is 1.5x larger than true height)
// video/x-raw, format=NV21 -> 8bit, 1 channel (height is 1.5x larger than true height)
// video/x-raw, format=YV12 -> 8bit, 1 channel (height is 1.5x larger than true height)
// video/x-raw, format=I420 -> 8bit, 1 channel (height is 1.5x larger than true height)
// video/x-bayer -> 8bit, 1 channel
// image/jpeg -> 8bit, mjpeg: buffer_size x 1 x 1
// bayer data is never decoded, the user is responsible for that
// everything is 8 bit, so we just test the caps for bit depth