Still cant get "FFMPEG: tag 0x00000021/'!???' is not found" error after build from source

asked 2020-07-06 07:04:40 -0600

bbboat gravatar image

updated 2020-07-06 07:28:46 -0600

Sorry the title is quite confusing but I cant edit it . And my Question is : I still get "FFMPEG: tag 0x00000021/'!???' is not found" error after built from source in pyhon3.7 Ubuntu16.04.

$ python3.7
Python 3.7.8 (default, Jun 29 2020, 05:46:05)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.4.0-pre'
>>> cv2.VideoWriter("test.mp4",0x21,10,(10,10))
OpenCV: FFMPEG: tag 0x00000021/'!???' is not found (format 'mp4 / MP4 (MPEG-4 Part 14)')'
<VideoWriter 0x7f6c63947a70>

this is my cmake script:

cmake -D CMAKE_BUILD_TYPE=RELEASE  
  -D WITH_FFMPEG=ON \   
  -D CMAKE_INSTALL_PREFIX=/usr/local \
  -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
  -D OPENCV_SKIP_PYTHON_LOADER=ON \
  -D PYTHON3_EXECUTABLE=/usr/bin/python3.7 \
  -D PYTHON_INCLUDE_DIR=/usr/include/python3.7 \
  -D PYTHON_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python3.7m \
  -D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.7m.so \
  -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.7/dist-packages/numpy/core/include/ \
  ..

and I have verified the ffmpeg on my machine is workable with h264(x264) now:

$ffmpeg -i input.mp4 -vcodec libx264 -f mp4 x264-output.mp4
ffmpeg version 4.3-2~16.04.york1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
#....
[aac @ 0x5601ecc5d640] Qavg: 62966.328



$ffmpeg -codecs | grep x264
ffmpeg version 4.3-2~16.04.york1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --prefix=/usr --extra-version='2~16.04.york1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m ) (encoders: libx264 libx264rgb h264_omx h264_v4l2m2m h264_vaapi )

At first build , my ffmpeg has not installed with x264, so I installed x264 and rebuild opencv, maybe somehow it will cause the problem?

this is cv2.getBuildInformation result

>>>  print(cv2.getBuildInformation())

General configuration for OpenCV 4.4.0-pre =====================================
  Version control:               4.3.0-533-g992c908

  Extra modules:
    Location (extra):            /home/wangxinping/Documents/workspace/opencv/opencv_contrib/modules
    Version control (extra):     4.3.0-78-g4683455

  Platform:
    Timestamp:                   2020-07-06T11:13:58Z
    Host:                        Linux 4.15.0-64-generic x86_64
    CMake:                       3.5.1
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               RELEASE

  CPU ...
(more)
edit retag flag offensive close merge delete

Comments

>>> print(cv2.getBuildInformation())

berak gravatar imageberak ( 2020-07-06 07:10:54 -0600 )edit

And I have confirmed that there is no other opencv-python under pip folder, e.g.:~/.local/lib/python3.7/site-packages

bbboat gravatar imagebbboat ( 2020-07-06 07:13:17 -0600 )edit

This is what I have on getBuildInformation():

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.16)
    Libraries:                   /usr/lib/arm-linux-gnueabihf/libpython2.7.so (ver 2.7.16)
    numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.2)
    install path:                lib/python2.7/dist-packages/cv2/python-2.7

  Python 3:
    Interpreter:                 /usr/bin/python3 (ver 3.7.3)
    Libraries:                   /usr/lib/arm-linux-gnueabihf/libpython3.7m.so (ver 3.7.3)
    numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.16.2)
    install path:                lib/python3.7/dist-packages/cv2/python-3.7

  Python (for build):            /usr/bin/python3
supra56 gravatar imagesupra56 ( 2020-07-06 08:33:31 -0600 )edit

You supposed to have python2 interpeter. But, you can't deleted python2. Leave that alone. Python2 is not on raspberry pi Buster v10.

-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-4.4.0-pre/modules \
supra56 gravatar imagesupra56 ( 2020-07-06 08:42:36 -0600 )edit

What's raspberry pi model? I have 3/b+, 4B-4g/ 8g

supra56 gravatar imagesupra56 ( 2020-07-06 08:46:40 -0600 )edit

Where is link for OpenCV 4.4.0-pre? I couldn't find it.

supra56 gravatar imagesupra56 ( 2020-07-06 08:47:51 -0600 )edit

You can't run this Python (for build): /usr/bin/python2.7 on python 3.

supra56 gravatar imagesupra56 ( 2020-07-06 08:51:12 -0600 )edit