DaWelter / h264decoder

h264 decoding module for python based on ffmpeg/libav
115 stars 61 forks source link

ImportError: No module named libh264decoder #1

Closed Ballan9 closed 5 years ago

Ballan9 commented 5 years ago

Hi I am trying to get this code to work in conjuction with a tello drone. But when i install all your packages it says theres a problem importing the libh264decoder. Is there a way you could help me get this working?

DaWelter commented 5 years ago

Hi. So you got it to build? Then there should be the libh264decoder.so library in the build dir. It must be found by Python when looking for imports, obviously. E.g. it can be next to your script files. Symlinks also work. The makefile should therefore create a symlink in the source dir.

Anyway, back when I made this, I just copied the .so to where it needed to be.

But that's not very good. There is a newer version with a "pythonic" setup.py script there: https://github.com/DaWelter/RCCar/tree/master/packages/h264decoder (I will close this repo. Everything pertaining to the model car project shall be in RCCar)

Ballan9 commented 5 years ago

I got everything to build except the lib264decoder. Cant figure out for the life of me what im doing wrong. I tried the new code and to run teh setup.py class in the RCcar h264decoder but it just came up with the error: Unable to find vcvarsall.bat. i just need the decoder to work becuase im trying to get this repo https://github.com/hanyazou/TelloPy to work. Which uses your decoder library

DaWelter commented 5 years ago

You are on windows? I never tried that. Right now I see only one reason why the CMake based build would not work. That is, that the library gets the wrong name. Like 'h264decoder.dll' instead 'libh264decoder.dll'. If so, try renaming it.

Apparently building a module with setup.py is a huge pain on Windows. I found relevant questions on stackoverflow. https://stackoverflow.com/questions/26136137/building-python-module-with-visual-studio-2012-and-setup-py https://stackoverflow.com/questions/11267463/compiling-python-modules-on-windows-x64 I can't support you with that. We should probably stick to CMake. At least on windows. Seems simpler.

DaWelter commented 5 years ago

I managed to get a windows build with MSVC to work. @Ballan9, please check the dev branch here if you still have trouble. There are additional notes in the readme.

Most importantly, I corrected the name of the library to libh264decoder.pyd

There is also support for Python 3. Beware that this is all relatively untested ...

For further assistance, I need to know what system you're on.

mferri17 commented 5 years ago

Same problem here on Windows 10 with Python 2.7 I am using this .pyd that DJI provides with his program for Tello drone (I suppose it is the same that @Ballan9 is using), but it doesn't work.

I noticed that the pyd I'm currently using do not show up with

import pkg_resources
dists = [d for d in pkg_resources.working_set]

neither it shows me any detail when I do help("modules libh264decoder").

I read you made a try to support building the package on Windows but I am new to Python and actually I don't know how I can do it. According to this answer I could create it easily but your repo does not have such setup.py, so I am pretty confused. Can you please help me building it or simply send me an already compiled .pyd?

Thanks in advance, have a nice day man.

DaWelter commented 5 years ago

Hi first, I'm not going to support forks or 3rd party builds. You probably want to contact the support from dji. See the bottom of this page https://github.com/dji-sdk/Tello-Python/tree/master/Tello_Video. There is a email address for sdk support.

Secondly, well, following your link, you see a build configuration which uses setuptools. It is a system to built (if required) and install python packages. But I don't use it here.

Instead, I worked on a CMake configuration for windows. CMake being another build system, mostly for c/c++ projects. libh264decoder is a python module implemented entirely in c/c++. So CMake is a suitable tool, in case you're wondering. Look in my dev branch. There are some notes in the readme. Maybe it helps you.

In the long run, I'll see if I can make a prebuilt module for distribution with pip. Previously I didn't think it was required since I didn't expect this to be actually used outside my private projects.

mferri17 commented 5 years ago

Hey there, thanks for your fast reply and sorry for my late. I wanted to contact DJI or try to get my hands on CMake these days, but I had no opportunities to do it. I have to postpone my tests, I will recontact you in case I have other problems in the future.

Thanks again and happy new year mate. See ya!

DaWelter commented 5 years ago

