
    9i=                     N    S SK r S SKrS SKrS SKJrJr  S SKJr  S SKJr  SS jr	g)    N)VideoReadercpu)DECORDError)tqdmc           
      &   [         R                  R                  S5        [        U [	        S5      S9nUR                  5       nX1:  a&  [        U5      [        U5      -  n[        U5      S-  nOSnSn[        U5      nXc-  n[        R                  " [        R                  " [        R                  " U[        U5      US95      SUS-
  5      R                  [        R                  5      n[        5       n	[        U5       Ho  n
SnUS	::  a	   X*U-
     n US	:  a,  ["        R$                  " U	S
   5      nU	R'                  U5        MF  WS-  nUR)                  SSS5      nU	R'                  U5        Mq     X4$ ! [          a    US-  n Of = fUS	::  a  M  N)a
  
Decode video from 'video_path' and return the sampled frames based on target_fps.
The default value of target_fps is 5.

Args:
    video_path: the absolute path of video.
    target_fps: the number of sampled video frames per second.

Returns:
    [imgs, duration]
torchr   )ctxg       @g      ?g        )step   
   g     o@   )decordbridge
set_bridger   r   get_avg_fpsfloatlennpcliproundarangeastypeint32listr   r   copydeepcopyappendpermute)
video_path
target_fpsvrcur_fpsintervalstart
vid_lengthdurationsampled_idxsimgsibiasimgs                j/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/modelscope/models/multi_modal/soonet/utils.pydecode_videor.      sl    MMW%	ZSV	,BnnG>E*$55h"$RJ#H77
5%
"3(CDaQrxx(  6D,bjTl "9--R)CKK*C++aA&CKK  " >  		 bjs   E55FF)   )
r   r   numpyr   r   r   decord._ffi.baser   r   r.        r-   <module>r4      s       # ( .r3   