@@ -120,11 +120,11 @@ def test_get_frame_at_pts(self, device):
120
120
def test_get_frame_at_index (self , device ):
121
121
decoder = create_from_file (str (NASA_VIDEO .path ))
122
122
add_video_stream (decoder , device = device )
123
- frame0 , _ , _ = get_frame_at_index (decoder , stream_index = 3 , frame_index = 0 )
123
+ frame0 , _ , _ = get_frame_at_index (decoder , frame_index = 0 )
124
124
reference_frame0 = NASA_VIDEO .get_frame_data_by_index (0 )
125
125
assert_frames_equal (frame0 , reference_frame0 .to (device ))
126
126
# The frame that is played at 6 seconds is frame 180 from a 0-based index.
127
- frame6 , _ , _ = get_frame_at_index (decoder , stream_index = 3 , frame_index = 180 )
127
+ frame6 , _ , _ = get_frame_at_index (decoder , frame_index = 180 )
128
128
reference_frame6 = NASA_VIDEO .get_frame_data_by_index (
129
129
INDEX_OF_FRAME_AT_6_SECONDS
130
130
)
@@ -134,9 +134,7 @@ def test_get_frame_at_index(self, device):
134
134
def test_get_frame_with_info_at_index (self , device ):
135
135
decoder = create_from_file (str (NASA_VIDEO .path ))
136
136
add_video_stream (decoder , device = device )
137
- frame6 , pts , duration = get_frame_at_index (
138
- decoder , stream_index = 3 , frame_index = 180
139
- )
137
+ frame6 , pts , duration = get_frame_at_index (decoder , frame_index = 180 )
140
138
reference_frame6 = NASA_VIDEO .get_frame_data_by_index (
141
139
INDEX_OF_FRAME_AT_6_SECONDS
142
140
)
@@ -148,9 +146,7 @@ def test_get_frame_with_info_at_index(self, device):
148
146
def test_get_frames_at_indices (self , device ):
149
147
decoder = create_from_file (str (NASA_VIDEO .path ))
150
148
add_video_stream (decoder , device = device )
151
- frames0and180 , * _ = get_frames_at_indices (
152
- decoder , stream_index = 3 , frame_indices = [0 , 180 ]
153
- )
149
+ frames0and180 , * _ = get_frames_at_indices (decoder , frame_indices = [0 , 180 ])
154
150
reference_frame0 = NASA_VIDEO .get_frame_data_by_index (0 )
155
151
reference_frame180 = NASA_VIDEO .get_frame_data_by_index (
156
152
INDEX_OF_FRAME_AT_6_SECONDS
@@ -162,20 +158,16 @@ def test_get_frames_at_indices(self, device):
162
158
def test_get_frames_at_indices_unsorted_indices (self , device ):
163
159
decoder = create_from_file (str (NASA_VIDEO .path ))
164
160
_add_video_stream (decoder , device = device )
165
- stream_index = 3
166
161
167
162
frame_indices = [2 , 0 , 1 , 0 , 2 ]
168
163
169
164
expected_frames = [
170
- get_frame_at_index (
171
- decoder , stream_index = stream_index , frame_index = frame_index
172
- )[0 ]
165
+ get_frame_at_index (decoder , frame_index = frame_index )[0 ]
173
166
for frame_index in frame_indices
174
167
]
175
168
176
169
frames , * _ = get_frames_at_indices (
177
170
decoder ,
178
- stream_index = stream_index ,
179
171
frame_indices = frame_indices ,
180
172
)
181
173
for frame , expected_frame in zip (frames , expected_frames ):
@@ -193,7 +185,6 @@ def test_get_frames_at_indices_unsorted_indices(self, device):
193
185
def test_get_frames_by_pts (self , device ):
194
186
decoder = create_from_file (str (NASA_VIDEO .path ))
195
187
_add_video_stream (decoder , device = device )
196
- stream_index = 3
197
188
198
189
# Note: 13.01 should give the last video frame for the NASA video
199
190
timestamps = [2 , 0 , 1 , 0 + 1e-3 , 13.01 , 2 + 1e-3 ]
@@ -204,7 +195,6 @@ def test_get_frames_by_pts(self, device):
204
195
205
196
frames , * _ = get_frames_by_pts (
206
197
decoder ,
207
- stream_index = stream_index ,
208
198
timestamps = timestamps ,
209
199
)
210
200
for frame , expected_frame in zip (frames , expected_frames ):
@@ -233,12 +223,9 @@ def test_pts_apis_against_index_ref(self, device):
233
223
num_frames = metadata_dict ["numFrames" ]
234
224
assert num_frames == 390
235
225
236
- stream_index = 3
237
226
_ , all_pts_seconds_ref , _ = zip (
238
227
* [
239
- get_frame_at_index (
240
- decoder , stream_index = stream_index , frame_index = frame_index
241
- )
228
+ get_frame_at_index (decoder , frame_index = frame_index )
242
229
for frame_index in range (num_frames )
243
230
]
244
231
)
@@ -254,7 +241,6 @@ def test_pts_apis_against_index_ref(self, device):
254
241
255
242
_ , pts_seconds , _ = get_frames_by_pts_in_range (
256
243
decoder ,
257
- stream_index = stream_index ,
258
244
start_seconds = 0 ,
259
245
stop_seconds = all_pts_seconds_ref [- 1 ] + 1e-4 ,
260
246
)
@@ -264,7 +250,6 @@ def test_pts_apis_against_index_ref(self, device):
264
250
* [
265
251
get_frames_by_pts_in_range (
266
252
decoder ,
267
- stream_index = stream_index ,
268
253
start_seconds = pts ,
269
254
stop_seconds = pts + 1e-4 ,
270
255
)
@@ -275,7 +260,7 @@ def test_pts_apis_against_index_ref(self, device):
275
260
torch .testing .assert_close (pts_seconds , all_pts_seconds_ref , atol = 0 , rtol = 0 )
276
261
277
262
_ , pts_seconds , _ = get_frames_by_pts (
278
- decoder , stream_index = stream_index , timestamps = all_pts_seconds_ref .tolist ()
263
+ decoder , timestamps = all_pts_seconds_ref .tolist ()
279
264
)
280
265
torch .testing .assert_close (pts_seconds , all_pts_seconds_ref , atol = 0 , rtol = 0 )
281
266
@@ -286,47 +271,37 @@ def test_get_frames_in_range(self, device):
286
271
287
272
# ensure that the degenerate case of a range of size 1 works
288
273
ref_frame0 = NASA_VIDEO .get_frame_data_by_range (0 , 1 )
289
- bulk_frame0 , * _ = get_frames_in_range (decoder , stream_index = 3 , start = 0 , stop = 1 )
274
+ bulk_frame0 , * _ = get_frames_in_range (decoder , start = 0 , stop = 1 )
290
275
assert_frames_equal (bulk_frame0 , ref_frame0 .to (device ))
291
276
292
277
ref_frame1 = NASA_VIDEO .get_frame_data_by_range (1 , 2 )
293
- bulk_frame1 , * _ = get_frames_in_range (decoder , stream_index = 3 , start = 1 , stop = 2 )
278
+ bulk_frame1 , * _ = get_frames_in_range (decoder , start = 1 , stop = 2 )
294
279
assert_frames_equal (bulk_frame1 , ref_frame1 .to (device ))
295
280
296
281
ref_frame389 = NASA_VIDEO .get_frame_data_by_range (389 , 390 )
297
- bulk_frame389 , * _ = get_frames_in_range (
298
- decoder , stream_index = 3 , start = 389 , stop = 390
299
- )
282
+ bulk_frame389 , * _ = get_frames_in_range (decoder , start = 389 , stop = 390 )
300
283
assert_frames_equal (bulk_frame389 , ref_frame389 .to (device ))
301
284
302
285
# contiguous ranges
303
286
ref_frames0_9 = NASA_VIDEO .get_frame_data_by_range (0 , 9 )
304
- bulk_frames0_9 , * _ = get_frames_in_range (
305
- decoder , stream_index = 3 , start = 0 , stop = 9
306
- )
287
+ bulk_frames0_9 , * _ = get_frames_in_range (decoder , start = 0 , stop = 9 )
307
288
assert_frames_equal (bulk_frames0_9 , ref_frames0_9 .to (device ))
308
289
309
290
ref_frames4_8 = NASA_VIDEO .get_frame_data_by_range (4 , 8 )
310
- bulk_frames4_8 , * _ = get_frames_in_range (
311
- decoder , stream_index = 3 , start = 4 , stop = 8
312
- )
291
+ bulk_frames4_8 , * _ = get_frames_in_range (decoder , start = 4 , stop = 8 )
313
292
assert_frames_equal (bulk_frames4_8 , ref_frames4_8 .to (device ))
314
293
315
294
# ranges with a stride
316
295
ref_frames15_35 = NASA_VIDEO .get_frame_data_by_range (15 , 36 , 5 )
317
- bulk_frames15_35 , * _ = get_frames_in_range (
318
- decoder , stream_index = 3 , start = 15 , stop = 36 , step = 5
319
- )
296
+ bulk_frames15_35 , * _ = get_frames_in_range (decoder , start = 15 , stop = 36 , step = 5 )
320
297
assert_frames_equal (bulk_frames15_35 , ref_frames15_35 .to (device ))
321
298
322
299
ref_frames0_9_2 = NASA_VIDEO .get_frame_data_by_range (0 , 9 , 2 )
323
- bulk_frames0_9_2 , * _ = get_frames_in_range (
324
- decoder , stream_index = 3 , start = 0 , stop = 9 , step = 2
325
- )
300
+ bulk_frames0_9_2 , * _ = get_frames_in_range (decoder , start = 0 , stop = 9 , step = 2 )
326
301
assert_frames_equal (bulk_frames0_9_2 , ref_frames0_9_2 .to (device ))
327
302
328
303
# an empty range is valid!
329
- empty_frame , * _ = get_frames_in_range (decoder , stream_index = 3 , start = 5 , stop = 5 )
304
+ empty_frame , * _ = get_frames_in_range (decoder , start = 5 , stop = 5 )
330
305
assert_frames_equal (empty_frame , NASA_VIDEO .empty_chw_tensor .to (device ))
331
306
332
307
@pytest .mark .parametrize ("device" , cpu_and_cuda ())
@@ -481,9 +456,9 @@ def test_frame_pts_equality(self):
481
456
# If this fails, there's a good chance that we accidentally truncated a 64-bit
482
457
# floating point value to a 32-bit floating value.
483
458
for i in range (390 ):
484
- frame , pts , _ = get_frame_at_index (decoder , stream_index = 3 , frame_index = i )
459
+ frame , pts , _ = get_frame_at_index (decoder , frame_index = i )
485
460
pts_is_equal = _test_frame_pts_equality (
486
- decoder , stream_index = 3 , frame_index = i , pts_seconds_to_test = pts .item ()
461
+ decoder , frame_index = i , pts_seconds_to_test = pts .item ()
487
462
)
488
463
assert pts_is_equal
489
464
@@ -564,32 +539,25 @@ def test_color_conversion_library_with_dimension_order(
564
539
frame0_ref = frame0_ref .permute (1 , 2 , 0 )
565
540
expected_shape = frame0_ref .shape
566
541
567
- stream_index = 3
568
- frame0 , * _ = get_frame_at_index (
569
- decoder , stream_index = stream_index , frame_index = 0
570
- )
542
+ frame0 , * _ = get_frame_at_index (decoder , frame_index = 0 )
571
543
assert frame0 .shape == expected_shape
572
544
assert_frames_equal (frame0 , frame0_ref )
573
545
574
546
frame0 , * _ = get_frame_at_pts (decoder , seconds = 0.0 )
575
547
assert frame0 .shape == expected_shape
576
548
assert_frames_equal (frame0 , frame0_ref )
577
549
578
- frames , * _ = get_frames_in_range (
579
- decoder , stream_index = stream_index , start = 0 , stop = 3
580
- )
550
+ frames , * _ = get_frames_in_range (decoder , start = 0 , stop = 3 )
581
551
assert frames .shape [1 :] == expected_shape
582
552
assert_frames_equal (frames [0 ], frame0_ref )
583
553
584
554
frames , * _ = get_frames_by_pts_in_range (
585
- decoder , stream_index = stream_index , start_seconds = 0 , stop_seconds = 1
555
+ decoder , start_seconds = 0 , stop_seconds = 1
586
556
)
587
557
assert frames .shape [1 :] == expected_shape
588
558
assert_frames_equal (frames [0 ], frame0_ref )
589
559
590
- frames , * _ = get_frames_at_indices (
591
- decoder , stream_index = stream_index , frame_indices = [0 , 1 , 3 , 4 ]
592
- )
560
+ frames , * _ = get_frames_at_indices (decoder , frame_indices = [0 , 1 , 3 , 4 ])
593
561
assert frames .shape [1 :] == expected_shape
594
562
assert_frames_equal (frames [0 ], frame0_ref )
595
563
0 commit comments