0

I tried to build Opencv3.1 at Ubuntu16.04 with ffmpeg. I follow the instructions how to install ffmpeg at here.

According to this discussion ,I checked.

>> mediainfo ~/Desktop/grb_2.mp4 
General
Complete name                            : /home/nyan/Desktop/grb_2.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 445 KiB
Duration                                 : 27s 862ms
Overall bit rate                         : 131 Kbps
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00
Writing application                      : Lavf57.66.105

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 27s 862ms
Bit rate                                 : 128 Kbps
Width                                    : 720 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Original display aspect ratio            : 4:3
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.012
Stream size                              : 435 KiB (98%)
Writing library                          : x264 core 148
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00 





ffmpeg -codecs | grep -i avc
ffmpeg version N-90982-gb995ec0 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
  configuration: --prefix=/home/nyan/ffmpeg_build --enable-shared --extra-cflags=-I/home/nyan/ffmpeg_build/include --extra-ldflags=-L/home/nyan/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/nyan/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 18.100 / 56. 18.100
  libavcodec     58. 19.100 / 58. 19.100
  libavformat    58. 13.101 / 58. 13.101
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 21.100 /  7. 21.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m ) (encoders: libx264 libx264rgb h264_v4l2m2m h264_vaapi )
 D.A.L. avc                  On2 Audio for Video Codec (decoders: on2avc )

So my ffmpeg installation is ok.

When I cmake to my Opencv, I have set up to ffmpeg as

enter image description here

But when I make to compile, I have error as

make[2]: *** No rule to make target '/home/nyan/ffmpeg_build/lib/libavresample.a', needed by 'lib/libopencv_videoio.so.3.1.0'.  Stop.
CMakeFiles/Makefile2:8709: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

How can I fix the problem?

I install libavresample manually and

sudo apt-get install libavresample-dev
[sudo] password for nyan: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libavresample-dev is already the newest version (7:2.8.14-0ubuntu0.16.04.1).

It is newest version.

EDIT:

Actually libavresample at ffmpeg is deprecated already. So I tried to install Opencv3.4.1 higher version. Compile, build and installation are fine. But VideoCapture cap(0); does not read from the device. So I checked ffmpeg at Opencv3.4.1 installation as

python -c "import cv2; print(cv2.getBuildInformation())" | grep -i ffmpeg

FFMMPEG IS NO. So build with ffmpeg is not successful even though there was no error at build for Opencv3.4.1.

batuman
  • 7,066
  • 26
  • 107
  • 229
  • Did you input the ffmpeg file paths by yourself or did CMake detect them automatically? – zindarod May 10 '18 at 13:26
  • @zindarod cmake detect automatically – batuman May 10 '18 at 13:38
  • What is the output of `pkg-config libavcodec libavfilter libavdevice libavresample libavformat libavutil libswscale libswresample --libs --cflags` and `which ffmpeg`? – zindarod May 10 '18 at 14:16
  • @zindarod `which ffmpeg is /home/nyan/bin/ffmpeg` – batuman May 10 '18 at 14:23
  • @zindarod pk-config gave for the rest as `Package libavcodec was not found in the pkg-config search path. Perhaps you should add the directory containing `libavcodec.pc' to the PKG_CONFIG_PATH environment variable No package 'libavcodec' found`. But I have all installed inside ffmpeg_build folder as in the ffmpeg build tutorial and all are installed correctly. – batuman May 10 '18 at 14:25
  • Did you do `sudo make install` and `sudo ldconfig` after ffmpeg compilation? – zindarod May 10 '18 at 14:28
  • No I didn't do that – batuman May 10 '18 at 14:29
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/170791/discussion-between-zindarod-and-batuman). – zindarod May 10 '18 at 14:33
  • `https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu`, They are installed in /home/bin. – batuman May 10 '18 at 14:34
  • @zindarod you are correct. Even though I made paths in .bashrc, opencv doesn't know ffmpeg is in the system. I follow the instruction how to compile ffmpeg and copy all in bin/lib/include/pkgconfig to respective /usr/local. Then Opencv knows ffmpeg is in the system and can link. – batuman May 12 '18 at 12:43

0 Answers0