Here is what I do:
$ git clone https://github.com/Itseez/opencv
$ cd opencv
$ git checkout 2.4.10
$ mkdir build && cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON .. > cmake.log 2>&1
$ make -j9 > make1.log 2>&1
$ make > make2.log 2>&1
$ grep CODEC_ID_H264 -r -s /usr/include/
/usr/include/libavcodec/avcodec.h: AV_CODEC_ID_H264,
/usr/include/libavcodec/avcodec.h: * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
$ pkg-config --modversion libavcodec
56.1.0
Here is what I get: cmake.log, make1.log, make2.log
What do I do to make OpenCV build?