Files
hand-motion-pipeline/scripts/verify_dex_video.py
T

19 lines
998 B
Python

"""Decode and verify the complete exported LEAP replay."""
import json
import subprocess
from pathlib import Path
root = Path(__file__).resolve().parents[1] / 'output/dex_2047635068'
video = root / 'leap_right_replay.mp4'
result = subprocess.run(['ffprobe', '-v', 'error', '-select_streams', 'v:0',
'-count_frames', '-show_entries',
'stream=width,height,avg_frame_rate,nb_read_frames',
'-of', 'json', str(video)], check=True, capture_output=True, text=True)
stream = json.loads(result.stdout)['streams'][0]
assert int(stream['nb_read_frames']) == 1333
assert stream['avg_frame_rate'] == '30/1'
assert (stream['width'], stream['height']) == (1280, 480)
subprocess.run(['ffmpeg', '-v', 'error', '-xerror', '-i', str(video), '-f', 'null', '-'], check=True)
(root / 'video_validation.json').write_text(json.dumps(dict(stream=stream, full_decode_pass=True), indent=2))
print('PASS: 1333 frames, 30 fps, 1280x480, full decode')