修复问题
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user