e-lab / torch-toolbox

A collection of snippets and libraries for Torch from e-Lab
https://engineering.purdue.edu/elab/
199 stars 64 forks source link

Video-decoder error during installation in mac #12

Open codeAC29 opened 8 years ago

codeAC29 commented 8 years ago

I am getting the following error on my mac while installing the libvideo-decoder. ffmpeg version is 3-1-2.

video_decoder.c:2859:3: warning: implicit declaration of function 'avcodec_free_frame' is invalid in C99 [-Wimplicit-function-declaration]
                avcodec_free_frame(&enc.pFrame_yuv);
                ^
video_decoder.c:2865:9: warning: 'avcodec_encode_video2' is deprecated [-Wdeprecated-declarations]
                while(avcodec_encode_video2(enc.fmt_ctx->streams[0]->codec, &enc.pkt, 0, &got) >= 0 && got)
                      ^
/usr/local/include/libavcodec/avcodec.h:5261:5: note: 'avcodec_encode_video2' has been explicitly marked deprecated here
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
    ^
video_decoder.c:2865:56: warning: 'codec' is deprecated [-Wdeprecated-declarations]
                while(avcodec_encode_video2(enc.fmt_ctx->streams[0]->codec, &enc.pkt, 0, &got) >= 0 && got)
                                                                     ^
/usr/local/include/libavformat/avformat.h:880:21: note: 'codec' has been explicitly marked deprecated here
    AVCodecContext *codec;
                    ^
video_decoder.c:2875:4: warning: 'av_free_packet' is deprecated [-Wdeprecated-declarations]
                        av_free_packet(&enc.pkt);
                        ^
/usr/local/include/libavcodec/avcodec.h:4414:6: note: 'av_free_packet' has been explicitly marked deprecated here
void av_free_packet(AVPacket *pkt);
     ^
video_decoder.c:2880:42: warning: 'codec' is deprecated [-Wdeprecated-declarations]
                avcodec_close(enc.fmt_ctx->streams[0]->codec);
                                                       ^
/usr/local/include/libavformat/avformat.h:880:21: note: 'codec' has been explicitly marked deprecated here
    AVCodecContext *codec;
                    ^
79 warnings generated.
gcc -O3 -c -fpic -Wall -DDARWIN -I. -I/Users/abhi/torch/install/include mpjpeg.c
gcc video_decoder.o mpjpeg.o -shared -L/Users/abhi/torch/install/lib/lua/5.1 -L/Users/abhi/torch/install/lib -o libvideo_decoder.so -lavutil -lavformat -lavcodec -lswscale -lTH -lluajit -lluaT /usr/local/lib/libjpeg.dylib
Undefined symbols for architecture x86_64:
  "_avcodec_alloc_frame", referenced from:
      _video_decoder_init in video_decoder.o
      _video_decoder_rgb in video_decoder.o
      _encoderopen in video_decoder.o
  "_avcodec_free_frame", referenced from:
      _encoderclose in video_decoder.o
  "_avcodec_get_frame_defaults", referenced from:
      _video_decoder_batch_resized in video_decoder.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libvideo_decoder.so] Error 1
mvitez commented 8 years ago

See https://github.com/e-lab/torch-toolbox/issues/11

codeAC29 commented 8 years ago

Thanks @mvitez, it worked but now when I try to use framecamera.lua I get the following error:

/Users/abhi/torch/install/share/lua/5.1/xlua/init.lua:360: module 'camopencv' not found:
    no field package.preload['camopencv']
    no file '/Users/abhi/.luarocks/share/lua/5.1/camopencv.lua'
    no file '/Users/abhi/.luarocks/share/lua/5.1/camopencv/init.lua'
    no file '/Users/abhi/torch/install/share/lua/5.1/camopencv.lua'
    no file '/Users/abhi/torch/install/share/lua/5.1/camopencv/init.lua'
    no file './camopencv.lua'
    no file '/Users/abhi/torch/install/share/luajit-2.1.0-beta1/camopencv.lua'
    no file '/usr/local/share/lua/5.1/camopencv.lua'
    no file '/usr/local/share/lua/5.1/camopencv/init.lua'
    no file '/Users/abhi/torch/install/lib/camopencv.dylib'
    no file '/Users/abhi/.luarocks/lib/lua/5.1/camopencv.so'
    no file '/Users/abhi/torch/install/lib/lua/5.1/camopencv.so'
    no file './camopencv.so'
    no file '/usr/local/lib/lua/5.1/camopencv.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
warning: <camopencv> could not be loaded (is it installed?)
qlua: /Users/abhi/torch/install/share/lua/5.1/xlua/init.lua:321: failed to load camopencv wrapper: verify that camopencv is installed
stack traceback:
    [C]: at 0x010cc57e90
    [C]: in function 'error'
    /Users/abhi/torch/install/share/lua/5.1/xlua/init.lua:321: in function 'error'
    /Users/abhi/torch/install/share/lua/5.1/camera/init.lua:21: in main chunk
    [C]: in function 'require'
    ./frame/framecamera.lua:7: in function 'prep_lua_camera'
    ./frame/framecamera.lua:61: in function 'init'

Btw when I do make install, it tries to copy .so file at /usr/local/lib/lua/5.1 but since I have installed torch locally, I had to modify the path to $(TORCH)/lib/lua/5.1/.

mvitez commented 8 years ago

What are you testing? There is no reference to camopencv in demo-core and no reference to /usr/local in video-decoder. After a deeper check, I can see that lua-camera uses opencv. So you should install opencv.

codeAC29 commented 8 years ago

In framecamera.lua require camera statement is there. Somehow, from there it starts looking for camopencv.

mvitez commented 8 years ago

See this: https://github.com/teradeep/demo-apps/issues/3, I can see your comments there.

codeAC29 commented 8 years ago

Yes thats what I thought, so I installed opencv as well as camera package. May be I have opencv3 and not opencv, which might be creating problem.

mvitez commented 8 years ago

Probably, yes.