Suchker kann in Gstreamer CV2, Python, nicht festlegenPython

Python-Programme
Anonymous
 Suchker kann in Gstreamer CV2, Python, nicht festlegen

Post by Anonymous »

Ich möchte n Sekunden nach vorne und rückwärts in Gstreamer CV2 Capture für aufgezeichnete Videos überspringen. Wenn ich jedoch cap_gstreamer.set (cv2.cap_prop_pos_frames, fps*überspringen_second) verwende, setzt es den Sucher auf den Beginn des Videos zurück. Wie kann ich es lösen? Ich habe ein Beispiel für ein aufgezeichnetes Taktvideo geschrieben.

Code: Select all

import cv2

video_p = '/home/alperenlcr/Videos/clock.mp4'

cap_gstreamer = cv2.VideoCapture(video_p, cv2.CAP_GSTREAMER)
cap_ffmpeg = cv2.VideoCapture(video_p, cv2.CAP_FFMPEG)

fps = cap_gstreamer.get(cv2.CAP_PROP_FPS)
skip_second = 100

im1 = cv2.resize(cap_gstreamer.read()[1], (960, 540))
im1_ffmpeg = cv2.resize(cap_ffmpeg.read()[1], (960, 540))

cap_gstreamer.set(cv2.CAP_PROP_POS_FRAMES, fps*skip_second)
cap_ffmpeg.set(cv2.CAP_PROP_POS_FRAMES, fps*skip_second)

im2 = cv2.resize(cap_gstreamer.read()[1], (960, 540))
im2_ffmpeg = cv2.resize(cap_ffmpeg.read()[1], (960, 540))

merge_gstreamer = cv2.hconcat([im1, im2])
merge_ffmpeg = cv2.hconcat([im1_ffmpeg, im2_ffmpeg])

cv2.imshow(str(skip_second) + ' gstreamer', merge_gstreamer)
cv2.imshow(str(skip_second) + ' ffmpeg', merge_ffmpeg)
cv2.waitKey(0)
cv2.destroyAllWindows()

cap_gstreamer.release()
cap_ffmpeg.release()

Result:
Image

My cv2 build is like:

Code: Select all

>>>  print(cv2.getBuildInformation())

General configuration for OpenCV 4.8.1 =====================================
Version control:               4.8.1-dirty

Extra modules:
Location (extra):            /home/alperenlcr/SourceInstalls/opencv_contrib/modules
Version control (extra):     4.8.1

Platform:
Timestamp:                   2024-12-02T13:44:58Z
Host:                        Linux 6.8.0-49-generic x86_64
CMake:                       3.22.1
CMake generator:             Unix Makefiles
CMake build tool:            /usr/bin/gmake
Configuration:               RELEASE

CPU/HW features:
Baseline:                    SSE SSE2 SSE3
requested:                 SSE3
Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (18 files):         + SSSE3 SSE4_1
SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (8 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (37 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (8 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

C/C++:
Built as dynamic libs?:      NO
C++ standard:                11
C++ Compiler:                /usr/bin/c++  (ver 10.5.0)
C++ flags (Release):         -fsigned-char -ffast-math -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
C++ flags (Debug):           -fsigned-char -ffast-math -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
C Compiler:                  /usr/bin/cc
C flags (Release):           -fsigned-char -ffast-math -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
C flags (Debug):             -fsigned-char -ffast-math -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
ccache:                      NO
Precompiled headers:         NO
Extra dependencies:          /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libtiff.so /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/x86_64-linux-gnu/libharfbuzz.so Iconv::Iconv m pthread cudart_static dl rt nppc nppial nppicc nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/lib/x86_64-linux-gnu -L/usr/lib/cuda/lib64
3rdparty dependencies:       libprotobuf ade ittnotify libwebp libopenjp2 IlmImf quirc ippiw ippicv

OpenCV modules:
To be built:                  aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
Disabled:                    cudacodec world
Disabled by dependency:      -
Unavailable:                 alphamat cvv hdf java julia matlab ovis python2 sfm viz
Applications:                tests perf_tests examples apps
Documentation:               NO
Non-free algorithms:         NO

GUI:                           GTK2
QT:                          NO
GTK+:                        YES (ver 2.24.33)
GThread :                  YES (ver 2.72.4)
GtkGlExt:                  NO
OpenGL support:              NO
VTK support:                 NO

Media I/O:
ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
WEBP:                        build (ver encoder: 0x020f)
PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.3.0)
JPEG 2000:                   build (ver 2.5.0)
OpenEXR:                     build (ver 2.3.0)
HDR:                         YES
SUNRASTER:                   YES
PXM:                         YES
PFM:                         YES

Video I/O:
DC1394:                      NO
FFMPEG:                      YES
avcodec:                   YES (58.134.100)
avformat:                  YES (58.76.100)
avutil:                    YES (56.70.100)
swscale:                   YES (5.9.100)
swresample:                YES (3.9.100)
GStreamer:                   YES (1.20.3)
v4l/v4l2:                    YES (linux/videodev2.h)

Parallel framework:            TBB (ver 2021.5 interface 12050)

Trace:                         YES (with Intel ITT)

Other third-party libraries:
Intel IPP:                   2021.8 [2021.8.0]
at:                   /home/alperenlcr/SourceInstalls/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
Intel IPP IW:                sources (2021.8.0)
at:                /home/alperenlcr/SourceInstalls/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
VA:                          NO
Lapack:                      NO
Eigen:                       NO
Custom HAL:                  NO
Protobuf:                    build (3.19.1)
Flatbuffers:                 builtin/3rdparty (23.5.9)

NVIDIA CUDA:                   YES (ver 11.5, CUFFT CUBLAS NVCUVID NVCUVENC FAST_MATH)
NVIDIA GPU arch:             86
NVIDIA PTX archs:

cuDNN:                         YES (ver 8.6.0)

OpenCL:                        YES (no extra features)
Include path:                /home/alperenlcr/SourceInstalls/opencv/3rdparty/include/opencl/1.2
Link libraries:              Dynamic load

ONNX:                          NO

Python 3:
Interpreter:                 /usr/bin/python3 (ver 3.10.12)
Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.10.so (ver 3.10.12)
numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.21.5)
install path:                lib/python3.10/dist-packages/cv2/python-3.10

Python (for build):            /usr/bin/python3

Java:
ant:                         NO
Java:                        NO
JNI:                         NO
Java wrappers:               NO
Java tests:                  NO

Install to:                    /usr/local
-----------------------------------------------------------------

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post