Z
ZS99241
Unregistered / Unconfirmed
GUEST, unregistred user!
发送:
var
VideoStream: TMemoryStream;
begin
VideoStream := TMemoryStream.Create;
CompressVideo(lpVhdr,AVCapturer1.VideoFormat,VideoStream);//这个过程是进行图像压缩并写入VideoStream中
IdUDPServer1.SendBuffer(Edt_Ip.Text,5027,VideoStream,VideoStream.Size);
VideoStream.Free;
end;
接收:
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
jpg:TJpegImage;
VideoStream:TMemoryStream;
begin
AData.ReadBuffer(VideoStream,AData.Size);
jpg := TJpegImage.Create;
jpg.LoadFromStream(VideoStream);
Image1.Picture.Bitmap.Assign(jpg);
VideoStream.Free;
jpg.Free;
end;
以上的代码能正常发送和接收图像,现想把存储视频流的VideoStream放入一个结构体中,然后进行发送
结构定入如下:
TVideoInfo = record
CMD: string[15];
VideoStream: TMemoryStream;
end;
发送:
var
VideoInfor: TVideoInfo;
begin
VideoInfor.VideoStream := TMemoryStream.Create;
CompressVideo(lpVhdr,AVCapturer1.VideoFormat,VideoInfor.VideoStream);//这个过程是进行图像压缩并写入VideoStream中
IdUDPServer1.SendBuffer(Edt_Ip.Text,5027,VideoInfor,SizeOf(VideoInfor));
VideoInfor.VideoStream.Free;
end;
接收:
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
jpg:TJpegImage;
VideoInfor: TVideoInfo;
begin
AData.ReadBuffer(VideoInfor,AData.Size);
jpg := TJpegImage.Create;
jpg.LoadFromStream(VideoInfo.VideoStream);//这里出错,各位说下,我想要实现把视频流放在一个结构中,该怎么写才对?
Image1.Picture.Bitmap.Assign(jpg);
VideoStream.Free;
jpg.Free;
end;
我的每帧图像大小在3K左右,现就是想把图像流放在memoryStream中,因为接收时要根据结构中的CMD指令来判断接收到的是什么数据,所以需要把图像流放在VideoInfo结构中,不知该如何处理?
var
VideoStream: TMemoryStream;
begin
VideoStream := TMemoryStream.Create;
CompressVideo(lpVhdr,AVCapturer1.VideoFormat,VideoStream);//这个过程是进行图像压缩并写入VideoStream中
IdUDPServer1.SendBuffer(Edt_Ip.Text,5027,VideoStream,VideoStream.Size);
VideoStream.Free;
end;
接收:
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
jpg:TJpegImage;
VideoStream:TMemoryStream;
begin
AData.ReadBuffer(VideoStream,AData.Size);
jpg := TJpegImage.Create;
jpg.LoadFromStream(VideoStream);
Image1.Picture.Bitmap.Assign(jpg);
VideoStream.Free;
jpg.Free;
end;
以上的代码能正常发送和接收图像,现想把存储视频流的VideoStream放入一个结构体中,然后进行发送
结构定入如下:
TVideoInfo = record
CMD: string[15];
VideoStream: TMemoryStream;
end;
发送:
var
VideoInfor: TVideoInfo;
begin
VideoInfor.VideoStream := TMemoryStream.Create;
CompressVideo(lpVhdr,AVCapturer1.VideoFormat,VideoInfor.VideoStream);//这个过程是进行图像压缩并写入VideoStream中
IdUDPServer1.SendBuffer(Edt_Ip.Text,5027,VideoInfor,SizeOf(VideoInfor));
VideoInfor.VideoStream.Free;
end;
接收:
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject;
AData: TStream;
ABinding: TIdSocketHandle);
var
jpg:TJpegImage;
VideoInfor: TVideoInfo;
begin
AData.ReadBuffer(VideoInfor,AData.Size);
jpg := TJpegImage.Create;
jpg.LoadFromStream(VideoInfo.VideoStream);//这里出错,各位说下,我想要实现把视频流放在一个结构中,该怎么写才对?
Image1.Picture.Bitmap.Assign(jpg);
VideoStream.Free;
jpg.Free;
end;
我的每帧图像大小在3K左右,现就是想把图像流放在memoryStream中,因为接收时要根据结构中的CMD指令来判断接收到的是什么数据,所以需要把图像流放在VideoInfo结构中,不知该如何处理?