How to use get_frame method in Airtest

Best Python code snippet using Airtest

video_sampling.py

Source:video_sampling.py Github

copy

Full Screen

2import ffmpeg3import os4from database import SQLiteDatabase, ImageSample5import subprocess6def get_frame(fps: int,7 h: int,8 m: int,9 s: int,10 ms: int,11 first_frame: int = 80) -> int:12 """ Convert the timestamp to a the respective frame number13 :param int fps: frames per second of video14 :param int h: hours15 :param int m: minutes16 :param int s: seconds17 :param int ms: milliseconds18 :param int first_frame: first frame ms of avidemux.19 :returns: frame number as int20 """21 frame_duration = (1 / fps) * 100022 total_duration = ((((h * 60) + m) * 60) + s) * 1000 + ms - first_frame23 return int(total_duration / frame_duration)24def extract_frames(frame_dict: dict,25 base_path: str = "/home/nico/isys/data",26 database_name: str = "database.db",27 output_folder: str = "images"):28 """ Convert a list of frames of one video to the respective images29 :param List frame_dict: dictionary containing video name as key and the list of frames as values30 :param str database_name: name of the SQLite database file31 :param str base_path: path to the base folder where to extract to32 :param str output_folder: name of the output folder where the images are saved to33 """34 for video_name, frames in frame_dict.items():35 # sort the video list based on the frame number36 # TODO: include a database entry and saving37 frame_list = sorted(frames)38 # check for filetype39 if os.path.splitext(video_name)[-1] == ".mp4":40 video_name_without_filetype = os.path.splitext(video_name)[0]41 elif not os.path.splitext(video_name)[-1]:42 # empty file type specifier43 video_name_without_filetype = video_name44 video_name = video_name + ".mp4"45 else:46 raise AttributeError(f"{os.path.splitext(video_name)[-1]} format unsupported")47 # combine to relative path48 video_name = os.path.join("converted", video_name)49 original_path = os.path.join(base_path, video_name)50 database = SQLiteDatabase(os.path.join(base_path, database_name))51 database.create_images_table()52 for idx, frame in enumerate(frame_list):53 num = database.get_num_entries_specific(table_name="images",54 column_name="video_path",55 entry_name=video_name)56 filename = os.path.join(output_folder, f"{video_name_without_filetype}_{num + 1:04d}.png")57 if os.path.isfile(original_path):58 # TODO: extract one frame before and after current one?59 if database.add_image(video_name, filename, frame):60 out, err = (ffmpeg.input(original_path).filter_('select', 'gte(n,{})'.format(frame))61 .output(os.path.join(base_path, filename), vframes=1, )62 .run(capture_stdout=True, quiet=True))63 print(f"Processed Image {idx + 1}/{len(frame_list)}")64 else:65 raise ValueError(f"{original_path} is not a valid file. Check paths and video name")66 four = 467def add_duration_to_sql(base_path: str = "/home/nico/isys/data",68 database_name: str = "database.db"):69 db = SQLiteDatabase(os.path.join(base_path, database_name))70 for video in os.listdir(os.path.join(base_path, "converted")):71 duration = get_duration(os.path.join(base_path, "converted", video)) * 1000.072 db.update_entry('videos', 'dest', "converted/" + str(video), 'duration', duration)73def get_duration(file):74 """Get the duration of a video using ffprobe."""75 cmd = 'ffprobe -i {} -show_entries format=duration -v quiet -of csv="p=0"'.format(file)76 output = subprocess.check_output(77 cmd,78 shell=True, # Let this run in the shell79 stderr=subprocess.STDOUT80 )81 # return round(float(output)) # ugly, but rounds your seconds up or down82 return float(output)83frame_dictionary = \84 {85 "video0001.mp4": [get_frame(fps=25, h=0, m=0, s=1, ms=880),86 get_frame(fps=25, h=0, m=0, s=19, ms=520),87 get_frame(fps=25, h=0, m=0, s=24, ms=640),88 get_frame(fps=25, h=0, m=0, s=40, ms=200),89 get_frame(fps=25, h=0, m=0, s=48, ms=440),90 get_frame(fps=25, h=0, m=0, s=50, ms=80),91 get_frame(fps=25, h=0, m=0, s=59, ms=920),92 get_frame(fps=25, h=0, m=1, s=1, ms=840),93 get_frame(fps=25, h=0, m=1, s=4, ms=80),94 get_frame(fps=25, h=0, m=1, s=6, ms=40),95 get_frame(fps=25, h=0, m=1, s=12, ms=400),96 get_frame(fps=25, h=0, m=1, s=18, ms=40),97 get_frame(fps=25, h=0, m=1, s=25, ms=240),98 get_frame(fps=25, h=0, m=1, s=28, ms=640),99 get_frame(fps=25, h=0, m=1, s=32, ms=680),100 get_frame(fps=25, h=0, m=1, s=36, ms=240),101 get_frame(fps=25, h=0, m=0, s=12, ms=640)],102 "video0002.mp4": [get_frame(fps=25, h=0, m=0, s=0, ms=240),103 get_frame(fps=25, h=0, m=0, s=5, ms=720),104 get_frame(fps=25, h=0, m=0, s=11, ms=120),105 get_frame(fps=25, h=0, m=0, s=19, ms=800),106 get_frame(fps=25, h=0, m=0, s=26, ms=440),107 get_frame(fps=25, h=0, m=0, s=39, ms=0),108 get_frame(fps=25, h=0, m=0, s=44, ms=920),109 get_frame(fps=25, h=0, m=0, s=49, ms=400),110 get_frame(fps=25, h=0, m=0, s=52, ms=120),111 get_frame(fps=25, h=0, m=1, s=14, ms=120),112 get_frame(fps=25, h=0, m=1, s=25, ms=240),113 ],114 "video0003.mp4": [get_frame(fps=25, h=0, m=0, s=1, ms=120),115 get_frame(fps=25, h=0, m=0, s=10, ms=480),116 get_frame(fps=25, h=0, m=0, s=12, ms=880),117 get_frame(fps=25, h=0, m=0, s=15, ms=440),118 get_frame(fps=25, h=0, m=0, s=21, ms=600),119 get_frame(fps=25, h=0, m=0, s=26, ms=320),120 get_frame(fps=25, h=0, m=0, s=36, ms=600),121 get_frame(fps=25, h=0, m=0, s=37, ms=80),122 get_frame(fps=25, h=0, m=0, s=43, ms=600),123 get_frame(fps=25, h=0, m=0, s=51, ms=960),124 get_frame(fps=25, h=0, m=0, s=55, ms=840),125 get_frame(fps=25, h=0, m=1, s=1, ms=440),126 get_frame(fps=25, h=0, m=1, s=3, ms=760),127 get_frame(fps=25, h=0, m=1, s=6, ms=440),128 get_frame(fps=25, h=0, m=1, s=24, ms=880)],129 "video0004.mp4": [get_frame(fps=25, h=0, m=0, s=0, ms=400),130 get_frame(fps=25, h=0, m=0, s=14, ms=800),131 get_frame(fps=25, h=0, m=0, s=20, ms=280),132 get_frame(fps=25, h=0, m=0, s=22, ms=440),133 get_frame(fps=25, h=0, m=0, s=30, ms=480),134 get_frame(fps=25, h=0, m=0, s=40, ms=520),135 get_frame(fps=25, h=0, m=0, s=43, ms=120),136 get_frame(fps=25, h=0, m=0, s=51, ms=40),137 get_frame(fps=25, h=0, m=1, s=0, ms=40),138 get_frame(fps=25, h=0, m=1, s=6, ms=440),139 get_frame(fps=25, h=0, m=1, s=7, ms=720),140 get_frame(fps=25, h=0, m=1, s=15, ms=960),141 get_frame(fps=25, h=0, m=1, s=26, ms=360),142 ],143 "video0005.mp4": [get_frame(fps=25, h=0, m=0, s=4, ms=640),144 get_frame(fps=25, h=0, m=0, s=10, ms=0),145 get_frame(fps=25, h=0, m=0, s=21, ms=960),146 get_frame(fps=25, h=0, m=1, s=0, ms=560)],147 "video0006.mp4": [get_frame(fps=25, h=0, m=0, s=0, ms=0),148 get_frame(fps=25, h=0, m=0, s=5, ms=280),149 get_frame(fps=25, h=0, m=0, s=9, ms=320),150 get_frame(fps=25, h=0, m=0, s=14, ms=280),151 get_frame(fps=25, h=0, m=0, s=36, ms=520),152 get_frame(fps=25, h=0, m=0, s=45, ms=80),153 get_frame(fps=25, h=0, m=0, s=57, ms=360),154 get_frame(fps=25, h=0, m=0, s=59, ms=880),155 get_frame(fps=25, h=0, m=1, s=5, ms=960),156 get_frame(fps=25, h=0, m=1, s=7, ms=0),157 get_frame(fps=25, h=0, m=0, s=4, ms=640),158 get_frame(fps=25, h=0, m=2, s=1, ms=80),159 get_frame(fps=25, h=0, m=2, s=10, ms=360),160 get_frame(fps=25, h=0, m=2, s=18, ms=480),161 get_frame(fps=25, h=0, m=2, s=26, ms=800),162 get_frame(fps=25, h=0, m=2, s=29, ms=960),163 get_frame(fps=25, h=0, m=2, s=33, ms=560),164 get_frame(fps=25, h=0, m=2, s=41, ms=480),165 get_frame(fps=25, h=0, m=2, s=52, ms=120),166 get_frame(fps=25, h=0, m=2, s=59, ms=400),167 get_frame(fps=25, h=0, m=3, s=6, ms=640),168 get_frame(fps=25, h=0, m=3, s=10, ms=480),169 get_frame(fps=25, h=0, m=3, s=21, ms=600),170 get_frame(fps=25, h=0, m=3, s=27, ms=520),171 get_frame(fps=25, h=0, m=3, s=35, ms=800),172 get_frame(fps=25, h=0, m=3, s=42, ms=240),173 get_frame(fps=25, h=0, m=3, s=58, ms=920),174 get_frame(fps=25, h=0, m=4, s=5, ms=80),175 get_frame(fps=25, h=0, m=4, s=32, ms=40),176 get_frame(fps=25, h=0, m=4, s=35, ms=320),177 get_frame(fps=25, h=0, m=4, s=39, ms=880),178 get_frame(fps=25, h=0, m=4, s=43, ms=0),179 get_frame(fps=25, h=0, m=4, s=54, ms=560),180 get_frame(fps=25, h=0, m=4, s=59, ms=840),181 get_frame(fps=25, h=0, m=5, s=9, ms=80),182 get_frame(fps=25, h=0, m=6, s=37, ms=800),183 get_frame(fps=25, h=0, m=6, s=56, ms=240),184 get_frame(fps=25, h=0, m=7, s=0, ms=120),185 get_frame(fps=25, h=0, m=7, s=6, ms=0),186 get_frame(fps=25, h=0, m=7, s=7, ms=200),187 get_frame(fps=25, h=0, m=9, s=13, ms=880),188 get_frame(fps=25, h=0, m=9, s=16, ms=40),189 get_frame(fps=25, h=0, m=9, s=19, ms=840),190 get_frame(fps=25, h=0, m=9, s=28, ms=120),191 get_frame(fps=25, h=0, m=9, s=37, ms=320),192 get_frame(fps=25, h=0, m=9, s=43, ms=560),193 get_frame(fps=25, h=0, m=9, s=57, ms=200),194 get_frame(fps=25, h=0, m=10, s=4, ms=640),195 get_frame(fps=25, h=0, m=10, s=17, ms=520),196 get_frame(fps=25, h=0, m=10, s=37, ms=400),197 get_frame(fps=25, h=0, m=10, s=40, ms=320),198 get_frame(fps=25, h=0, m=10, s=47, ms=320),199 get_frame(fps=25, h=0, m=10, s=58, ms=720),200 get_frame(fps=25, h=0, m=11, s=7, ms=400),201 get_frame(fps=25, h=0, m=11, s=17, ms=40),202 get_frame(fps=25, h=0, m=11, s=33, ms=960),203 get_frame(fps=25, h=0, m=12, s=0, ms=440),204 get_frame(fps=25, h=0, m=12, s=33, ms=840),205 get_frame(fps=25, h=0, m=12, s=42, ms=880),206 get_frame(fps=25, h=0, m=0, s=5, ms=280),207 ],208 "video0007.mp4": [get_frame(fps=25, h=0, m=0, s=7, ms=440),209 get_frame(fps=25, h=0, m=0, s=13, ms=360),210 get_frame(fps=25, h=0, m=0, s=16, ms=80),211 get_frame(fps=25, h=0, m=0, s=27, ms=760),212 get_frame(fps=25, h=0, m=1, s=13, ms=960),213 get_frame(fps=25, h=0, m=1, s=26, ms=320),214 get_frame(fps=25, h=0, m=1, s=39, ms=0),215 get_frame(fps=25, h=0, m=1, s=54, ms=200),216 get_frame(fps=25, h=0, m=2, s=2, ms=840),217 get_frame(fps=25, h=0, m=2, s=13, ms=360),218 get_frame(fps=25, h=0, m=2, s=36, ms=720),219 ],220 "video0008.mp4": [get_frame(fps=25, h=0, m=0, s=0, ms=0),221 get_frame(fps=25, h=0, m=0, s=6, ms=40),222 get_frame(fps=25, h=0, m=0, s=20, ms=160),223 get_frame(fps=25, h=0, m=0, s=30, ms=920),224 get_frame(fps=25, h=0, m=0, s=33, ms=440),225 get_frame(fps=25, h=0, m=0, s=38, ms=880),226 get_frame(fps=25, h=0, m=0, s=41, ms=40),227 get_frame(fps=25, h=0, m=0, s=47, ms=760),228 get_frame(fps=25, h=0, m=0, s=49, ms=600),229 get_frame(fps=25, h=0, m=0, s=52, ms=680),230 get_frame(fps=25, h=0, m=1, s=3, ms=400),231 get_frame(fps=25, h=0, m=1, s=20, ms=200),232 get_frame(fps=25, h=0, m=1, s=43, ms=0),233 get_frame(fps=25, h=0, m=1, s=45, ms=320),234 get_frame(fps=25, h=0, m=1, s=47, ms=400),235 get_frame(fps=25, h=0, m=1, s=51, ms=640),236 get_frame(fps=25, h=0, m=1, s=54, ms=560),237 get_frame(fps=25, h=0, m=1, s=57, ms=440),238 ],239 "video0009.mp4": [get_frame(fps=25, h=0, m=0, s=3, ms=480),240 get_frame(fps=25, h=0, m=0, s=10, ms=400),241 get_frame(fps=25, h=0, m=0, s=15, ms=80),242 get_frame(fps=25, h=0, m=0, s=22, ms=800),243 get_frame(fps=25, h=0, m=0, s=34, ms=40),244 get_frame(fps=25, h=0, m=0, s=43, ms=160),245 get_frame(fps=25, h=0, m=1, s=1, ms=960),246 get_frame(fps=25, h=0, m=1, s=3, ms=160),247 get_frame(fps=25, h=0, m=1, s=8, ms=200),248 get_frame(fps=25, h=0, m=1, s=40, ms=160),249 get_frame(fps=25, h=0, m=1, s=44, ms=840),250 get_frame(fps=25, h=0, m=1, s=54, ms=720),251 get_frame(fps=25, h=0, m=1, s=58, ms=0),252 get_frame(fps=25, h=0, m=2, s=16, ms=920),253 ],254 "video0010.mp4": [get_frame(fps=25, h=0, m=0, s=0, ms=0),255 get_frame(fps=25, h=0, m=0, s=7, ms=600),256 get_frame(fps=25, h=0, m=0, s=10, ms=880),257 get_frame(fps=25, h=0, m=0, s=13, ms=160),258 get_frame(fps=25, h=0, m=0, s=25, ms=760),259 get_frame(fps=25, h=0, m=0, s=30, ms=280),260 get_frame(fps=25, h=0, m=0, s=36, ms=160),261 get_frame(fps=25, h=0, m=0, s=38, ms=880),262 get_frame(fps=25, h=0, m=0, s=43, ms=40),263 get_frame(fps=25, h=0, m=0, s=47, ms=480),264 get_frame(fps=25, h=0, m=0, s=54, ms=480),265 get_frame(fps=25, h=0, m=0, s=55, ms=960),266 get_frame(fps=25, h=0, m=1, s=0, ms=920),267 ],268 "video0011.mp4": [get_frame(fps=25, h=0, m=0, s=3, ms=400),269 get_frame(fps=25, h=0, m=0, s=8, ms=920),270 get_frame(fps=25, h=0, m=0, s=18, ms=680),271 get_frame(fps=25, h=0, m=0, s=22, ms=240),272 get_frame(fps=25, h=0, m=0, s=26, ms=200),273 get_frame(fps=25, h=0, m=0, s=36, ms=520),274 get_frame(fps=25, h=0, m=0, s=44, ms=360),275 get_frame(fps=25, h=0, m=0, s=54, ms=960),276 get_frame(fps=25, h=0, m=1, s=4, ms=160),277 get_frame(fps=25, h=0, m=1, s=7, ms=240),278 get_frame(fps=25, h=0, m=1, s=10, ms=280),279 get_frame(fps=25, h=0, m=1, s=15, ms=120),280 get_frame(fps=25, h=0, m=1, s=23, ms=680),281 get_frame(fps=25, h=0, m=1, s=44, ms=80),282 get_frame(fps=25, h=0, m=1, s=45, ms=600),283 ],284 "video0012.mp4": [get_frame(fps=25, h=0, m=0, s=5, ms=400),285 get_frame(fps=25, h=0, m=0, s=7, ms=360),286 get_frame(fps=25, h=0, m=0, s=13, ms=360),287 get_frame(fps=25, h=0, m=0, s=28, ms=160),288 get_frame(fps=25, h=0, m=0, s=32, ms=640),289 ],290 "video0013.mp4": [get_frame(fps=25, h=0, m=0, s=1, ms=120),291 get_frame(fps=25, h=0, m=0, s=8, ms=320),292 get_frame(fps=25, h=0, m=0, s=13, ms=800),293 get_frame(fps=25, h=0, m=0, s=20, ms=240),294 get_frame(fps=25, h=0, m=0, s=25, ms=760),295 get_frame(fps=25, h=0, m=0, s=36, ms=320),296 get_frame(fps=25, h=0, m=0, s=40, ms=120),297 get_frame(fps=25, h=0, m=0, s=47, ms=640),298 get_frame(fps=25, h=0, m=1, s=2, ms=400),299 get_frame(fps=25, h=0, m=1, s=9, ms=80),300 get_frame(fps=25, h=0, m=1, s=11, ms=200),301 get_frame(fps=25, h=0, m=1, s=16, ms=440),302 get_frame(fps=25, h=0, m=1, s=32, ms=160),303 get_frame(fps=25, h=0, m=1, s=37, ms=160),304 get_frame(fps=25, h=0, m=1, s=42, ms=680),305 get_frame(fps=25, h=0, m=1, s=51, ms=800),306 get_frame(fps=25, h=0, m=2, s=17, ms=600),307 get_frame(fps=25, h=0, m=2, s=30, ms=960),308 get_frame(fps=25, h=0, m=2, s=41, ms=600),309 get_frame(fps=25, h=0, m=2, s=53, ms=680),310 get_frame(fps=25, h=0, m=3, s=18, ms=600),311 get_frame(fps=25, h=0, m=3, s=33, ms=960),312 get_frame(fps=25, h=0, m=3, s=45, ms=320),313 get_frame(fps=25, h=0, m=3, s=54, ms=480),314 get_frame(fps=25, h=0, m=4, s=7, ms=200),315 get_frame(fps=25, h=0, m=4, s=32, ms=720),316 get_frame(fps=25, h=0, m=4, s=40, ms=520),317 get_frame(fps=25, h=0, m=5, s=0, ms=120),],318 "video0014.mp4": [get_frame(fps=25, h=0, m=0, s=8, ms=800),319 get_frame(fps=25, h=0, m=0, s=11, ms=920),320 get_frame(fps=25, h=0, m=0, s=19, ms=0),321 get_frame(fps=25, h=0, m=0, s=25, ms=960),322 get_frame(fps=25, h=0, m=0, s=34, ms=800),323 get_frame(fps=25, h=0, m=0, s=45, ms=320),324 get_frame(fps=25, h=0, m=0, s=49, ms=480),325 get_frame(fps=25, h=0, m=1, s=4, ms=560),326 get_frame(fps=25, h=0, m=1, s=12, ms=120),327 get_frame(fps=25, h=0, m=1, s=45, ms=280),328 get_frame(fps=25, h=0, m=1, s=52, ms=400),329 get_frame(fps=25, h=0, m=2, s=5, ms=280),330 get_frame(fps=25, h=0, m=2, s=34, ms=120),331 get_frame(fps=25, h=0, m=3, s=4, ms=920),332 get_frame(fps=25, h=0, m=3, s=13, ms=960),333 get_frame(fps=25, h=0, m=3, s=20, ms=880),334 get_frame(fps=25, h=0, m=3, s=27, ms=200),335 get_frame(fps=25, h=0, m=3, s=40, ms=880),336 get_frame(fps=25, h=0, m=3, s=59, ms=120),337 get_frame(fps=25, h=0, m=4, s=18, ms=520),338 get_frame(fps=25, h=0, m=4, s=40, ms=440),339 get_frame(fps=25, h=0, m=4, s=46, ms=960),340 get_frame(fps=25, h=0, m=4, s=59, ms=120),341 get_frame(fps=25, h=0, m=5, s=31, ms=920),342 get_frame(fps=25, h=0, m=5, s=40, ms=40),343 get_frame(fps=25, h=0, m=5, s=48, ms=320),344 get_frame(fps=25, h=0, m=5, s=52, ms=560),345 get_frame(fps=25, h=0, m=5, s=55, ms=600),346 get_frame(fps=25, h=0, m=5, s=58, ms=640),347 get_frame(fps=25, h=0, m=6, s=4, ms=480),348 get_frame(fps=25, h=0, m=6, s=6, ms=80),349 get_frame(fps=25, h=0, m=6, s=21, ms=440),350 get_frame(fps=25, h=0, m=6, s=33, ms=160),351 get_frame(fps=25, h=0, m=6, s=44, ms=0),352 get_frame(fps=25, h=0, m=6, s=50, ms=400),353 get_frame(fps=25, h=0, m=6, s=57, ms=680),],354 "video0015.mp4": [get_frame(fps=25, h=0, m=0, s=1, ms=760),355 get_frame(fps=25, h=0, m=0, s=7, ms=600),356 get_frame(fps=25, h=0, m=0, s=13, ms=360),357 get_frame(fps=25, h=0, m=0, s=23, ms=400),358 get_frame(fps=25, h=0, m=0, s=29, ms=160),359 get_frame(fps=25, h=0, m=0, s=35, ms=880),360 get_frame(fps=25, h=0, m=0, s=42, ms=80),361 get_frame(fps=25, h=0, m=0, s=52, ms=800),362 get_frame(fps=25, h=0, m=0, s=56, ms=560),363 get_frame(fps=25, h=0, m=1, s=0, ms=680),364 get_frame(fps=25, h=0, m=1, s=10, ms=0),365 get_frame(fps=25, h=0, m=1, s=18, ms=400),366 get_frame(fps=25, h=0, m=1, s=38, ms=760),367 get_frame(fps=25, h=0, m=1, s=50, ms=560),368 get_frame(fps=25, h=0, m=1, s=59, ms=280),369 ],370 "video0016.mp4": [get_frame(fps=25, h=0, m=0, s=0, ms=80),371 get_frame(fps=25, h=0, m=0, s=4, ms=440),372 get_frame(fps=25, h=0, m=0, s=11, ms=560),373 get_frame(fps=25, h=0, m=0, s=14, ms=680),374 get_frame(fps=25, h=0, m=0, s=17, ms=360),375 get_frame(fps=25, h=0, m=0, s=22, ms=680),376 get_frame(fps=25, h=0, m=0, s=51, ms=680),377 get_frame(fps=25, h=0, m=0, s=59, ms=160),378 get_frame(fps=25, h=0, m=1, s=8, ms=360),379 get_frame(fps=25, h=0, m=1, s=11, ms=880),380 get_frame(fps=25, h=0, m=1, s=17, ms=440),381 get_frame(fps=25, h=0, m=1, s=28, ms=280),382 get_frame(fps=25, h=0, m=1, s=41, ms=720),383 get_frame(fps=25, h=0, m=3, s=1, ms=760),384 get_frame(fps=25, h=0, m=3, s=6, ms=960),385 get_frame(fps=25, h=0, m=3, s=17, ms=120),386 get_frame(fps=25, h=0, m=3, s=23, ms=600),387 get_frame(fps=25, h=0, m=4, s=23, ms=880),388 get_frame(fps=25, h=0, m=4, s=34, ms=200),389 get_frame(fps=25, h=0, m=4, s=48, ms=680),390 ],391 "video0017.mp4": [get_frame(fps=25, h=0, m=0, s=6, ms=160),392 get_frame(fps=25, h=0, m=0, s=17, ms=40),393 get_frame(fps=25, h=0, m=0, s=0, ms=0),394 ],395 "video0018.mp4": [get_frame(fps=25, h=0, m=0, s=1, ms=800),396 get_frame(fps=25, h=0, m=0, s=7, ms=520),397 get_frame(fps=25, h=0, m=0, s=29, ms=480),398 get_frame(fps=25, h=0, m=0, s=42, ms=880),399 get_frame(fps=25, h=0, m=1, s=7, ms=680),400 get_frame(fps=25, h=0, m=1, s=13, ms=640),401 ],402 "video0019.mp4": [get_frame(fps=25, h=0, m=0, s=2, ms=520),403 get_frame(fps=25, h=0, m=0, s=19, ms=440),404 get_frame(fps=25, h=0, m=0, s=35, ms=800),405 get_frame(fps=25, h=0, m=1, s=3, ms=280),406 get_frame(fps=25, h=0, m=1, s=25, ms=760),407 get_frame(fps=25, h=0, m=1, s=40, ms=240),408 get_frame(fps=25, h=0, m=2, s=6, ms=520),409 get_frame(fps=25, h=0, m=2, s=13, ms=440),410 get_frame(fps=25, h=0, m=2, s=21, ms=560),411 get_frame(fps=25, h=0, m=2, s=34, ms=720),412 get_frame(fps=25, h=0, m=2, s=50, ms=400),413 get_frame(fps=25, h=0, m=2, s=59, ms=400),414 get_frame(fps=25, h=0, m=3, s=20, ms=400),415 get_frame(fps=25, h=0, m=4, s=24, ms=40),416 ],417 "video0020.mp4": [get_frame(fps=25, h=0, m=0, s=3, ms=520),418 get_frame(fps=25, h=0, m=0, s=16, ms=0),419 ],420 "video0021.mp4": [get_frame(fps=25, h=0, m=0, s=3, ms=720),421 get_frame(fps=25, h=0, m=0, s=10, ms=840),422 get_frame(fps=25, h=0, m=0, s=14, ms=600),423 get_frame(fps=25, h=0, m=0, s=36, ms=40),424 ],425 "video0022.mp4": [get_frame(fps=25, h=0, m=0, s=31, ms=360),426 get_frame(fps=25, h=0, m=2, s=24, ms=640),427 get_frame(fps=25, h=0, m=3, s=35, ms=200),428 get_frame(fps=25, h=0, m=4, s=19, ms=680),429 get_frame(fps=25, h=0, m=4, s=39, ms=80),430 ],431 "video0023.mp4": [get_frame(fps=25, h=0, m=0, s=13, ms=840),432 get_frame(fps=25, h=0, m=0, s=52, ms=160),433 get_frame(fps=25, h=0, m=1, s=5, ms=760),434 get_frame(fps=25, h=0, m=1, s=26, ms=520),435 ],436 "video0024.mp4": [get_frame(fps=25, h=0, m=0, s=4, ms=600),437 get_frame(fps=25, h=0, m=0, s=8, ms=640),438 get_frame(fps=25, h=0, m=0, s=15, ms=200),439 get_frame(fps=25, h=0, m=0, s=19, ms=360),440 get_frame(fps=25, h=0, m=0, s=27, ms=640),441 get_frame(fps=25, h=0, m=0, s=39, ms=440),442 get_frame(fps=25, h=0, m=0, s=44, ms=800),443 get_frame(fps=25, h=0, m=0, s=47, ms=80),444 get_frame(fps=25, h=0, m=0, s=52, ms=920),445 get_frame(fps=25, h=0, m=1, s=7, ms=520),446 get_frame(fps=25, h=0, m=1, s=18, ms=840)447 ],448 "video0025.mp4": [get_frame(fps=25, h=0, m=0, s=6, ms=200),449 get_frame(fps=25, h=0, m=0, s=43, ms=240),450 get_frame(fps=25, h=0, m=0, s=51, ms=200),451 get_frame(fps=25, h=0, m=1, s=13, ms=200),452 get_frame(fps=25, h=0, m=1, s=26, ms=320),453 get_frame(fps=25, h=0, m=1, s=45, ms=200),454 get_frame(fps=25, h=0, m=1, s=50, ms=600),455 get_frame(fps=25, h=0, m=2, s=41, ms=400),456 get_frame(fps=25, h=0, m=4, s=8, ms=320),457 get_frame(fps=25, h=0, m=4, s=5, ms=960),458 get_frame(fps=25, h=0, m=4, s=24, ms=280),459 get_frame(fps=25, h=0, m=4, s=33, ms=520),460 get_frame(fps=25, h=0, m=5, s=9, ms=320),461 get_frame(fps=25, h=0, m=5, s=19, ms=720),462 ],463 "video0026.mp4": [get_frame(fps=25, h=0, m=0, s=12, ms=40),464 get_frame(fps=25, h=0, m=0, s=20, ms=0),465 get_frame(fps=25, h=0, m=0, s=27, ms=80),466 get_frame(fps=25, h=0, m=0, s=33, ms=400),467 get_frame(fps=25, h=0, m=0, s=40, ms=120),468 get_frame(fps=25, h=0, m=0, s=56, ms=240),469 get_frame(fps=25, h=0, m=1, s=21, ms=0),470 get_frame(fps=25, h=0, m=1, s=29, ms=400),471 get_frame(fps=25, h=0, m=1, s=31, ms=760),472 ],473 "video0027.mp4": [get_frame(fps=25, h=0, m=0, s=0, ms=80),474 get_frame(fps=25, h=0, m=0, s=2, ms=920),475 get_frame(fps=25, h=0, m=0, s=4, ms=680),476 get_frame(fps=25, h=0, m=0, s=8, ms=320),477 get_frame(fps=25, h=0, m=0, s=13, ms=120),478 get_frame(fps=25, h=0, m=0, s=16, ms=840),479 get_frame(fps=25, h=0, m=0, s=23, ms=360),480 get_frame(fps=25, h=0, m=0, s=32, ms=680),481 get_frame(fps=25, h=0, m=0, s=43, ms=800),482 get_frame(fps=25, h=0, m=0, s=49, ms=640),483 get_frame(fps=25, h=0, m=1, s=10, ms=0),484 get_frame(fps=25, h=0, m=1, s=20, ms=800),485 get_frame(fps=25, h=0, m=1, s=39, ms=680),486 get_frame(fps=25, h=0, m=2, s=23, ms=600),487 get_frame(fps=25, h=0, m=2, s=36, ms=920),488 get_frame(fps=25, h=0, m=2, s=42, ms=520),489 get_frame(fps=25, h=0, m=2, s=50, ms=160),490 get_frame(fps=25, h=0, m=2, s=58, ms=80),491 get_frame(fps=25, h=0, m=3, s=1, ms=760),492 get_frame(fps=25, h=0, m=3, s=5, ms=720),493 get_frame(fps=25, h=0, m=3, s=16, ms=400),494 get_frame(fps=25, h=0, m=3, s=23, ms=200),495 get_frame(fps=25, h=0, m=3, s=26, ms=200),496 get_frame(fps=25, h=0, m=3, s=34, ms=440),497 get_frame(fps=25, h=0, m=3, s=51, ms=600),498 get_frame(fps=25, h=0, m=3, s=55, ms=760),499 get_frame(fps=25, h=0, m=4, s=5, ms=120),500 get_frame(fps=25, h=0, m=4, s=29, ms=160),501 get_frame(fps=25, h=0, m=4, s=41, ms=520),502 get_frame(fps=25, h=0, m=5, s=4, ms=800),503 get_frame(fps=25, h=0, m=5, s=18, ms=320),504 get_frame(fps=25, h=0, m=6, s=2, ms=240),505 get_frame(fps=25, h=0, m=6, s=14, ms=960),506 get_frame(fps=25, h=0, m=6, s=58, ms=680),507 get_frame(fps=25, h=0, m=7, s=36, ms=520),508 get_frame(fps=25, h=0, m=8, s=11, ms=640),509 get_frame(fps=25, h=0, m=8, s=37, ms=280),510 get_frame(fps=25, h=0, m=8, s=57, ms=680),511 get_frame(fps=25, h=0, m=9, s=14, ms=840),512 get_frame(fps=25, h=0, m=9, s=31, ms=440),513 get_frame(fps=25, h=0, m=9, s=50, ms=960),514 get_frame(fps=25, h=0, m=10, s=34, ms=0),515 get_frame(fps=25, h=0, m=11, s=8, ms=600),516 get_frame(fps=25, h=0, m=12, s=0, ms=720),517 get_frame(fps=25, h=0, m=12, s=8, ms=280),518 get_frame(fps=25, h=0, m=12, s=50, ms=360)519 ],520 "video0028.mp4": [get_frame(fps=25, h=0, m=0, s=3, ms=360),521 get_frame(fps=25, h=0, m=0, s=35, ms=200),522 get_frame(fps=25, h=0, m=1, s=21, ms=200),523 get_frame(fps=25, h=0, m=2, s=19, ms=40),524 get_frame(fps=25, h=0, m=2, s=43, ms=640),525 get_frame(fps=25, h=0, m=2, s=53, ms=720),526 get_frame(fps=25, h=0, m=3, s=18, ms=760),527 get_frame(fps=25, h=0, m=3, s=33, ms=760),528 get_frame(fps=25, h=0, m=4, s=28, ms=560),529 get_frame(fps=25, h=0, m=4, s=47, ms=360),530 get_frame(fps=25, h=0, m=5, s=24, ms=680),531 get_frame(fps=25, h=0, m=6, s=59, ms=920),532 get_frame(fps=25, h=0, m=7, s=52, ms=720),533 get_frame(fps=25, h=0, m=9, s=26, ms=960),534 get_frame(fps=25, h=0, m=10, s=11, ms=120),535 get_frame(fps=25, h=0, m=10, s=37, ms=760),536 get_frame(fps=25, h=0, m=12, s=0, ms=720),537 get_frame(fps=25, h=0, m=12, s=58, ms=0),538 ],539 "video0029.mp4": [get_frame(fps=25, h=0, m=0, s=27, ms=600),540 get_frame(fps=25, h=0, m=1, s=8, ms=40),541 ],542 "video0030.mp4": [get_frame(fps=25, h=0, m=0, s=22, ms=40),543 get_frame(fps=25, h=0, m=0, s=40, ms=720),544 get_frame(fps=25, h=0, m=0, s=48, ms=480),545 ],546 }...

