Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build with FFmpeg master. Some deprecated APIs have been removed. #10011

Merged
merged 2 commits into from
Nov 18, 2017

Conversation

jviney
Copy link
Contributor

@jviney jviney commented Nov 3, 2017

OpenCV currently does not build with FFmpeg master. This is because 2 of their deprecated APIs have been removed.

  • AVFMT_RAWPICTURE removed
  • Non AV_ prefixed avcodec flags have been removed

@alalek
Copy link
Member

alalek commented Nov 3, 2017

Proposed changes break MacOS builder videoio tests (with most fresh FFMPEG version installed):

--     FFMPEG:                      YES
--       avcodec:                   YES (ver 57.89.100)
--       avformat:                  YES (ver 57.71.100)
--       avutil:                    YES (ver 55.58.100)
--       swscale:                   YES (ver 4.6.100)
--       avresample:                YES (ver 3.5.0)

@jviney
Copy link
Contributor Author

jviney commented Nov 3, 2017

Tests passing again.

@alalek
Copy link
Member

alalek commented Nov 7, 2017

Are you able to run OpenCV's videoio tests with master branch of FFMPEG? (you need opencv_extra repository and setup OPENCV_TEST_DATA_PATH=<opencv_extra>/testdata environment variable).

@jviney
Copy link
Contributor Author

jviney commented Nov 9, 2017

This patch works with the FFmpeg 3.3 and 3.4 branches, but not with current master (git 69218b419). This assertion fails inside Videoio_Video_parallel_writers_and_readers.accuracy:

modules/videoio/test/test_ffmpeg.cpp:356: error: (-215) frameCount == WriteVideo_Invoker::FrameCount in function operator()

The rest of the tests pass.

@alalek
Copy link
Member

alalek commented Nov 9, 2017

Thanks! I have the same observations about current master FFmpeg branch.

