clip: add speed up support (#35933)

pull/35934/head
Adeeb Shihadeh 3 days ago committed by GitHub
parent 8c7d53004f
commit 978d1c38f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      .gitignore
  2. 11
      tools/clip/run.py

1
.gitignore vendored

@ -16,6 +16,7 @@ a.out
/docs_site/
*.mp4
*.dylib
*.DSYM
*.d

@ -29,7 +29,7 @@ FRAMERATE = 20
PIXEL_DEPTH = '24'
RESOLUTION = '2160x1080'
SECONDS_TO_WARM = 2
PROC_WAIT_SECONDS = 30
PROC_WAIT_SECONDS = 30*10
OPENPILOT_FONT = str(Path(BASEDIR, 'selfdrive/assets/fonts/Inter-Regular.ttf').resolve())
REPLAY = str(Path(BASEDIR, 'tools/replay/replay').resolve())
@ -188,6 +188,7 @@ def clip(
out: str,
start: int,
end: int,
speed: int,
target_mb: int,
title: str | None,
):
@ -212,6 +213,12 @@ def clip(
if title:
overlays.append(f"drawtext=text='{escape_ffmpeg_text(title)}':fontfile={OPENPILOT_FONT}:fontcolor=white:fontsize=32:{box_style}:x=(w-text_w)/2:y=53")
if speed > 1:
overlays += [
f"setpts=PTS/{speed}",
"fps=60",
]
ffmpeg_cmd = [
'ffmpeg', '-y',
'-video_size', RESOLUTION,
@ -289,6 +296,7 @@ def main():
p.add_argument('-o', '--output', help='output clip to (.mp4)', type=validate_output_file, default=DEFAULT_OUTPUT)
p.add_argument('-p', '--prefix', help='openpilot prefix', default=f'clip_{randint(100, 99999)}')
p.add_argument('-q', '--quality', help='quality of camera (low = qcam, high = hevc)', choices=['low', 'high'], default='high')
p.add_argument('-x', '--speed', help='record the clip at this speed multiple', type=int, default=1)
p.add_argument('-s', '--start', help='start clipping at <start> seconds', type=int)
p.add_argument('-t', '--title', help='overlay this title on the video (e.g. "Chill driving across the Golden Gate Bridge")', type=validate_title)
args = parse_args(p)
@ -302,6 +310,7 @@ def main():
out=args.output,
start=args.start,
end=args.end,
speed=args.speed,
target_mb=args.file_size,
title=args.title,
)

Loading…
Cancel
Save