wiki
Guides/Compressing_files查看官网原文 ↗
这篇还没汉化,先拿英文原文顶着。(有想看的页面?催更就完事了。)

Compressing files

Each beatmap has a file size limit dictated by its total length, and any video and audio content must meet format, resolution, and bit rate requirements.

This guide will help you get your beatmap under that limit and meet such requirements.

Introduction

There are 2 types of compression, lossless and lossy:

The process of converting between audio and video formats, to reduce file size, average bit rate, or resolution, is called re-encoding or transcoding. Re-encoding an already lossy-compressed audio or video using lossy compression can result in varying degrees of further quality reduction, depending on the settings used.

Due to that reason, re-encoding should be avoided, except if the original audio or video file is any of the following:

In case re-encoding is necessary, it is suggested to use the highest-quality source file available, i.e. with the highest resolution and/or bit rate.

Video

osu! supports video encoded in the H.264 format with the .mp4 file extension. Other formats, such as H.265, VP9, and AV1, and file extensions such as .mkv and .mov, are currently not supported.

The ranking criteria specify a maximum video resolution of 1280x720 pixels.

Using Handbrake

To begin, download and install Handbrake, then follow these steps:

  1. Open Handbrake, then import your video file by either: - Drag-and-dropping the file into Handbrake, or - Clicking the File option, then selecting the file to import.

Importing video files in Handbrake

  1. Select the Fast 720p30 preset.

Selecting the video preset

  1. Select the Audio tab and remove all audio tracks. Do the same for any subtitles by going into the Subtitles tab and removing all entries.

Removing audio tracks from the audio tab in Handbrake

  1. Go into the Video tab and use the following settings: - Video Encoder set to H.264 (x264) to encode in the H.264 format using the x264 encoder - Framerate (FPS) set to Same as source with Constant Framerate selected - Constant Quality set to a value between 20 to 25. Smaller value will result in larger, higher quality files
  2. Depending on how long you are willing to spend time encoding, change the Encoder Preset under Encoder Options (Veryslow is recommended). Slower presets result in better video quality and may also reduce video file size. - Do not use the Placebo preset, as it takes much longer to encode than Veryslow for very little improvement in quality or file size.

Setting the video codec and quality in Handbrake

  1. To resize the image of the video file, go to the Dimensions tab and change the width to 1280 and the height to 720.

Setting the video dimensions in Handbrake

  1. Lastly, pick the location you want to save your result to, then click Start Encode.

Encoding and saving the video

Using FFmpeg

FFmpeg is a program used through a command-line interface (CLI), meaning it does not have any graphical interface by itself. While this may seem intimidating, FFmpeg can offer more flexibility than other tools, such as when integrated into a script.

To install FFmpeg on Windows, download FFmpeg and add its directory to your PATH environment variable. On macOS, you can alternatively install it using the brew package manager. On Linux, most Linux distributions either already provide or pre-install FFmpeg by default (if not, research about the distribution you use for more information).

To use FFmpeg to re-encode a video file, open a terminal and paste in the following command, changing the values as needed:

ffmpeg -i input -c:v libx264 -crf 20 -preset veryslow -vf scale=-1:720 -an -sn -map_metadata -1 -map_chapters -1 output.mp4

Audio

Audio encoded in either MP3 or OGG (Vorbis) formats is supported with .mp3 and .ogg file extensions, respectively. Other formats are currently not supported (except for audio with the .wav file extension for hitsounds).

Generally, OGG (Vorbis) results in better quality than MP3 for a given bit rate.

The ranking criteria specifies that average bit rate must be between 192kbps and 128kbps for MP3 format, and between 208kbps and 128kbps for OGG (Vorbis) format. As a reference, Featured Artists songs included in the beatmap templates are encoded to MP3 with a constant bit rate of 192kbps.

Using Audacity

To begin, download and install Audacity, then follow these steps:

  1. Open Audacity, then import the audio file into Audacity.

Importing audio into Audacity

  1. Export the audio as either MP3 or OGG.

Export as MP3

  1. Change the export options to compress your file, depending on selected format: - For MP3, change the bit rate mode to Constant and select the quality of 192 kbps - For OGG (Vorbis), adjust the Quality slider to 6, which sets the average bit rate to 192 kbps
  2. Select the output location and click Save, and a new dialog will appear for you to enter audio metadata.

Export settings

  1. Once done entering metadata, which can be left blank if desired, click OK to start re-encoding.

Notice

Clicking Cancel in the metadata dialog will abort the re-encoding process.

Using FFmpeg

Note: For instructions on installing FFmpeg, see Video/Using FFmpeg

After installing FFmpeg, open a terminal, then use one of the below commands.

To encode in the MP3 format, paste the following command into your terminal and change these values as needed:

ffmpeg -i input -c:a libmp3lame -b:a 192k -vn -sn -map_metadata -1 -map_chapters -1 output.mp3

To encode in the OGG (Vorbis) format, paste the following command into your terminal and change these values as needed:

ffmpeg -i input -c:a libvorbis -q:a 6 -vn -sn -map_metadata -1 -map_chapters -1 output.ogg

Verification

It is recommended to check the technical information of re-encoded audio and video files to confirm that they meet your expectations.

Using MediaInfo

MediaInfo is very easy to use. After installing, open the file with MediaInfo and the technical information about that file will appear.

  1. Right-click any file and select MediaInfo from the context menu, or use File -> Open -> Open file(s)... in MediaInfo.
  2. Change the view from Basic to either Tree, Text, or HTML. The default Basic view only displays a condensed series of information.

Relevant fields for video files:

Relevant fields for audio files:

If everything seems correct and the file size is small enough, then you can put either re-encoded audio or video file into your beatmap.