MichaelMathieu / THFFmpeg

Torch bindings for FFmpeg (reading videos only)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation Issue

javierselva opened this issue · comments

Hi,
I'm trying to make VideoPredictionICLR2016 work on a Docker container (JIC the dockerfile can be found here). So far I've managed to install everything but THFFmpeg. Actually, it installs but the code still fails. I get /root/torch/install/bin/luajit: symbol lookup error: /root/torch/install/lib/lua/5.1/libthffmpeg.so: undefined symbol: av_frame_free when running th train_iclr_model.lua.
As far as my understanding goes this is due to a problem with FFmpeg version. I've followed this tutorial and installed version 2.8.5 but the problem persists. From reading what you said about this I think that the problem is that when installing THFFmpeg it cannot find the proper FFmpeg version. This is the output for luarocks make:

Warning: unmatched variable LUALIB
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Torch7 in /root/torch/install
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26") 
-- checking for module 'libavcodec'
--   found libavcodec, version 54.35.1
-- checking for module 'libavformat'
--   found libavformat, version 54.20.4
-- checking for module 'libavutil'
--   found libavutil, version 52.3.0
-- Found FFMPEG or Libav: /usr/lib/x86_64-linux-gnu/libavcodec.so;/usr/lib/x86_64-linux-gnu/libavformat.so;/usr/lib/x86_64-linux-gnu/libavutil.so, /usr/include
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:    LUALIB
-- Build files have been written to: /root/thffmpeg/build
Scanning dependencies of target thffmpeg
[100%] Building C object CMakeFiles/thffmpeg.dir/thffmpeg.c.o
Linking C shared module libthffmpeg.so
[100%] Built target thffmpeg
[100%] Built target thffmpeg
Install the project...
-- Install configuration: "Release"
-- Installing: /root/torch/install/lib/luarocks/rocks/thffmpeg/1.0.alpha-0/lib/libthffmpeg.so
-- Set runtime path of "/root/torch/install/lib/luarocks/rocks/thffmpeg/1.0.alpha-0/lib/libthffmpeg.so" to "$ORIGIN/../lib:/root/torch/install/lib"
-- Installing: /root/torch/install/lib/luarocks/rocks/thffmpeg/1.0.alpha-0/lua/thffmpeg/init.lua
-- Installing: /root/torch/install/lib/luarocks/rocks/thffmpeg/1.0.alpha-0/lua/thffmpeg/test.lua
-- Installing: /root/torch/install/lib/luarocks/rocks/thffmpeg/1.0.alpha-0/lua/thffmpeg/README.md
cmake -E make_directory build && cd build && cmake .. -DLUALIB= -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/root/torch/install/bin/.." -DCMAKE_INSTALL_PREFIX="/root/torch/install/lib/luarocks/rocks/thffmpeg/1.0.alpha-0" && make
   
cd build && make install
Updating manifest for /root/torch/install/lib/luarocks/rocks
thffmpeg 1.0.alpha-0 is now built and installed in /root/torch/install/ (license: BSD)

It seems to me that it finds Libav but not FFmpeg. In the README you suggest manually specifying some paths but I'm not quite sure what content do I have to point to.

From the FFmpeg compilation guide I linked avobe the FFmpeg content I have in my system is:

  • ffmpeg_sources – Where the source files will be downloaded. This can be deleted if desired when finished with the guide.
  • ffmpeg_build – Where the files will be built and libraries installed. This can be deleted if desired when finished with the guide.
  • bin – Where the resulting binaries (ffmpeg, ffplay, ffserver, x264, x265) will be installed.

From the script that checks where FFmpeg is in the system I thought that FFMPEG_INCLUDE_DIR and FFMPEG_LIBRARIES should point to ffmpeg_build/include and ffmpeg_build/lib but a simple export didn't do the trick.

Now for my actual questions:
In the README you say that for this kind of problem we should try:

luarocks make
cd build
ccmake .
#set the correct paths
cd ..
luarocks make

First, is ccmake necessary instead of just using cmake?
Second, # set the correct paths to what? In which variables?
Finally, I'm not quite used to compiling libraries, and so when you suggest "add -I/usr/include/ffmpeg to the CXX and C flags, in ccmake ." is that regarding the same as the comment in your script quoted avobe? If so, would the resulting script be something like...?:

luarocks make
cd build
ccmake . -I /usr/include/ffmpeg
cd ..
luarocks make

As I explained above I don't have any folder such as /usr/include/ffmpeg, only the ones described by the tutorial.

The system uses Cuda 7.5 and cudnn 4 on Ubuntu 14.04. If you need any more information just let me know.

Thank you very much in advance for your help.

Edit: Tried to set CMAKE_C_FLAGS and CMAKE_CXX_FLAGS to /root/ffmpeg_build/include and /root/bin (where ffmpeg is installed) with no success (I just exported them before calling cmake . but maybe that's not the proper way (?) )
Edit 2: I think my problem is hugely related with this. I'm going to try some of the solutions outlined there. Edit 2.5: I think this may be the problem, but as I:

  • don't know what version of Libav whould THFFmpeg need in order to work properly
  • AND given the fact that I am unable to "locate" files inside a Doker (probably is possible but haven't managed, maybe files aren't indexed inside docker and that's the reason some tools like "find" and "locate" don't work properly)
  • AND not quite sure that uninstalling libav woudn't affect other libraries that the code for video prediction needs to work, I am quite stuck here.

So probably it would be best to simply be able to point THFFmpeg building process to the correct FFmpeg includes and libraries, but still I haven't found out how.