修复问题

This commit is contained in:
2025-09-28 11:25:04 +08:00
parent 8024f53bce
commit 42a6af7c53

View File

@@ -464,27 +464,11 @@ public class MediaTransferFlvByJavacv extends MediaTransfer implements Runnable
finishWindow();
}
// 完全重新创建Frame避免使用转换器
int width = src.cols();
int height = src.rows();
int depth = src.depth();
int channels = src.channels();
// 安全处理跳过检测模式直接使用grabber.grab()
frame = grabber.grab();
// 创建新的Frame
frame = new Frame(width, height, Frame.DEPTH_UBYTE, channels);
// 将Mat数据复制到Frame
ByteBuffer frameBuffer = (ByteBuffer)frame.image[0];
frameBuffer.clear();
// 确保Mat是连续的
Mat continuous = src.isContinuous() ? src : src.clone();
byte[] matData = new byte[Math.toIntExact(continuous.total() * continuous.elemSize())];
continuous.data().get(matData);
// 复制数据
frameBuffer.put(matData);
frameBuffer.rewind();
// 如果需要,可以在这里添加日志
log.debug("检测模式下使用直接抓取帧");
} else {
frame = grabber.grab();
}