1- from math import prod
2- from ffmpegio import video , probe
1+ from ffmpegio import video , probe , utils
32import tempfile , re
43from os import path
5- import numpy as np
64
75
86def test_create ():
@@ -50,7 +48,6 @@ def test_read_write():
5048 with tempfile .TemporaryDirectory () as tmpdirname :
5149 out_url = path .join (tmpdirname , re .sub (r"\..*?$" , outext , path .basename (url )))
5250 print (out_url )
53- print (prod (A ["shape" ]))
5451 video .write (out_url , fs , A )
5552 print (probe .video_streams_basic (out_url ))
5653 fs , A = video .read (out_url , vframes = 10 )
@@ -73,14 +70,14 @@ def test_read():
7370 N = 5
7471 fs , B = video .read (url , vframes = 10 , ss_in = float (n0 / fs ))
7572 print (B ["shape" ], A ["shape" ])
76- nbytes = prod (A ["shape" ][1 :]) * int ( A ["dtype" ][ - 1 ])
77- assert A ["buffer" ][n0 * nbytes :] == B [' buffer' ][: (10 - n0 ) * nbytes ]
73+ nbytes = utils . get_samplesize (A ["shape" ][- 3 :], A ["dtype" ])
74+ assert A ["buffer" ][n0 * nbytes :] == B [" buffer" ][: (10 - n0 ) * nbytes ]
7875
7976 fs , C = video .read (url , ss_in = float (n0 / fs ), t_in = float (N / fs ))
8077
8178 print (C ["shape" ])
82- assert A ["buffer" ][n0 * nbytes :(n0 + N ) * nbytes ] == C [' buffer' ]
83-
79+ assert A ["buffer" ][n0 * nbytes : (n0 + N ) * nbytes ] == C [" buffer" ]
80+
8481 # fs, D = video.read(url, ss_in=n0, t_in=N, units='frames')
8582 # assert np.array_equal(D, C)
8683
@@ -113,7 +110,6 @@ def test_two_pass_write():
113110 # test_create()
114111 from ffmpegio import configure , utils , ffmpegprocess
115112 from ffmpegio .utils import log as log_utils
116- import numpy as np
117113 from pprint import pprint
118114 import re
119115
0 commit comments