kidrigger / godot-videodecoder

GDNative Video Decoder libraries for Godot Game Engine, using FFmpeg library for codecs. A Google Summer of Code Project, 2018
MIT License
84 stars 22 forks source link

Can't run godot project #14

Closed marcosjouron closed 3 years ago

marcosjouron commented 5 years ago

Hi @KidRigger, first of all thank for your code. It helps me but i have a little problem. I'm a bit newbie in linux. I follow your steps and compile FFMPEG ok, then i try to build your library with: clang -std=c11 -fPIC -c -I../../godot_headers gdnative_videodecoder.c -o gdnative_videodecoder.os and clang -shared gdnative_videodecoder.os -o ../test/addons/libgdnative_videodecoder.so Is that the correct way to compile your files?

Tehn I placed all the files right in the folders but when i run the godot project i got error:

"E 0:00:00:0185 Can't open dynamic library: /home/jouronm/godot_workspace/godot-videodecoder/test/addons/libgdnative_videodecoder.so. Error: /home/jouronm/godot_workspace/godot-videodecoder/test/addons/libgdnative_videodecoder.so: undefined symbol: av_packet_unref

drivers/unix/os_unix.cpp:427 @ open_dynamic_library()" Library is in the right place and i be sure because i remove it and run it again the Godot project then it told me "library not found" It is possible that ffmpeg compilation with gcc will no be compatible with clang compilation for your library? Thx in advance.
kidrigger commented 5 years ago

Thanks for your feedback.

For compilation use SCons, scons platform=x11

I suppose the README needs to be updated. Thanks for pointing it out!

That'll automatically compile and place the compiled libraries in the bin folder, and also inside the Godot project. The error is caused due to the videodecoder library being unable to find FFmpeg due to different configuration.

marcosjouron commented 5 years ago

@KidRigger you were very, very kind. But one question, My default compiler is GCC, it is ok? Cheers.

kidrigger commented 5 years ago

Yes, it mostly shouldn't give trouble (I've built it on Manjaro with GCC EDIT - This claim was incorrect) Let me know if you have any more issues, if not, we'll close this issue.

marcosjouron commented 5 years ago

Well yes i have problems compling it, i will show you let me a minutes and i prepare you a detailed description. Thx

marcosjouron commented 5 years ago

Hi again @KidRigger , here i go: I use scons platform=x11 and the log is:

scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... gcc -o src/gdnative_videodecoder.os -c -fPIC -g -Ithirdparty/include -Igodot_include src/gdnative_videodecoder.c In file included from src/gdnative_videodecoder.c:14:0: src/set.h: In function 'set_print': src/set.h:79:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode for (int i = 0; i < depth; i++) { ^ src/set.h:79:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code

Then i edit Sconstruc and i add this line:

#env.Append( CCFLAGS=["-std=c11"] )

Try it again scons platform=x11:

**scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... gcc -o bin/x11/libgdnative_videodecoder.so -shared -Wl,-rpath=\$ORIGIN/lib/ src/gdnative_videodecoder.os -Lbin/x11 -lavformat -lavcodec -lavutil -lswscale -lswresample /usr/bin/ld: //usr/local/lib/libavformat.a(allformats.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC //usr/local/lib/libavformat.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status scons: * [bin/x11/libgdnative_videodecoder.so] Error 1 scons: building terminated because of errors.

I edit again Sconstruc and add:

env.Append( LDFLAGS=["-fPIC"] )

After that i try again scons but i get the same error than before and at this point i'm stucked.

Sorry if I'have been so much detailed but this way i be sure that you could understand the problem. Thx :)

kidrigger commented 5 years ago

I checked my build - it does use clang and not gcc. - so my previous claim was incorrect. Could you try working with that? I'll investigate the errors earliest I can (I'm sorry I can't do this right now) Reopening the issue until it's actually resolved.

marcosjouron commented 5 years ago

@KidRigger i will ask you for some to test before go more deep. It is possible you send me your working directory for check if i can run the godot video-coder test project with the plung just compiled?.

Now I just compile the plugin this way with clang: clang -std=c11 -fPIC -c -I../../godot_headers gdnative_videodecoder.c -o gdnative_videodecoder.os clang -shared gdnative_videodecoder.os -o ../test/addons/libgdnative_videodecoder.so

Once up libgdnative_videodecoder.so is compiled and copied in test/addons/bin/x11. Next step load the godot test project and finally run it, i get this errors:

E 0:00:00:0192 Can't open dynamic library: /home/jouronm/godot_workspace/godot-videodecoder/test/addons/bin/x11/libgdnative_videodecoder.so. Error: libavformat.so.58: cannot open shared object file: No such file or directory E 0:00:00:0192 No valid library handle, can't get symbol from GDNative object E 0:00:00:0192 No nativescript_init in "res://addons/bin/x11/libgdnative_videodecoder.so" found

Of course all the ffmpeg libs are copied into test/addons/bin/x11

Cheers.

marcosjouron commented 5 years ago

Hi again @KidRigger, after a lot try and errors finally i get it work. I compiled ffmpeg using my default compiler (gcc): (sudo of course is optional if you have enough rights)

sudo make distclean sudo ./configure --enable-shared --enable-version3 --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-opencl --enable-opengl --disable-debug --prefix=../godot-videodecoder/thirdparty sudo make -j8 sudo make -j8 install

and also your plugin with your instructions:

scons platform=x11

Also i did a changes in your code to write a logfile, it help me a lot to find some issues. Fell free to ask me for your code modified, even it is very simple to do.

After that i had some troubles setting up godot test project but at the end it all works.

Now i get stucked because I'm not able to play ogv neither webm files. I check that i have the codecs installed correctly.

Cheers.

jamie-pate commented 3 years ago

The project has been reworked to use docker for builds and the codecs are built in statically. Please try again with the latest version.