if (oc->oformat->flags & AVFMT_RAWPICTURE) {
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AVFMT_RAWPICTURE have been deprecated/eliminated completely (there is no replacement for this), so code block under this "if" is not used at all anymore.

Please disable these code block completely:

#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(57, 0, 0)
    if (oc->oformat->flags & AVFMT_RAWPICTURE) {
        /* raw video case. The API will change slightly in the near
           futur for that */
        AVPacket pkt;
        av_init_packet(&pkt);

#ifndef PKT_FLAG_KEY
#define PKT_FLAG_KEY AV_PKT_FLAG_KEY
#endif

        pkt.flags |= PKT_FLAG_KEY;
        pkt.stream_index= video_st->index;
        pkt.data= (uint8_t *)picture;
        pkt.size= sizeof(AVPicture);

        ret = av_write_frame(oc, &pkt);
    } else
#endif
    {
        /* encode the image */
        AVPacket pkt;
        av_init_packet(&pkt);
        ...
    }

Please apply similar changes for other AVFMT_RAWPICTURE entries (condition is negative).

#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(57, 0, 0)
    if (!(oc->oformat->flags & AVFMT_RAWPICTURE))
#endif
    {
        ... code ...
    }

@alalek alalek merged commit b1d2088 into opencv:master Nov 18, 2017
skvark pushed a commit to opencv/opencv-python that referenced this pull request Feb 19, 2018
* Adjust build environment as per https://docs.opencv.org/3.1.0/d5/de5/tutorial_py_setup_in_windows.html and https://wiki.python.org/moin/WindowsCompilers#Which_Microsoft_Visual_C.2B-.2B-_compiler_to_use_with_a_specific_Python_version_.3F

* The best practice is to only use requirements.txt for deployments, not for packaging

* ignore PyCharm metadata

* refactor to be more modular

* the warnings are irrelevant in older versions

* v110 toolset might introduce dependency on older runtime not likely to be present in newer systems, potentially breaking upgrade

* build locally with scikit-build

* adjust appveyor config to local build

* cleanup

* DLL load works without

* fail appveyor build immediately when one job fails

* * cmd doesn't expand globs
* - diplication
* - WinXP-related bits
* pip erroneously considers cv2/ as installed package when in sourceroot
* require CMake output entries to be found
* 3.5+ uses different .pyd naming scheme
* .pyd is placed differently in Linux
* DLL is only in Windows

* ignore temporary config files

* Yet another .pyd naming convention in Py35 Linux.
Screw checking.

* Update setup.py file to flag compatibility with Python 2.7-3.4-3.5-3.6 (#57)

# Conflicts:
#	setup.py

* Adjust build environment as per https://docs.opencv.org/3.1.0/d5/de5/tutorial_py_setup_in_windows.html and https://wiki.python.org/moin/WindowsCompilers#Which_Microsoft_Visual_C.2B-.2B-_compiler_to_use_with_a_specific_Python_version_.3F

* The best practice is to only use requirements.txt for deployments, not for packaging

* ignore PyCharm metadata

* refactor to be more modular

* the warnings are irrelevant in older versions

* v110 toolset might introduce dependency on older runtime not likely to be present in newer systems, potentially breaking upgrade

* build locally with scikit-build

* adjust appveyor config to local build

* cleanup

* DLL load works without

* fail appveyor build immediately when one job fails

* * cmd doesn't expand globs
* - diplication
* - WinXP-related bits
* pip erroneously considers cv2/ as installed package when in sourceroot
* require CMake output entries to be found
* 3.5+ uses different .pyd naming scheme
* .pyd is placed differently in Linux
* DLL is only in Windows

* ignore temporary config files

* fail fast on error

* * custom build logic should be unneeded now, will uncomment as needed

* use the latest upstream multibuild

* enable tracing
- more suspicious things

* save some build time

* these somehow cause "Server does not allow request for unadvertised object" for GitHub

* Revert "use the latest upstream multibuild"

This reverts commit 915ba42.

* Yet another .pyd naming convention in Py35 Linux.
Screw checking.

* Update setup.py file to flag compatibility with Python 2.7-3.4-3.5-3.6 (#57)

# Conflicts:
#	setup.py

* add diagnostics

* * Use upstream multubuild due to the forked one abusing prebuild as build

* save some time

* looks like clean_code() isn't required

* * Don't make CMake try Ninja first
* MacOS LAPACK on Travis is still broken

* See build progress as it goes

* update submodules on demand

* fetch source in time for find_version.py

* use custom docker image

* use custom multibuild

* bump submodule

* Linux/OSX are supposed to build with Qt support

* * make shallow copies to save on download time
* manylinux git is an old version

* * clean up redundant syntax
* reformat codeas YML multiline with dedent

* IPP IW broken in Linux

* + ffmpeg patch

* additional deps required due to multibuild bug

* +cv2.data

* Use upstream multibuild with monkey patch

* don't do anything if upload not needed

* filter out irrelevant debug output

* * clean up unused scripts
* inline the remaining standalone scripts

* https://github.com/matthew-brett/multibuild/issues/106 fixed

* * bump OpenCV version to 3.4.0

* * opencv/opencv#10011 is available in 3.4.0
* allow for if the sourcetree is a submodule

* * don't reinstall whatever happens to be preinstalled
* re-add workaround for travis-ci/travis-ci#9055

* * rearrange custom CMake flags
* -DWITH_GTK=OFF proved to be unneeded, gthread is among manylinux requirements

* fix linux detection to work in 3.3+, too

* fix data path for other OSes

* don't do anything unless deployment is requested

* use upstream ``devel`` multibuild

* restore from backup after rebase

* catch fetch error

* use `devel` multibuild

* comment not using --depth

* remove redundant command after merge
@ilovezfs
Copy link
Contributor

@jviney @alalek will this be backported to the 2.4 branch? opencv@2 now fails to build with ffmpeg 4.0.

[ 15%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o
cd /tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/build/modules/highgui && /usr/local/Homebrew/Library/Homebrew/shims/super/clang++  -DCVAPI_EXPORTS -DHIGHGUI_EXPORTS -D_USE_MATH_DEFINES -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/imgproc/include -I/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/core/include -I/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/build/modules/highgui -I/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/highgui/src -I/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/highgui/include -I/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/build -isystem /usr/local/include/eigen3 -isystem /usr/local/opt/jpeg/include -isystem /usr/local/include -isystem /usr/local/include/OpenEXR -isystem /usr/local/Cellar/ffmpeg/4.0/include  -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-array-bounds -Wno-aggressive-loop-optimizations -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -msse -msse2 -mavx -Wno-deprecated-declarations -Wno-clobbered -DNDEBUG  -DNDEBUG -fPIC   -o CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o -c /tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg.cpp
In file included from /tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg.cpp:45:
/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1484:21: error: use of undeclared identifier 'CODEC_FLAG_GLOBAL_HEADER'
        c->flags |= CODEC_FLAG_GLOBAL_HEADER;
                    ^
/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1512:30: error: use of undeclared identifier 'AVFMT_RAWPICTURE'
    if (oc->oformat->flags & AVFMT_RAWPICTURE) {
                             ^
/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1686:35: error: use of undeclared identifier 'AVFMT_RAWPICTURE'
        if( (oc->oformat->flags & AVFMT_RAWPICTURE) == 0 )
                                  ^
/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:1920:32: error: use of undeclared identifier 'AVFMT_RAWPICTURE'
    if (!(oc->oformat->flags & AVFMT_RAWPICTURE)) {
                               ^
/tmp/opencv@2-20180421-49575-xduc6s/opencv-2.4.13.6/modules/highgui/src/cap_ffmpeg_impl.hpp:2214:25: error: use of undeclared identifier 'CODEC_FLAG_GLOBAL_HEADER'
            c->flags |= CODEC_FLAG_GLOBAL_HEADER;
                        ^
5 errors generated.
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
bash-3.2$ 

https://jenkins.brew.sh/job/Homebrew%20Core%20Pull%20Requests/22666/version=high_sierra/testReport/junit/brew-test-bot/high_sierra/install_opencv_2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port/backport done Label for maintainers. Authors of PR can ignore this
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants