import cv2
import time
cap = cv2.cudacodec.createVideoReader("D:/obsrecord/tiktok-live-sample2.flv")
t1 = time.time()
while True:
ret, frame = cap.nextFrame()
if not ret:
t2 = time.time()
print(t2 - t1)
break
and get the message
D:\python\Python311\python.exe C:\Users\Administrator\Desktop\code\python\normalpy311\videodecodespeedtest.py
[ERROR:0@0.740] global video_parser.cpp:92 cv::cudacodec::detail::VideoParser::parseVideoData Maxium number of packets (20) parsed without decoding a frame or reconfiguring the decoder, if reading from a live source consider initializing with VideoReaderInitParams::udpSource == true.
[ERROR:0@0.740] global video_parser.cpp:92 cv::cudacodec::detail::VideoParser::parseVideoData Maxium number of packets (20) parsed without decoding a frame or reconfiguring the decoder, if reading from a live source consider initializing with VideoReaderInitParams::udpSource == true.
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\code\python\normalpy311\videodecodespeedtest.py", line 49, in <module>
ret, frame = cap.nextFrame()
^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.7.0-dev) D:\opencv\opencv_contrib-4.7.0\modules\cudacodec\src\video_reader.cpp:185: error: (-2:Unspecified error) Parsing/Decoding video source failed, check GPU memory is available and GPU supports hardware decoding. in function '`anonymous-namespace'::VideoReaderImpl::internalGrab'
Process finished with exit code 1
I saw another person had a similar problem on github, and the solution was to change the value of Maxium number of packets to 100, but it didn’t work for me
D:\python\Python311\python.exe C:\Users\Administrator\Desktop\code\python\normalpy311\videodecodespeedtest.py
[ERROR:0@0.740] global video_parser.cpp:92 cv::cudacodec::detail::VideoParser::parseVideoData Maxium number of packets (100) parsed without decoding a frame or reconfiguring the decoder, if reading from a live source consider initializing with VideoReaderInitParams::udpSource == true.
[ERROR:0@0.740] global video_parser.cpp:92 cv::cudacodec::detail::VideoParser::parseVideoData Maxium number of packets (100) parsed without decoding a frame or reconfiguring the decoder, if reading from a live source consider initializing with VideoReaderInitParams::udpSource == true.
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\code\python\normalpy311\videodecodespeedtest.py", line 49, in <module>
ret, frame = cap.nextFrame()
^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.7.0-dev) D:\opencv\opencv_contrib-4.7.0\modules\cudacodec\src\video_reader.cpp:185: error: (-2:Unspecified error) Parsing/Decoding video source failed, check GPU memory is available and GPU supports hardware decoding. in function '`anonymous-namespace'::VideoReaderImpl::internalGrab'
Process finished with exit code 1
here is the media message
General
Complete name : D:\obsrecord\tiktok-live-sample2.flv
Format : Flash Video
File size : 3.18 MiB
Duration : 5 h 31 min
Overall bit rate : 1 342 b/s
Frame rate : 25.000 FPS
Writing application : Lavf58.45.100
_default_bitrate : 1300
_min_bitrate : 800
_hit_node_optimize : 1
_os_version : 15.6.1
_stream_id : push-rtmp-f5-tt01.fcdn.us.tiktokv.com:stage:stream-3571633242648871180_or4
_h_id : 5
_max_bitrate : 2200
_fp_amode : 0
_push_protocol : rtmpq
_is_hardware_encode : 1
_p_id : 5
_platform : iOS
_fp_coderate : 2252800
_qId : ByteAudioAUUnsplit+new_session_api
_fp_vmode : 1
_fp_nb : 0
_sdk_version : 13.2.0.20-mt
_publish_time_stamp : 1681875167
_model : iPhone 11 Pro Max
_s_id : 8
_interval : 2
_ab : 0
_start_time : 1681875167488
_link_info :
Video
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings : CABAC / 3 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference fra : 3 frames
Format settings, GOP : M=1, N=50
Codec ID : 7
Duration : 5 h 31 min
Bit rate : 2 199 kb/s
Width : 720 pixels
Height : 1 280 pixels
Display aspect ratio : 0.562
Frame rate mode : Constant
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.095
Stream size : 5.09 GiB
Audio
Format : AAC LC SBR
Format/Info : Advanced Audio Codec Low Complexity with Spectral Band Replication
Commercial name : HE-AAC
Format settings : NBC
Codec ID : 10-5
Duration : 5 h 30 min
Bit rate : 62.5 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 44.1 kHz
Frame rate : 21.533 FPS (2048 SPF)
Compression mode : Lossy
Delay relative to video : 5 h 30 min
Stream size : 148 MiB
need you help, thank you.