1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| import subprocess import os import time
video_source_dir = "videos_source"
output_dir = "api_out"
temp_dir = 'videos_temp'
api_dir = 'videos_apiout'
for video_file in os.listdir(video_source_dir): timestamp = int(time.time()) if video_file.endswith(".mp4"):
video_path = os.path.join(video_source_dir, video_file) command = [ "python", "main_yolo_dected_video.py", "--source", temp_dir+'/'+str(timestamp), "--out_dir", api_dir+'/'+str(timestamp), "--video_path", video_path ] result = subprocess.run(command) if result.returncode == 0: print(f"Processed {video_file} successfully.") else: print(f"Failed to process {video_file}. Error code: {result.returncode}")
|