Coder Social home page Coder Social logo

nelsonjchen / op-replay-clipper Goto Github PK

View Code? Open in Web Editor NEW
78.0 6.0 12.0 334 KB

๐Ÿ“ฝ Capture and develop clips of openpilot. UI optional. Already deployed on Replicate.com for YOUR immediate use!

Home Page: https://replicate.com/nelsonjchen/op-replay-clipper

License: MIT License

Dockerfile 1.25% Shell 36.60% Makefile 3.01% Python 59.15%
openpilot github-codespaces replicate

op-replay-clipper's Introduction

๐Ÿ“ฝ openpilot Replay Clipper

Here's a small openpilot bug clip:

replicate-prediction-3iy65fzbw3bygdqvuid3duganu.mp4

Capture and develop clips of openpilot from comma.ai's Comma Connect.

The clipper can produce clips of:

  • comma.ai openpilot UI (including desired path, lane lines, modes, etc.)
  • Forward, Wide, and Driver Camera with no UI
    • Concatenate, cut, and convert the raw, low-compatibility, and separated HEVC files to one highly compatible H.264 MP4 for easy sharing.
  • 360 Video
    • Rendered from Wide and Driver Camera. Uploadable to YouTube, viewable in VLC, and accepted by any video players or web services that take 360 videos.
  • Forward Upon Wide and 360 Forward Upon Wide
    • Forward video is overlayed atop the wide video. Not perfect, but usable.

All clip options have a configurable target file size option as platforms like Discord limit file upload sizes.

The clipper is deployed on Replicate:

https://replicate.com/nelsonjchen/op-replay-clipper

Replicate is an ultra-low-cost pay-as-you-go compute platform for running software jobs. Replicate is a great way to run this clipper as it's fast, easy to use, and you don't need to install anything on your computer or even deploy anything yourself. Just enter in the required information into the form, and Replicate will generate a clip. Expect to pay about ~$0.01 per clip but not even need to put in any payment details until you've reached a generously large level of usage.

Terminology

  • Route - A drive recorded by openpilot. Generally from Ignition On to Ignition Off.

Requirements

Non-Requirements

  • A comma lite or prime subscription.
    • Clipping was a comma connect prime-only feature but was removed for refurbishment. This is a free and open source tool to do the same.

Quick Usage

We assume you've already paired your device and have access to the device with your comma connect account.

  1. Visit comma connect and select a route.
  2. Scrub to the time you want to clip.
    • In this example, I've scrubbed to a time where I want to make a small clip of behind this cool car.
    • image
  3. Now I need to select the portion of the route I want to clip. Here's a video of what that UI looks like
    • See how I drag and select a portion.

    • You can see me make a mistake but pressing the left arrow (โ†) in the top-left corner lets me re-expand and try to trim again.

    • The clipper has a maximum length of 5 minutes. Try to select a portion that's less than that. Try to aim for 20 seconds to a minute though as everybody else has short attention spans.

    • Video:

      scrubdown.mp4
  4. Once satisified with the selected portion, prepare the route and files for rendering.
    • Make sure all files are uploaded. Select "Upload All" under the "Files" dropdown if you haven't already and make sure it says uploaded. You may need to wait and your device may need to be on for a while for all files to upload.
      • The clipper only works with high-resolution files and needs all files that are part of the clip to be uploaded.
      • image
    • Make sure the route has "Public access" under "More info" turned on. You can set this to off after you're done with clip making.
      • image
  5. Copy the URL in the address bar of your browser to your clipboard. This is not the segment ID underneath the More Info button. In the case above, I've copied an old URL of "https://connect.comma.ai/fe18f736cb0d7813/1698203405863/1698203460702" to my clipboard. Note: comma has changed the URL format since this step was originally written. New URLs are like "https://connect.comma.ai/fe18f736cb0d7813/000001bb--4c0c0efba9/21/90".
    • When you were adjusting the selected portion of the route in a previous step, it was changing those last two numbers in the browser address bar URL which is the start time and end time respectively.
    • "Share This Route" button if it is present will work too. Choose "copy to clipboard" or similar.
  6. Visit https://replicate.com/nelsonjchen/op-replay-clipper
  7. Under route, paste the URL you copied in the previous step.
    • image
  8. Tweak any settings you like.
  9. Press Run.
  10. Wait for the clip to render. It may take a few minutes.
  11. Once done, you can download the clip. If you want, turn off "Public access" on the route after you're done.
    • Here's a generated clip with the wide rendering type with no UI:

      cog-clip.1.mp4

Gallery

Demonstration of speed or longitudinal behavior of openpilot with model-based longitudinal is nearly impossible or hard without this clipper. This video is of a good model based long behavior at highway speeds.

ae_driving_highway.mp4

Cars can have bugs themselves. Here's my 2020 Corolla Hatchback phantomly braking on metal strips in stop and go traffic probably from the radar. Perhaps a future openpilot that doesn't depend on radar might be the one sanity checking the radar instead of the other way around currently. And another example of that in Portland.

phantom-radar-braking.mp4
funky-ramp-redux.mp4

This is a video of a bug report where openpilot's lateral handling lost the lane.

lost-line.mp4

Lane cutting?

cutty-uphills.mp4

Nav-assisted follow the road instead of taking the side road.

2023-06-27--15-58-05--14_nav_stays_left_woooo.mp4

Copying the car in front to get around someone waiting for the left turn

