enzanki-ars / rocket-league-replay-analysis

UNMAINTAINED - Creating videos for Analyzing Rocket League Replays (https://gitlab.com/enzanki_ars/rocket-league-replay-analysis)
https://gitlab.com/enzanki_ars/rocket-league-replay-analysis
GNU Affero General Public License v3.0
24 stars 2 forks source link

Migration from SVGs to FFmpeg #40

Closed enzanki-ars closed 6 years ago

enzanki-ars commented 6 years ago

User change notes

Graphics will not be using a SVG based overlay template. In other words, no more images created on the hard drive for every single frame, allowing anyone to easily:

Changes

--process_type will be completely replaced with --render and --data_explorer.

usage: rocketleaguereplayanalysis 
                                  [-h]
                                  [--render {player-data-drive,
                                             player-data-scoreboard,
                                             possession,
                                             pressure,
                                             scoreboard} 
                                       [{player-data-drive,
                                         player-data-scoreboard,
                                         possession,
                                         pressure,
                                         scoreboard} ...]]
                                  [--data_explorer] 
                                  [--export_parsed_data]
                                  [--show_field_size] 
                                  [--version]
                                  game_json

Users will also be able to configure a custom render using --custom_render_config and --custom_render_image by passing a JSON file to --custom_render_config and a FFmpeg compatible image file (basically almost anything you can think of; png, jpg, etc.) to --custom_render_image.

Initial implementation will allow for only one filter at a time per variable, but future updates will hopefully allow for more than one filter at a time per variable.

Example config

[
  {
    "varaible_path": [
      "frames",
      "frame_num",
      "time",
      "game_time"
    ],
    "adjust_value": {
      "action": "multiply",
      "modify": 2
    },
    "filter": "drawtext",
    "options": {
      "fontsize": 18,
      "fontcolor": "black",
      "x": 100,
      "y": 100,
      "text": "Default"
    },
    "reinit": {
      "text": "{0:3i}"
    }
  },
  {
    "varaible_path": [
      "frames",
      "frame_num",
      "cars",
      "player_num",
      "drift"
    ],
    "adjust_value": {
      "action": "replace",
      "modify": [
        {
          "if": true,
          "then": "Yes"
        },
        {
          "if": false,
          "then": "No"
        }
      ]
    },
    "filter": "drawtext",
    "reinit": {
      "text": "{0:3i}"
    }
  }
]

Config requirements

That block can be repeated multiple times throughout the json document, one for each piece of text you want to include. All variables are required, except adjust_value and options.

Config options

varaible_path is the same path seen when using --export_parsed_data will be used to define the filter ID. See below for more information on how that works and is defined.

adjust_value is optional, allowing for the value provided by the replay format to be adjusted. action can be either add, subtract, multiply, divide, mod, or replace. The value passed to reinit will be modified using the action and the modify value. replace acts like an if statement, replacing values with then if the frame value matches if.

filter should hopefully accept any FFmpeg filters, specifically any http://ffmpeg.org/ffmpeg-filters.html#Video-Filters.

option defaults will inherit from FFmpeg defaults for the respective filter, though OpenSans will be the default font for drawtext to ensure working drawtext and similar renders across platforms.

reinit defines what and how the value should change over time. See FFmpeg's docs for a bit of how this will work.

Example filter IDs

['frames', 'frame_num', 'time', 'game_time'] will become frames-frame_num-time-game_time wehere frame_num will be replaced with frame numbers in the path processing step.

['frames', 'frame_num', 'cars', 'player_num', 'scoreboard', 'assists'] will become frames-frame_num-cars-player_num-scoreboard-assists where player_num will be replaced with each player's number and frame_num will be replaced with frame numbers during the path processing step.