fix(ffmpeg): copy C allocated buffer to Go memory

This commit is contained in:
Adrian Shum 2022-09-09 17:52:36 +08:00
parent 51ff1bbbd3
commit 1493db09b2

View file

@ -282,7 +282,7 @@ func encodeFrameImage(av *AVContext) ([]byte, error) {
if err < 0 {
return nil, avError(err)
}
p := (*[1 << 30]byte)(unsafe.Pointer(pkt.data))[:pkt.size:pkt.size]
p := C.GoBytes(unsafe.Pointer(pkt.data), pkt.size)
if pkt.buf != nil {
C.av_packet_unref(&pkt)
}