Okay, and happy new year. However, the people at DJI made some modifications of their own in order to be able to build the module on Windows and on the Mac. I was not aware of that. So, since this issue is actually a DJI issue, I'm going to close it. I leave the following note for anyone else who comes here:

I'm not affiliated with DJI. So, if you are a user of their SDK or their fork of this software, respectively, then please contact the support of DJI.

kesaroid commented 5 years ago

Hello, Facing the same issue with Windows 10 here. Contacted Ryzerobotics with the problem, but still no luck

johnadams2076 commented 5 years ago

1) Run the install.bat. 2) Please check the folder C:\Python27\Lib\site-packages. Does it have libh264decoder.pyd and at least 9 other dlls. Look for avodec-58.dll, avutil-56.dll etc.. ?

For venv, ensure that your C:\Tello-Python\venv does not have libh264decoder.pyd. Let me know.

kesaroid commented 5 years ago

Thanks @johnadams2076 for the reply, I shall check this. But install.bat looks fairly complex installing all dependencies from scratch. Is there a way to just install libh264decoder.pyd? and install the other dependencies manually?

Edit: libh264decoder.pyd does not appear in my Python27\Lib\site-packages. The install.bat file asks for admin rights and closes immediately. The problem maybe with the install.bat file itself? Please let me know.

Also, would love to see the same implemented on Python3.

kesaroid commented 5 years ago

install.bat file is not working properly for windows. I manually tried putting libh264decoder.pyd into site-packages as recommended but it still shows importerror.

johnadams2076 commented 5 years ago

Works for me. Check Pose Recognition in video. https://www.linkedin.com/feed/update/urn:li:activity:6498225445987852288 Okay. As a workaround, For Win-64, following files need to be downloaded into your C:\\Tello-Python\Tello_Video\install\Windows.

https://www.python.org/ftp/python/2.7.15/python-2.7.15.amd64.msi https://bootstrap.pypa.io/get-pip.py https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-20180825-844ff49-win64-shared.zip https://nchc.dl.sourceforge.net/project/boost/boost-binaries/1.68.0/boost_1_68_0-msvc-12.0-64.exe https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe

Type "command" in the search bar and right click. Select "Run as Administrator". cd to C:\\Tello-Python\Tello_Video\install\Windows. type "install"

It will extract and put files in the appropriate directories. Now check C:\Python27\Lib\site-packages. Pyd file along with several dlls must be present. Run main.py.

Hope this helps.

As for 3.6, I tried cmake for h264decoder. I got it compiled. Linker Ld.exe was looking for 3 dlls. I did not go further. I switched to the above method.

Lets explore what's possible and beyond.

bluebloodAxe commented 5 years ago

I account this problem on win10 and python 2.7 too.

zhushujiang commented 4 years ago

我也遇到这个问题,win10 和Python2.7 的运行报错

glitchwizard commented 3 years ago

I'm getting this error as well, with 2.7, and Windows 10, any solutions yet?

Works for me. Check Pose Recognition in video. https://www.linkedin.com/feed/update/urn:li:activity:6498225445987852288 Okay. As a workaround, For Win-64, following files need to be downloaded into your C:\Tello-Python\Tello_Video\install\Windows.

https://www.python.org/ftp/python/2.7.15/python-2.7.15.amd64.msi https://bootstrap.pypa.io/get-pip.py https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-20180825-844ff49-win64-shared.zip https://nchc.dl.sourceforge.net/project/boost/boost-binaries/1.68.0/boost_1_68_0-msvc-12.0-64.exe https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe

Type "command" in the search bar and right click. Select "Run as Administrator". cd to C:\Tello-Python\Tello_Video\install\Windows. type "install"

It will extract and put files in the appropriate directories. Now check C:\Python27\Lib\site-packages. Pyd file along with several dlls must be present. Run main.py.

Hope this helps.

As for 3.6, I tried cmake for h264decoder. I got it compiled. Linker Ld.exe was looking for 3 dlls. I did not go further. I switched to the above method.

Lets explore what's possible and beyond.

The middle link doesn't work anymore, anyone know where to get that file?