forked from moonfdd/ffmpeg-go
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.go
96 lines (77 loc) · 2.17 KB
/
test.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package main
import (
// 导入 purego 包
"fmt"
"sync"
"github.com/dwdcth/ffmpeg-go/v7/ffcommon"
// "github.com/dwdcth/ffmpeg-go/v7/libavcodec"
"github.com/ebitengine/purego"
)
// func AvcodecGetName(id int32) (res ffcommon.FCharP) {
// var avcodec_get_name func(int32) ffcommon.FCharP
// purego.RegisterLibFunc(&avcodec_get_name, ffcommon.GetAvcodecLib(), "av_version_info")
// res = avcodec_get_name(id)
// return
// }
/*
var av_version_info func() string
var av_version_info_once sync.Once
func AvVersionInfo() (res ffcommon.FCharP){
av_version_info_once.Do(func() {
purego.RegisterLibFunc(&av_version_info, ffcommon.GetAvutilDll(), "av_version_info")
})
res = av_version_info()
return
}
*/
var av_version_info func() string
var av_version_info_once sync.Once
func AvVersionInfo() (res ffcommon.FCharP) {
av_version_info_once.Do(func() {
purego.RegisterLibFunc(&av_version_info, ffcommon.GetAvutilDll(), "av_version_info")
})
res = av_version_info()
return
}
func main() {
// // 加载动态库
// lib, err := purego.Dlopen("/lib/x86_64-linux-gnu/libavutil.so.56", purego.RTLD_NOW|purego.RTLD_GLOBAL)
// if err != nil {
// panic(err)
// }
// defer purego.Dlclose(lib)
// var av_version_info func() string
// purego.RegisterLibFunc(&av_version_info, lib, "av_version_info")
// res := av_version_info()
// fmt.Println(res)
// lib2, err := purego.Dlopen("/lib/x86_64-linux-gnu/libavcodec.so.58", purego.RTLD_NOW|purego.RTLD_GLOBAL)
// if err != nil {
// panic(err)
// }
// defer purego.Dlclose(lib2)
// var avcodec_get_name func(int32) string
// purego.RegisterLibFunc(&avcodec_get_name, lib2, "avcodec_get_name")
// res1 := avcodec_get_name(27)
// fmt.Println(res1)
res := AvVersionInfo()
res = AvVersionInfo()
res = AvVersionInfo()
fmt.Println(res)
}
/*
//dylib
func AvVersionInfo() (res ffcommon.FCharP) {
t, _, _ := ffcommon.GetAvutilDll().NewProc("av_version_info").Call()
if t == 0 {
}
res = ffcommon.StringFromPtr(t)
return
}
//purego
func AvVersionInfo() (res ffcommon.FCharP){
var av_version_info func() string
purego.RegisterLibFunc(&av_version_info, ffcommon.GetAvutilDll(), "av_version_info")
res = av_version_info()
return
}
*/