nahkd123 / osu-replay-viewer

View replays without actually launching the game
MIT License
11 stars 2 forks source link
osu recorder replay video

【Deprecation notice】

It has been more than a year since the last commit (other than update to this README). I can't allocate time to maintain this project, hence the inclusion of this deprecation notice. However, it is more than just not being able to have time for this.

Implementation is janky

The current implementation involves IPC with ffmpeg, which impacts the performance during rendering. Although I am streaming raw image data from game process to ffmpeg over stdin, it can be done better by doing all encoding directly from game framebuffer to ffmpeg using C# binding.

My wish is being able to make animation using o!f, then render the animation as video frames and include them in container like MP4 or MKV, without resorting to IPC. My theory is that, if I make a new renderer that's basically OpenGL but for offline rendering, I can send the framebuffer to ffmpeg directly. If you want to implement this then you also want to change the clock to manually control as well, because the current clock uses the system time on o!f by default.

Speed adjustment mods will not works

Double time, Half time and other speed adjustment mods will not works.


osu! Replay Viewer

Based on osu!lazer

This replay viewer allow you to view imported replays (yes you have to import them in osu!lazer client) without launching the actual game, and you can also render replays to video files, thanks to FFmpeg.

This project aims to make replay viewer without modifying the official game code or write entire thing from scratch, but uses components from the game instead. Because of this, it's much more easy to upgrade to make UI matches with actual game

This project somewhat implemented this idea (except we're running outside the official client)

Features

Basic Usage

# List all downloaded replays
# Look for replay GUID (something like f1bb0aa3-5111-4534-b93d-e1e20074f7fe) and pass it to
# --view local <GUID>
osu-replay-viewer --list

# View replay
osu-replay-viewer --view local f1bb0aa3-5111-4534-b93d-e1e20074f7fe

# List all available skins
osu-replay-viewer --list-skin

# View replay with given skin
osu-replay-viewer --skin select "osu!classic" --view local f1bb0aa3-5111-4534-b93d-e1e20074f7fe

Requirements

This replay viewer is not guranteed to works on platforms other than Windows, but at least it's managed to works on Linux previously. If you have any problem related to Linux platform, please create a new issue.

Installing FFmpeg

  1. Grab FFmpeg binaries here

    Linux users can also install FFmpeg from package manager included in their distribution

    Windows users can download FFmpeg here or here

  2. Include ffmpeg in command line path

  3. Confirm that it's working by running ffmpeg alone

For the best encoding speed, you can install FFmpeg with hardware acceleration. To actually use hardware acceleration, see hardware acceleration

Command Line arguments

You can view all command line arguments by running the executable without arguments

Output of osu-replay-viewer --help:

Usage:
  dotnet run osu-replay-renderer [options...]
  osu-replay-renderer [options...]

  --yes
    Always Yes
    Always answer yes to all prompts. Similar to 'command | yes'

  --mod-override           <<Mod Name/acronyms:AC>>
    Alternatives: -MOD
    Mod Override
    Override Mod(s). You can use 'no-mod' or 'acronyms:NM' to clear all mods

  --query                  <Keyword>
    Alternatives: -q
    Query
    Query data (Eg: find something in help index or query replays)

  --list
    Alternatives: -list, -l
    List Replays
    List all local replays

  --view                   <Type (local/online/file/auto)> <Score GUID/Beatmap ID (auto)/File.osr>
    Alternatives: -view, -i
    View Replay
    Select a replay to view. This options must be always present (excluding -list options)

  --help
    Alternatives: -h
    Help Index
    View help with details

  --headless
    Alternatives: -H
    Headless Mode
    Switch to headless mode (not rendering anything to screen)

  --headless-loopback      <Input Device ID> <Output Device ID> <Output File (.wav)>
    Alternatives: -HL
    Headless Audio Loopback
    Record audio produced by headless host through loopback device

  --record
    Alternatives: -R
    Record Mode
    Switch to record mode

  --record-output          <Output = osu-replay.mp4>
    Alternatives: -O
    Record Output
    Set record output

  --record-audio           <Output = <--record-output>.wav>
    Alternatives: --record-audio-output, -AO
    Record Audio Output
    Set record audio output (the file is always in RIFF Wave format)

  --record-resolution      <Width = 1280> <Height = 600>
    Alternatives: -RSL
    Record Resolution
    Set the output resolution

  --record-fps             <FPS = 60>
    Alternatives: -FPS
    Record FPS
    Set the output FPS

  --jpeg
    Alternatives: -JPG
    Jpeg Output Mode
    Send Jpeg data to FFmpeg process instead of raw pixels

  --ffmpeg-preset          <Preset = slow>
    Alternatives: -FPR
    FFmpeg H264 Encoding Preset
    Set the FFmpeg H264 Encoding preset

  --ffmpeg-frames-blending <Blending = 1>
    Alternatives: -FBL
    FFmpeg Frames Blending
    Blend multiple frames to create smooth transition. Default is 1x

  --ffmpeg-minterpolation
    Alternatives: -FMI
    FFmpeg Motion Interpolation
    Use motion interpolation to create smooth transition

  --ffmpeg-encoder         <Encoder = libx264>
    Alternatives: -FENC
    FFmpeg Video Encoder
    Set video encoder for FFmpeg. 'ffmpeg -encoders' for the list

  --ffmpeg-bitrate         <Bitrate = 100M>
    Alternatives: -FQ
    FFmpeg Global Quality
    Set the max bitrate for output video

  --experimental           <Flag>
    Alternatives: -experimental
    Experimental Toggle
    Toggle experimental feature

  --overlay-override       <true/false>
    Alternatives: -overlay
    Override Overlay Options
    Control the visiblity of player overlay

  --skin                   <Type (import/select)> <Skin name/File.osk>
    Alternatives: -skin, -s
    Select Skin
    Select a skin to use in replay

  --list-skin
    Alternatives: --list-skins, -lskins, -lskin
    List Skins
    List all available skins

Build

To build this project, you need:

Clone this repository (git clone), then build it with dotnet build command.

You can also build and run directly, using dotnet run osu-replay-viewer

Troubleshooting

"No corresponding beatmap for the score could be found"

You need to import the beatmap to your current osu!lazer installation (works best with ranked maps).

Tips

Hardware Acceleration

To use hardware acceleration, you need:

Simply add --ffmpeg-encoder h264_<qsv/amf/nvenc> or --ffmpeg-encoder hevc<qsv/amf/nvenc> to enable hardware encoding. (Eg: osu-replay-renderer --view local 1337 --record --ffmpeg-encoder h264_qsv)

Here is the table for hardware encoders: Vendor Encoder Codec Note
any libx264 H.264 Uses CPU
Intel h264_qsv H.264
AMD h264_amf H.264
NVIDIA h264_nvenc H.264
any libx265 HEVC Uses CPU
Intel hevc_qsv HEVC
AMD hevc_amf HEVC
NVIDIA hevc_nvenc HEVC

Planned

This is the list of stuffs that I want to changes. It can be planned features or just revamp the code.

While Live PP Graph is currently possible, it would be nice if someone exposes them as bindables.