Repository: opencv
Issue: Video grap core dump on opencv 4.5.5
Labels: bug,priority: low,category: videoio

### System Information

OpenCV python version: 4.5.5.64
Operating System / Platform: Centos 7
Python version: 3.9.2


### Detailed description

I build the opencv from source code with ffmpeg.And get core dump , however the opensource's whl works well.
So is there anyway to find what's  wrong?

Code to core dump.
```
>>> import cv2
>>> PULL_STERAM_URL = "rtsp://admin:aaa@xxxxx:5545/LiveMedia/trackID=1"
>>> cap = cv2.VideoCapture(PULL_STERAM_URL)
[DEBUG:0@22.582] global /home/aaa/source_code/opencv-python/opencv/modules/videoio/src/videoio_registry.cpp (197) VideoBackendRegistry VIDEOIO: Builtin backends(7): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); V4L2(970); CV_IMAGES(960); CV_MJPEG(950); UEYE(940)
[DEBUG:0@22.582] global /home/aaa/source_code/opencv-python/opencv/modules/videoio/src/videoio_registry.cpp (221) VideoBackendRegistry VIDEOIO: Available backends(7): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); V4L2(970); CV_IMAGES(960); CV_MJPEG(950); UEYE(940)
[ INFO:0@22.582] global /home/aaa/source_code/opencv-python/opencv/modules/videoio/src/videoio_registry.cpp (223) VideoBackendRegistry VIDEOIO: Enabled backends(7, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); V4L2(970); CV_IMAGES(960); CV_MJPEG(950); UEYE(940)
[ WARN:0@22.582] global /home/aaa/source_code/opencv-python/opencv/modules/videoio/src/cap.cpp (132) open VIDEOIO(FFMPEG): trying capture filename='rtsp://admin:aaa@xxxxx:5545/LiveMedia/trackID=1' ...
[OPENCV:FFMPEG:40] Starting connection attempt to xxxxx port 5545
[OPENCV:FFMPEG:40] Successfully connected to xxxxx port 5545
[OPENCV:FFMPEG:40] SDP:
v=0
o=- 229 1 IN IP4 xxxxx
s=aaa RTSP Server
c=IN IP4 0.0.0.0
t=0 0
a=range:npt=now-
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=control:rtsp://xxxxx:5545/LiveMedia/trackID=1
a=recvonly

[OPENCV:FFMPEG:40] setting jitter buffer size to 0
[OPENCV:FFMPEG:40] Reinit context to 1920x1088, pix_fmt: yuvj420p
[DEBUG:0@23.804] global /home/aaa/source_code/opencv-python/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp (1056) open FFMPEG: stream[0] is video stream with codecID=27 width=1920 height=1080
[DEBUG:0@23.804] global /home/aaa/source_code/opencv-python/opencv/modules/videoio/src/cap_ffmpeg_hw.hpp (933) HWAccelIterator FFMPEG: allowed acceleration types (none): ''
[ WARN:0@23.804] global /home/aaa/source_code/opencv-python/opencv/modules/videoio/src/cap.cpp (144) open VIDEOIO(FFMPEG): created, isOpened=1
>>> cap.grab()
[OPENCV:FFMPEG:40] Reinit context to 1920x1088, pix_fmt: yuvj420p
Aborted (core dumped)
```

Video info:
```
ffmpeg version 4.4.1-h1.gts.aaa.r2 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-shared --disable-static --prefix=/usr --disable-doc --disable-debug --enable-libx264 --enable-gpl --enable-openssl --enable-nonfree --enable-cuda-nvcc --extra-cflags='-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -Wl,-Bsymbolic -pie -fPIE -D_FORTIFY_SOURCE=2 -O2 -s -ftrapv -I/usr/local/openssl/include/ -I/usr/local/cuda/include' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -Wl,-Bsymbolic -s -L/usr/local/cuda/lib64 -L/usr/local/openssl/lib -lcrypto -lssl' --extra-ldexeflags='-pie -fPIE -s'
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, rtsp, from 'rtsp://admin:aaa@xxxxx:5545/LiveMedia/trackID=1':
  Metadata:
    title           : aaa RTSP Server
  Duration: N/A, start: 0.033289, bitrate: N/A
  Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1920x1080, 30 tbr, 90k tbn, 180k tbc
Output #0, rtsp, to 'rtsp://xxxxx:8554/test':
  Metadata:
    title           : aaa RTSP Server
    encoder         : Lavf58.76.100
  Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1920x1080, q=2-31, 30 tbr, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
```

### Steps to reproduce

Code:
opencv 4.5.5
opencv-python 64
opencv-contrib 4.5.5


first build python whl :
```
    export ENABLE_CONTRIB=1
    export CMAKE_ARGS="-DCMAKE_SKIP_RPATH=TRUE \
          -DBUILD_TESTS=OFF \
          -DBUILD_DOCS=OFF \
          -DBUILD_EXAMPLES=OFF \
          -DBUILD_opencv_world=OFF \
          -DDBUILD_SHARED_LIBS=ON \
          -DWITH_ADE=OFF \
          -DBUILD_OPENCV_GAPI=OFF \
          -DOPENCV_GENERATE_PKGCONFIG=ON \
          -DCMAKE_GENERATE_PKGCONFIG=YES \
          -DCMAKE_BUILD_TYPE=RELEASE \
          -DBUILD_opencv_python3=ON \
          -DBUILD_opencv_python2=OFF \
          -DOPENCV_PYTHON3_VERSION=${PY_VER_MAJ} \
          -DBUILD_opencv_java=OFF \
          -DPYTHON3_NUMPY_INCLUDE_DIRS=$(python -c "import numpy; print (numpy.get_include())") \
          -DOPENCV_SKIP_PYTHON_LOADER=OFF \
          -DWITH_IPP=OFF \
          -DWITH_TIFF=OFF \
          -DWITH_OPENEXR=OFF \
          -DWITH_FFMPEG=ON
    python setup.py bdist_wheel
```


### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [ ] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)