Full Screen

Full Screen

offwaketime.py

Source:offwaketime.py Github

copy

Full Screen

...76 char name[TASK_COMM_LEN];77 u64 ret[MAXWDEPTH];78};79BPF_HASH(wokeby, u32, struct wokeby_t);80static u64 get_frame(u64 *bp) {81 if (*bp) {82 // The following stack walker is x86_64 specific83 u64 ret = 0;84 if (bpf_probe_read(&ret, sizeof(ret), (void *)(*bp+8)))85 return 0;86 if (bpf_probe_read(bp, sizeof(*bp), (void *)*bp))87 *bp = 0;88 if (ret < __START_KERNEL_map)89 return 0;90 return ret;91 }92 return 0;93}94int waker(struct pt_regs *ctx, struct task_struct *p) {95 u32 pid = p->pid;96 if (!(FILTER))97 return 0;98 u64 bp = 0;99 struct wokeby_t woke = {};100 int depth = 0;101 bpf_get_current_comm(&woke.name, sizeof(woke.name));102 bp = ctx->bp;103 // unrolled loop (MAXWDEPTH):104 if (!(woke.ret[depth++] = get_frame(&bp))) goto out;105 if (!(woke.ret[depth++] = get_frame(&bp))) goto out;106 if (!(woke.ret[depth++] = get_frame(&bp))) goto out;107 if (!(woke.ret[depth++] = get_frame(&bp))) goto out;108 if (!(woke.ret[depth++] = get_frame(&bp))) goto out;109 if (!(woke.ret[depth++] = get_frame(&bp))) goto out;110 if (!(woke.ret[depth++] = get_frame(&bp))) goto out;111 if (!(woke.ret[depth++] = get_frame(&bp))) goto out;112 if (!(woke.ret[depth++] = get_frame(&bp))) goto out;113 woke.ret[depth] = get_frame(&bp);114out:115 wokeby.update(&pid, &woke);116 return 0;117}118int oncpu(struct pt_regs *ctx, struct task_struct *p) {119 u32 pid = p->pid;120 u64 ts, *tsp;121 // record previous thread sleep time122 if (FILTER) {123 ts = bpf_ktime_get_ns();124 start.update(&pid, &ts);125 }126 // calculate current thread's delta time127 pid = bpf_get_current_pid_tgid();128 tsp = start.lookup(&pid);129 if (tsp == 0)130 return 0; // missed start or filtered131 u64 delta = bpf_ktime_get_ns() - *tsp;132 start.delete(&pid);133 delta = delta / 1000;134 if (delta < MINBLOCK_US)135 return 0;136 // create map key137 u64 zero = 0, *val, bp = 0;138 int depth = 0;139 struct key_t key = {};140 struct wokeby_t *woke;141 bpf_get_current_comm(&key.target, sizeof(key.target));142 bp = ctx->bp;143 // unrolled loop (MAXTDEPTH):144 if (!(key.tret[depth++] = get_frame(&bp))) goto out;145 if (!(key.tret[depth++] = get_frame(&bp))) goto out;146 if (!(key.tret[depth++] = get_frame(&bp))) goto out;147 if (!(key.tret[depth++] = get_frame(&bp))) goto out;148 if (!(key.tret[depth++] = get_frame(&bp))) goto out;149 if (!(key.tret[depth++] = get_frame(&bp))) goto out;150 if (!(key.tret[depth++] = get_frame(&bp))) goto out;151 if (!(key.tret[depth++] = get_frame(&bp))) goto out;152 if (!(key.tret[depth++] = get_frame(&bp))) goto out;153 if (!(key.tret[depth++] = get_frame(&bp))) goto out;154 if (!(key.tret[depth++] = get_frame(&bp))) goto out;155 if (!(key.tret[depth++] = get_frame(&bp))) goto out;156 if (!(key.tret[depth++] = get_frame(&bp))) goto out;157 if (!(key.tret[depth++] = get_frame(&bp))) goto out;158 if (!(key.tret[depth++] = get_frame(&bp))) goto out;159 if (!(key.tret[depth++] = get_frame(&bp))) goto out;160 if (!(key.tret[depth++] = get_frame(&bp))) goto out;161 if (!(key.tret[depth++] = get_frame(&bp))) goto out;162 if (!(key.tret[depth++] = get_frame(&bp))) goto out;163 key.tret[depth] = get_frame(&bp);164out:165 woke = wokeby.lookup(&pid);166 if (woke) {167 __builtin_memcpy(&key.wret, woke->ret, sizeof(key.wret));168 __builtin_memcpy(&key.waker, woke->name, TASK_COMM_LEN);169 wokeby.delete(&pid);170 }171 val = counts.lookup_or_init(&key, &zero);172 (*val) += delta;173 return 0;174}175"""176if args.pid:177 filter = 'pid == %s' % args.pid...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful