video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-07-22 d42f702ea93b3d34a300ad2f1f72db4d7bb9cc80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package goffmpeg
 
/*
#include <stdlib.h>
#include "libcffmpeg.h"
 
extern void cb_rec_proxy(char*, int);
void cb_rec(char* path, int i){
    cb_rec_proxy(path, i);
}
extern void cb_dec_proxy(void *data, int w, int h);
void cb_dec(void*data, int w, int h){
    cb_dec_proxy(data, w, h);
}
*/
import "C"
import (
    "unsafe"
)
 
// ActiveRecorder active recorer
func (h *GoFFMPEG) ActiveRecorder(output string, mind, maxd int, fn RecorderFunc) {
    out := C.CString(output)
    defer C.free(unsafe.Pointer(out))
 
    funcRecorder = fn
 
    cFn := (C.rec_func)(unsafe.Pointer(C.cb_rec))
    C.wrap_fn_active_recorder(h.ffmpeg, out, C.int(mind), C.int(maxd), cFn)
}
 
// ActiveDecoder active decoder
func (h *GoFFMPEG) ActiveDecoder(fn DecoderFunc) {
    funcDecoder = fn
 
    cFn := (C.dec_func)(unsafe.Pointer(C.cb_dec))
    C.wrap_fn_active_decoder(h.ffmpeg, cFn)
}