我在我的项目中使用paslibvlc从获得一个视频摄像头在h.264流。我需要从此流中获取快照,并尝试使用vmem。我的项目编写于delphi 7。当我用字符串“rtsp:// ip/main”连接摄像机时,一切正常,但是当我设置回调和格式时,会出现访问存储器违规的错误。有人可以对我说,我做错了什么? 这是代码libvlc vmem访问冲突
PBytes = ^TBytes;
TBytes = array of byte;
var
MainForm: TMainForm;
ctx:TBytes;
const
cameraURL = 'rtsp://192.168.123.100/main';
function lock(opaque : Pointer; var planes : Pointer) : Pointer;
function unlock(opaque : Pointer; picture : Pointer; planes : Pointer) : Pointer;
function display(opaque : Pointer; picture : Pointer) : Pointer;
implementation
{$R *.dfm}
function lock(opaque : Pointer; var planes : Pointer) : Pointer;
begin
planes := x;
end;
function unlock(opaque : Pointer; picture : Pointer; planes : Pointer) : Pointer;
begin
end;
function display(opaque : Pointer; picture : Pointer) : Pointer;
begin
end;
procedure TMainForm.PlayerInit();
var
args: packed array[0..6] of PAnsiChar;
begin
libvlc_dynamic_dll_init();
SetLength(ctx, 1280*720*4+32);
if (libvlc_dynamic_dll_error <> '') then
begin
MessageDlg(libvlc_dynamic_dll_error, mtError, [mbOK], 0);
exit;
end;
args[0] := PAnsiChar(libvlc_dynamic_dll_path);
args[1] := '--no-video-title-show';
args[2] := '--no-xlib';
args[3] := '--no-audio';
p_li := libvlc_new(Length(args)-1, @args[0]);
p_mi := NIL;
end;
procedure TMainForm.PlayerPlay(fileName: WideString);
var
p_md: libvlc_media_t_ptr;
begin
btm:=Tbitmap.Create;
btm.Width:=1280;
btm.Height:=720;
PlayerStop();
// create new media from fileName
p_md := libvlc_media_new_path(p_li, PAnsiChar(System.UTF8Encode(fileName)));
//libvlc_media_player_set_media(p_mi, p_md);
p_mi := libvlc_media_player_new_from_media(p_md);
if (p_mi <> NIL) then
begin
libvlc_video_set_callbacks(p_mi,@lock,@unlock,@display,@ctx);
libvlc_video_set_format(p_mi, 'RV32', 1280, 720, 1280*4);
//libvlc_media_player_set_hwnd(p_mi, btm.Handle);
end;
// play
libvlc_media_player_play(p_mi);
// release media
if (p_md <> NIL) then
begin
libvlc_media_release(p_md);
// p_md := NIL;
end;
end;
procedure TMainForm.FormActivate(Sender: TObject);
begin
PlayerInit();
PlayerPlay(cameraURL);
end;
请在标签中指定Delphi版本。谢谢。顺便说一句,你为什么不让你的avatara透明?在蓝色背景中的白色边框只是看起来不圆滑;-) – 2013-03-20 16:03:25