From f93ee1a42e8c47e472332287b7350b66a6b0fa11 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期五, 24 七月 2020 18:28:57 +0800 Subject: [PATCH] 保存触发id之后的视频作为触发视频 --- gostream.go | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gostream.go b/gostream.go index 6345ebd..a0af494 100644 --- a/gostream.go +++ b/gostream.go @@ -8,19 +8,43 @@ import "unsafe" +// CloseStream close stream +func (h *GoFFMPEG) CloseStream() { + C.wrap_fn_close_stream(unsafe.Pointer(libcffmpeg), h.ffmpeg) +} + //GetAVPacket get AVPacket func (h *GoFFMPEG) GetAVPacket() ([]byte, int, int) { var key C.int var size C.int - p := C.wrap_fn_get_avpacket(h.ffmpeg, &size, &key) + p := C.wrap_fn_get_avpacket(unsafe.Pointer(libcffmpeg), h.ffmpeg, &size, &key) + defer C.free(unsafe.Pointer(p)) if size <= 0 { return nil, 0, -1 } - defer C.free(unsafe.Pointer(p)) d := C.GoBytes(p, size) s := int(size) k := int(key) return d, s, k } + +//GetAVPacket2 get AVPacket +func (h *GoFFMPEG) GetAVPacket2() (unsafe.Pointer, []byte, int, int) { + var key C.int + var size C.int + + p := C.wrap_fn_get_avpacket(unsafe.Pointer(libcffmpeg), h.ffmpeg, &size, &key) + if size <= 0 { + return nil, nil, 0, -1 + } + + const maxLen = 0x7fffffff + length := int(size) + data := (*[maxLen]byte)(unsafe.Pointer(p))[:length:length] + + k := int(key) + + return p, data, length, k +} -- Gitblit v1.8.0