interesting-assisted-right-pass.mp4

Limitations

Usage Tips

  • Learn how to bookmark and flag interesting points on a drive/route.

    With the car on, soon after an incident when it is safe:

    1. Tap the screen to reveal a bookmark flag button if it isn't there already.
      • button_flag
    2. Tap that icon.
    3. This will result in small slivers of yellow in the timeline you can quickly hone in on.
      • flagged
    4. With regards to the clipper usage, during the process in which you are honing in on the start and of the clip, your upper bound of the clip will nearly all the time be at that yellow so your first or early drags to hone down should basically top out there and be very generous with the start time before the yellow.

Advanced Usage

JWT Token Input

There is a JWT Token input field. This is for users who do not wish to set a route to be "Public access". There is a major catch though. The JWT Token is valid for 1 year and is irrevocable in any way. Password changes from SSO account logins like in Comma Connect will not invalidate the token. Addtionally, it is not granular, meaning it will give access to all routes for the user if leaked.

If you share a JWT Token with anyone, they will be able to access all your routes for 1 year with no possibility of revocation from you. This is why it's not recommended to use this feature unless you know what you're doing compared to the "Public access" method which is much easier to revoke access to.

Tokens can be obtained from visiting https://jwt.comma.ai/ and logging in with the same comma connect account type. Tokens should be about 181 characters or longer.

Replicate can queue up jobs to run in parallel

After you run something, just use your browser to "Duplicate" the tab, change the settings for the next thing, and press Run. Replicate will queue up jobs and if necessary, even scale up to run multiple jobs in parallel. Very cool!

Credits

UI

The real MVP is @deanlee for the replay tool in the openpilot project. The level of effort to develop the replay tool is far beyond this script. The script is just a wrapper around the replay tool to make it easy to use for clipping videos.

https://github.com/commaai/openpilot/blame/master/tools/replay/main.cc

Video-only

A lot of the FFmpeg commands is based off of @ntegan1's research and documentation including a small disclosure of some but not all details by @incognitojam when @incognitojam was at comma.

https://discord.com/channels/469524606043160576/819046761287909446/1068406169317675078

@morrislee provided original data suitable to try to reverse engineer 360 clips.

op-replay-clipper's People

Contributors

blue-genie avatar iamz avatar nelsonjchen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

op-replay-clipper's Issues

Audio

Not much of a loss on openpilot. Massive loss if frogpilot UI gets inplemented.

Periodically build openpilot ARM images

This should be possible.

At a daily interval, clone the OP repo down, build images targeting ARM, then build the prebuilt clipper images.

PITA, but oh well.

Better 360 Videos

It does not appear op-replay-clipper's 360 video matches up with what comma prime 360 had in the past.

  • The A pillars for example do not match up straight.
  • There is a seam on the forward video that's noticeable in VLC, a bit on YouTube, and on some app.

Setup Cog CI/CD

  • Have to handle customized version of cog to allow more environment variables.

Go Live no longer works

When trying to start the web server by clicking on Go Live in the bottom right corner, the following is displayed when it tries to load the page showing the directory of the live server.

image

Have configurable Bitrate and/or values

  • Discord Free 8MB (Default for < 2 minutes)
  • Discord Nitro Classic 50MB (Default for 2 to 10 minutes)
  • Discord Nitro 500MB (Default for etc.)
  • Skip (Leave it uncompressed for self-conversion)

Better handle and do trial customer limits for DigitalOcean by default with `--slow-cpu` and 4 vCPUs by default for DigitalOcean

  • New DigitalOcean customers are limited to 4 vCPUs
  • They will get assigned dirty/tainted IP addresses
  • The web server stuff may be confusing and can be accidentally quit. Maybe make it start in the background persistently instead of foreground on demand with DO-specific instructions.

Many thanks to DrWumbo#4031 for walking through their different POV as a DigitalOcean trial customer.

Display e2e_long drives accurately somehow

They should either detect it's e2e_long and render in e2e_long mode or maybe we just add an option to render it in e2e_long mode.

Right now, e2e_long drives are rendered with a green path whereas they should be gold.

Create instructions to run on DigitalOcean VPS

Notes:

  • Direct users here to choose the right "app" https://marketplace.digitalocean.com/apps/docker
  • Make sure users create with 8 vCPU Droplet as 4 vCPU droplet is the default.
  • List pricing of ~0.17/hr.
  • Run git clone https://github.com/nelsonjchen/op-replay-clipper
  • Need to set shared folder to 777 after cloning
  • Run command to generate clip. e.g docker-compose run --rm clipper /workspace/clip.sh "255403b2bd0acb75|2022-10-08--18-25-16" -s 2160 -l 60 (no jwt)
  • Run icanhazip.com to get the ip address
  • docker run -it --rm -p 8080:80 -v $(pwd)/shared:/public danjellz/http-server
  • Download Clip with web browser to ip address .
  • Destroy Droplet or money gets burned.

Produce a replicate.com deployment of the clipper

  • Has GPU so it'll be fast
  • Can keep warm so multiple jobs still fine.
  • Cheap, relatively.
  • Can turn OP Replay into an API; Maybe good for a connect fork to have rendering
  • Maybe to make it easy to specify a start/stop, take in a connect URL.
  • Secure as nothing is saved.

Concerns:

  • Definitely might need some bind/symlink magic to make sure users cannot see other user's data if JWTs are involved.
  • Might need to be able to build OP from scratch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.