Build error when process to cap_ffmpeg.cpp

hi, everyone,
I build opencv error when with ffmpeg option. here is environment and error message:

  • centos 7

  • ffmpeg4.3.1

  • opencv4.5.3

  • gcc4.8.2

  • python2.7.5

and ffmpeg install configure:
./configure --prefix=/usr/local/ffmpeg --enable-libopenh264 --enable-shared --enable-yasm --enable-libx264 --enable-gpl --enable-pthreads --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib

opencv install configure:

cmake -D CMAKE_BUILD_TYPE=RELEASE  \
-D WITH_FFMPEG=ON \
-D WITH_GTK=OFF \
-D WITH_DC1394=OFF\
-D ENABLE_PRECOMPILED_HEADERS=OFF\
-D OPENCV_GENERATE_PKGCONFIG=YES \
-D BUILD_opencv_python2=ON \
-D PYTHON_INCLUDE_DIR=/usr/include/python2.7 \
-D PYTHON2_LIBRARY=/usr/lib64/python2.7/config/libpython2.7.so \
-D PYTHON_EXCUTABLE=/usr/bin/python ..

error message is:

[ 37%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o
In file included from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg_impl.hpp:100:0,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg.cpp:50:
/opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg_hw.hpp: In constructor 'HWAccelIterator::HWAccelIterator(cv::VideoAccelerationType, bool, AVDictionary*)':
/opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg_hw.hpp:939:23: error: use of deleted function 'std::basic_istringstream<char>& std::basic_istringstream<char>::operator=(const std::basic_istringstream<char>&)'
             s_stream_ = std::istringstream(accel_list);
                       ^
In file included from /usr/include/c++/4.8.2/complex:45:0,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core/cvstd.inl.hpp:47,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core.hpp:3306,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/include/opencv2/videoio.hpp:46,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/precomp.hpp:57,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg.cpp:42:
/usr/include/c++/4.8.2/sstream:272:11: note: 'std::basic_istringstream<char>& std::basic_istringstream<char>::operator=(const std::basic_istringstream<char>&)' is implicitly deleted because the default definition would be ill-formed:
     class basic_istringstream : public basic_istream<_CharT, _Traits>
           ^
/usr/include/c++/4.8.2/sstream:272:11: error: use of deleted function 'std::basic_istream<char>& std::basic_istream<char>::operator=(const std::basic_istream<char>&)'
In file included from /usr/include/c++/4.8.2/sstream:38:0,
                 from /usr/include/c++/4.8.2/complex:45,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core/cvstd.inl.hpp:47,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core.hpp:3306,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/include/opencv2/videoio.hpp:46,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/precomp.hpp:57,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg.cpp:42:
/usr/include/c++/4.8.2/istream:58:11: note: 'std::basic_istream<char>& std::basic_istream<char>::operator=(const std::basic_istream<char>&)' is implicitly deleted because the default definition would be ill-formed:
     class basic_istream : virtual public basic_ios<_CharT, _Traits>
           ^
/usr/include/c++/4.8.2/istream:58:11: error: use of deleted function 'std::basic_ios<char>& std::basic_ios<char>::operator=(const std::basic_ios<char>&)'
In file included from /usr/include/c++/4.8.2/ios:44:0,
                 from /usr/include/c++/4.8.2/istream:38,
                 from /usr/include/c++/4.8.2/sstream:38,
                 from /usr/include/c++/4.8.2/complex:45,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core/cvstd.inl.hpp:47,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core.hpp:3306,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/include/opencv2/videoio.hpp:46,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/precomp.hpp:57,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg.cpp:42:
/usr/include/c++/4.8.2/bits/basic_ios.h:66:11: note: 'std::basic_ios<char>& std::basic_ios<char>::operator=(const std::basic_ios<char>&)' is implicitly deleted because the default definition would be ill-formed:
     class basic_ios : public ios_base
           ^
In file included from /usr/include/c++/4.8.2/ios:42:0,
                 from /usr/include/c++/4.8.2/istream:38,
                 from /usr/include/c++/4.8.2/sstream:38,
                 from /usr/include/c++/4.8.2/complex:45,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core/cvstd.inl.hpp:47,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core.hpp:3306,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/include/opencv2/videoio.hpp:46,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/precomp.hpp:57,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg.cpp:42:
/usr/include/c++/4.8.2/bits/ios_base.h:789:5: error: 'std::ios_base& std::ios_base::operator=(const std::ios_base&)' is private
     operator=(const ios_base&);
     ^
In file included from /usr/include/c++/4.8.2/ios:44:0,
                 from /usr/include/c++/4.8.2/istream:38,
                 from /usr/include/c++/4.8.2/sstream:38,
                 from /usr/include/c++/4.8.2/complex:45,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core/cvstd.inl.hpp:47,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core.hpp:3306,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/include/opencv2/videoio.hpp:46,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/precomp.hpp:57,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg.cpp:42:
/usr/include/c++/4.8.2/bits/basic_ios.h:66:11: error: within this context
     class basic_ios : public ios_base
           ^
In file included from /usr/include/c++/4.8.2/complex:45:0,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core/cvstd.inl.hpp:47,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core.hpp:3306,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/include/opencv2/videoio.hpp:46,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/precomp.hpp:57,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg.cpp:42:
/usr/include/c++/4.8.2/sstream:272:11: error: use of deleted function 'std::basic_stringbuf<char>& std::basic_stringbuf<char>::operator=(const std::basic_stringbuf<char>&)'
     class basic_istringstream : public basic_istream<_CharT, _Traits>
           ^
/usr/include/c++/4.8.2/sstream:64:11: note: 'std::basic_stringbuf<char>& std::basic_stringbuf<char>::operator=(const std::basic_stringbuf<char>&)' is implicitly deleted because the default definition would be ill-formed:
     class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
           ^
In file included from /usr/include/c++/4.8.2/ios:43:0,
                 from /usr/include/c++/4.8.2/istream:38,
                 from /usr/include/c++/4.8.2/sstream:38,
                 from /usr/include/c++/4.8.2/complex:45,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core/cvstd.inl.hpp:47,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core.hpp:3306,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/include/opencv2/videoio.hpp:46,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/precomp.hpp:57,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg.cpp:42:
/usr/include/c++/4.8.2/streambuf:810:7: error: 'std::basic_streambuf<_CharT, _Traits>& std::basic_streambuf<_CharT, _Traits>::operator=(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]' is private
       operator=(const basic_streambuf& __sb)
       ^
In file included from /usr/include/c++/4.8.2/complex:45:0,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core/cvstd.inl.hpp:47,
                 from /opt/compiler/opencv-4.5.3/modules/core/include/opencv2/core.hpp:3306,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/include/opencv2/videoio.hpp:46,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/precomp.hpp:57,
                 from /opt/compiler/opencv-4.5.3/modules/videoio/src/cap_ffmpeg.cpp:42:
/usr/include/c++/4.8.2/sstream:64:11: error: within this context
     class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
           ^
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_ffmpeg.cpp.o] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2

can anyone help me out with this? thank you very much.

GCC 4.8 is very old and likely causing all the issues here.

get a newer GCC.

and maybe a newer python.

It’s working, when I change gcc version to 6.5.0, it can be built with no error. Thank you.