@@ -182,7 +182,6 @@ def _decode_frames_by_av_module(
182
182
video_start_pts/video_end_pts: the starting/ending Presentation TimeStamp where
183
183
frames are read
184
184
"""
185
- start_time = time .perf_counter ()
186
185
container = av .open (full_path )
187
186
188
187
video_frames = []
@@ -215,7 +214,6 @@ def _decode_frames_by_av_module(
215
214
container .close ()
216
215
vframes = [frame .to_rgb ().to_ndarray () for frame in video_frames ]
217
216
vframes = torch .as_tensor (np .stack (vframes ))
218
- elapsed_time = time .perf_counter () - start_time
219
217
220
218
vframe_pts = torch .tensor ([frame .pts for frame in video_frames ], dtype = torch .int64 )
221
219
@@ -354,7 +352,6 @@ def test_stress_test_read_video_from_file(self):
354
352
full_path = os .path .join (VIDEO_DIR , test_video )
355
353
356
354
# pass 1: decode all frames using new decoder
357
- start_time = time .perf_counter ()
358
355
tv_result = video_reader .read_video_from_file (
359
356
full_path ,
360
357
seek_frame_margin ,
@@ -392,7 +389,6 @@ def test_read_video_from_file(self):
392
389
full_path = os .path .join (VIDEO_DIR , test_video )
393
390
394
391
# pass 1: decode all frames using new decoder
395
- start_time = time .perf_counter ()
396
392
tv_result = video_reader .read_video_from_file (
397
393
full_path ,
398
394
seek_frame_margin ,
@@ -411,7 +407,6 @@ def test_read_video_from_file(self):
411
407
audio_timebase_num ,
412
408
audio_timebase_den ,
413
409
)
414
- elapsed_time = time .perf_counter () - start_time
415
410
# pass 2: decode all frames using av
416
411
pyav_result = _decode_frames_by_av_module (full_path )
417
412
# check results from TorchVision decoder
@@ -436,7 +431,6 @@ def test_read_video_from_file_rescale_min_dimension(self):
436
431
for test_video , config in test_videos .items ():
437
432
full_path = os .path .join (VIDEO_DIR , test_video )
438
433
439
- start_time = time .perf_counter ()
440
434
tv_result = video_reader .read_video_from_file (
441
435
full_path ,
442
436
seek_frame_margin ,
@@ -455,7 +449,6 @@ def test_read_video_from_file_rescale_min_dimension(self):
455
449
audio_timebase_num ,
456
450
audio_timebase_den ,
457
451
)
458
- elapsed_time = time .perf_counter () - start_time
459
452
self .assertEqual (min_dimension , min (tv_result [0 ].size (1 ), tv_result [0 ].size (2 )))
460
453
461
454
def test_read_video_from_file_rescale_width (self ):
@@ -475,7 +468,6 @@ def test_read_video_from_file_rescale_width(self):
475
468
for test_video , config in test_videos .items ():
476
469
full_path = os .path .join (VIDEO_DIR , test_video )
477
470
478
- start_time = time .perf_counter ()
479
471
tv_result = video_reader .read_video_from_file (
480
472
full_path ,
481
473
seek_frame_margin ,
@@ -494,7 +486,6 @@ def test_read_video_from_file_rescale_width(self):
494
486
audio_timebase_num ,
495
487
audio_timebase_den ,
496
488
)
497
- elapsed_time = time .perf_counter () - start_time
498
489
self .assertEqual (tv_result [0 ].size (2 ), width )
499
490
500
491
def test_read_video_from_file_rescale_height (self ):
@@ -514,7 +505,6 @@ def test_read_video_from_file_rescale_height(self):
514
505
for test_video , config in test_videos .items ():
515
506
full_path = os .path .join (VIDEO_DIR , test_video )
516
507
517
- start_time = time .perf_counter ()
518
508
tv_result = video_reader .read_video_from_file (
519
509
full_path ,
520
510
seek_frame_margin ,
@@ -533,7 +523,6 @@ def test_read_video_from_file_rescale_height(self):
533
523
audio_timebase_num ,
534
524
audio_timebase_den ,
535
525
)
536
- elapsed_time = time .perf_counter () - start_time
537
526
self .assertEqual (tv_result [0 ].size (1 ), height )
538
527
539
528
def test_read_video_from_file_rescale_width_and_height (self ):
@@ -553,7 +542,6 @@ def test_read_video_from_file_rescale_width_and_height(self):
553
542
for test_video , config in test_videos .items ():
554
543
full_path = os .path .join (VIDEO_DIR , test_video )
555
544
556
- start_time = time .perf_counter ()
557
545
tv_result = video_reader .read_video_from_file (
558
546
full_path ,
559
547
seek_frame_margin ,
@@ -572,7 +560,6 @@ def test_read_video_from_file_rescale_width_and_height(self):
572
560
audio_timebase_num ,
573
561
audio_timebase_den ,
574
562
)
575
- elapsed_time = time .perf_counter () - start_time
576
563
self .assertEqual (tv_result [0 ].size (1 ), height )
577
564
self .assertEqual (tv_result [0 ].size (2 ), width )
578
565
@@ -648,7 +635,6 @@ def test_compare_read_video_from_memory_and_file(self):
648
635
full_path , video_tensor = _get_video_tensor (VIDEO_DIR , test_video )
649
636
650
637
# pass 1: decode all frames using cpp decoder
651
- start_time = time .perf_counter ()
652
638
tv_result_memory = video_reader .read_video_from_memory (
653
639
video_tensor ,
654
640
seek_frame_margin ,
@@ -667,10 +653,8 @@ def test_compare_read_video_from_memory_and_file(self):
667
653
audio_timebase_num ,
668
654
audio_timebase_den ,
669
655
)
670
- elapsed_time = time .perf_counter () - start_time
671
656
self .check_separate_decoding_result (tv_result_memory , config )
672
657
# pass 2: decode all frames from file
673
- start_time = time .perf_counter ()
674
658
tv_result_file = video_reader .read_video_from_file (
675
659
full_path ,
676
660
seek_frame_margin ,
@@ -689,7 +673,6 @@ def test_compare_read_video_from_memory_and_file(self):
689
673
audio_timebase_num ,
690
674
audio_timebase_den ,
691
675
)
692
- elapsed_time = time .perf_counter () - start_time
693
676
694
677
self .check_separate_decoding_result (tv_result_file , config )
695
678
# finally, compare results decoded from memory and file
@@ -713,7 +696,6 @@ def test_read_video_from_file(self):
713
696
full_path = os .path .join (VIDEO_DIR , test_video )
714
697
715
698
# pass 1: decode all frames using new decoder
716
- start_time = time .perf_counter ()
717
699
tv_result = video_reader .read_video_from_file (
718
700
full_path ,
719
701
seek_frame_margin ,
@@ -732,7 +714,6 @@ def test_read_video_from_file(self):
732
714
audio_timebase_num ,
733
715
audio_timebase_den ,
734
716
)
735
- elapsed_time = time .perf_counter () - start_time
736
717
# pass 2: decode all frames using av
737
718
pyav_result = _decode_frames_by_av_module (full_path )
738
719
@@ -757,7 +738,6 @@ def test_read_video_from_memory(self):
757
738
full_path , video_tensor = _get_video_tensor (VIDEO_DIR , test_video )
758
739
759
740
# pass 1: decode all frames using cpp decoder
760
- start_time = time .perf_counter ()
761
741
tv_result = video_reader .read_video_from_memory (
762
742
video_tensor ,
763
743
seek_frame_margin ,
@@ -776,7 +756,6 @@ def test_read_video_from_memory(self):
776
756
audio_timebase_num ,
777
757
audio_timebase_den ,
778
758
)
779
- elapsed_time = time .perf_counter () - start_time
780
759
# pass 2: decode all frames using av
781
760
pyav_result = _decode_frames_by_av_module (full_path )
782
761
@@ -802,7 +781,6 @@ def test_read_video_from_memory_get_pts_only(self):
802
781
full_path , video_tensor = _get_video_tensor (VIDEO_DIR , test_video )
803
782
804
783
# pass 1: decode all frames using cpp decoder
805
- start_time = time .perf_counter ()
806
784
tv_result = video_reader .read_video_from_memory (
807
785
video_tensor ,
808
786
seek_frame_margin ,
@@ -821,11 +799,9 @@ def test_read_video_from_memory_get_pts_only(self):
821
799
audio_timebase_num ,
822
800
audio_timebase_den ,
823
801
)
824
- elapsed_time = time .perf_counter () - start_time
825
802
self .assertAlmostEqual (config .video_fps , tv_result [3 ].item (), delta = 0.01 )
826
803
827
804
# pass 2: decode all frames to get PTS only using cpp decoder
828
- start_time = time .perf_counter ()
829
805
tv_result_pts_only = video_reader .read_video_from_memory (
830
806
video_tensor ,
831
807
seek_frame_margin ,
@@ -844,7 +820,6 @@ def test_read_video_from_memory_get_pts_only(self):
844
820
audio_timebase_num ,
845
821
audio_timebase_den ,
846
822
)
847
- elapsed_time = time .perf_counter () - start_time
848
823
849
824
self .assertEqual (tv_result_pts_only [0 ].numel (), 0 )
850
825
self .assertEqual (tv_result_pts_only [4 ].numel (), 0 )
@@ -867,7 +842,6 @@ def test_read_video_in_range_from_memory(self):
867
842
audio_start_pts , audio_end_pts = 0 , - 1
868
843
audio_timebase_num , audio_timebase_den = 0 , 1
869
844
# pass 1: decode all frames using new decoder
870
- start_time = time .perf_counter ()
871
845
tv_result = video_reader .read_video_from_memory (
872
846
video_tensor ,
873
847
seek_frame_margin ,
@@ -889,7 +863,6 @@ def test_read_video_in_range_from_memory(self):
889
863
vframes , vframe_pts , vtimebase , vfps , aframes , aframe_pts , atimebase , asample_rate = (
890
864
tv_result
891
865
)
892
- elapsed_time = time .perf_counter () - start_time
893
866
self .assertAlmostEqual (config .video_fps , vfps .item (), delta = 0.01 )
894
867
895
868
for num_frames in [4 , 8 , 16 , 32 , 64 , 128 ]:
@@ -920,7 +893,6 @@ def test_read_video_in_range_from_memory(self):
920
893
)
921
894
922
895
# pass 2: decode frames in the randomly generated range
923
- start_time = time .perf_counter ()
924
896
tv_result = video_reader .read_video_from_memory (
925
897
video_tensor ,
926
898
seek_frame_margin ,
@@ -939,7 +911,6 @@ def test_read_video_in_range_from_memory(self):
939
911
audio_timebase_num ,
940
912
audio_timebase_den ,
941
913
)
942
- elapsed_time = time .perf_counter () - start_time
943
914
944
915
# pass 3: decode frames in range using PyAv
945
916
video_timebase_av , audio_timebase_av = _get_timebase_by_av_module (full_path )
0 commit comments