3d0c / gmf

Go Media Framework
MIT License
885 stars 170 forks source link

C.av_codec_iterate #111

Closed jens-bongartz closed 5 years ago

jens-bongartz commented 5 years ago

Hi, I am trying to install Live Stream Analyzer on my Raspberry Pi 3B+ (Raspbian Kernel 4.14.98-v7+) for which gmf is a prerequisite. I installed ffmpeg Version 3.2.12-1 via apt-get including all development packages (libavutil-dev, libavcodec-dev, etc.)

libavutil 55. 34.101 / 55. 34.101 libavcodec 57. 64.101 / 57. 64.101 libavformat 57. 56.101 / 57. 56.101 libavdevice 57. 1.100 / 57. 1.100 libavfilter 6. 65.100 / 6. 65.100 libavresample 3. 1. 0 / 3. 1. 0 libswscale 4. 2.100 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 / 54. 1.100

Unfortunately "go get" installation of gmf exit with the following error message:

#github.com/3d0c/gmf could not determine kind of name for C.av_codec_iterate

Thankful for any hints to solve this issue.

Cheers Jens

3d0c commented 5 years ago

Hi, @jens-bongartz Unfortunately it won't work with ffmpeg version 3. Here is a changelog https://github.com/FFmpeg/FFmpeg/blob/master/doc/APIchanges#L125 This function has been introduced in version 4.

jens-bongartz commented 5 years ago

Thanks for the quick response. After checking the actual FFmpeg version I thought that this could be the issue. I will try to install version 4 and post results ....

jens-bongartz commented 5 years ago

OK. After installing FFmepg 4.1.3 (which took a while and a lot of "apt-get" of missing packages) and removing the outdated libav*** packages the error disappeared. But a new issues occured:

# github.com/3d0f/gmf /usr/bin/ld: cannot find -lmmal_core /usr/bin/ld: cannot find -lmmal_util /usr/bin/ld: cannot find -lmmal_vc_client /usr/bin/ld: cannot find -lbcm_host

Google told me that: MMAL (Multimedia Abstraction Layer) is a C library designed by Broadcom for use with the Videocore IV GPU found on the Raspberry Pi.

sudo find / -name "libmmal*" pointed me to the /opt/vc/lib folder where these libraries resides and export LIBRARY_PATH=/opt/vc/lib resolved this issue.

But then again I ran into a whole bunch of errors:

github.com/3d0c/gmf go/src/github.com/3d0c/gmf/avio_go16.go:115: cannot use _Cfunc_avio_alloc_context(this.buffer, C.int(bufferSize), C.int(flag), _cgoCheckPointer0(unsafe.Pointer(ctx.avCtx)), ptrRead, ptrWrite, ptrSeek) (type C.struct_AVIOContext) as type C.AVIOContext in assignment go/src/github.com/3d0c/gmf/filter_go16.go:37: cannot use _Cfunc_avfilter_graph_alloc() (type C.struct_AVFilterGraph) as type C.AVFilterGraph in field value go/src/github.com/3d0c/gmf/filter_go16.go:53: cannot convert &inputs (type C.AVFilterInOut) to type C.struct_AVFilterInOut go/src/github.com/3d0c/gmf/filter_go16.go:53: cannot convert &outputs (type C.AVFilterInOut) to type C.struct_AVFilterInOut go/src/github.com/3d0c/gmf/filter_go16.go:61: cannot use &inputs (type C.AVFilterInOut) as type C.struct_AVFilterInOut in argument to func literal go/src/github.com/3d0c/gmf/filter_go16.go:62: cannot use &outputs (type C.AVFilterInOut) as type C.struct_AVFilterInOut in argument to func literal go/src/github.com/3d0c/gmf/filter_go16.go:64: cannot use curr.next (type C.struct_AVFilterInOut) as type C.AVFilterInOut in assignment go/src/github.com/3d0c/gmf/filter_go16.go:120: cannot convert &ctx (type C.AVFilterContext) to type C.struct_AVFilterContext go/src/github.com/3d0c/gmf/filter_go16.go:212: cannot convert &f.filterGraph (type C.AVFilterGraph) to type C.struct_AVFilterGraph go/src/github.com/3d0c/gmf/format_go16.go:538: cannot use val.avAVIOContext (type C.AVIOContext) as type C.struct_AVIOContext in assignment go/src/github.com/3d0c/gmf/format_go16.go:538: too many errors

I suppose it is still a lib issue but this is beyond my scope.

Thanks for your help!

Jens

jens-bongartz commented 5 years ago

For the records: I fiddled a little bit around in the source code without honestly really knowing what I was doing. In avio_go16.go and filter_go16.go I replaced all Ctype statements with C.struct_ and finally in options.go16 I changed in line 35 C.uchar into C.uint8_t. All of a sudden the code compiled without any further errors and I got the Live Stream Analyzer to run.

3d0c commented 5 years ago

@jens-bongartz Hm, what version of Go do you have?

jens-bongartz commented 5 years ago

I installed golang with apt-get from the Raspbian repository. It is go 1.7.4 linux/arm.

gidoBOSSftw5731 commented 5 years ago

Hey! I have this exact same issue! Im on x86_64 go....

go version go1.12.5 linux/amd64

3d0c commented 5 years ago

@gidoBOSSftw5731 You mean a lot of "cannot convert" errors?

gidoBOSSftw5731 commented 5 years ago

well, one, as shown below:

[21:39:35 - 19-05-24] /home/gido5731/work/discord-music-bot % go get github.com/3d0c/gmf                                              # github.com/3d0c/gmf
../../go/src/github.com/3d0c/gmf/codecDesc.go:38:10: could not determine kind of name for C.av_codec_iterate
3d0c commented 5 years ago

@gidoBOSSftw5731 Check your ffmpeg version, it should be 4 or higher over even better install it from the latest master.

gidoBOSSftw5731 commented 5 years ago

Ah, thanks!