Documentation

Guides and API reference for uploads, image transforms and video.

npm install @cd2/fileboy-react
API https://api.fileboy.io

Audio

Upload podcasts, voice notes, music and lessons as audio files. Fileboy encodes them for streaming, measures a waveform and plays them in a compact audio player, with the same privacy, captions, chapters and analytics as video.

How audio works

An audio file is a video asset with kind: "audio". It has the same id, routes and dashboard page as a video, so everything that doesn't need a picture works the same: uploads and resumable uploads, privacy, passwords and expiring links, signed playback, embeds, captions and chapters, auto-generated captions, playlists, analytics, webhooks and replacing the source.

When it is processed, Fileboy encodes it to AAC twice, at 64 kbps and 128 kbps, and streams both as HLS and DASH so players pick the one the connection can carry. The 128 kbps one is also its M4A download (/videos/{id}/audio.m4a), and the original is kept for download as for a video. More than two channels are mixed down to stereo, and sample rates over 48 kHz are brought down to 48 kHz. Loudness is not normalised: it plays at the level it was recorded.

Its poster is the artwork embedded in the file (an MP3 or M4A cover) when it has one (fitted into 1280×1280; a cover over the video picture limits is left out), or else a drawing of its waveform, so lists, share pages and link previews have a picture. You can upload your own cover on its Share tab in the dashboard (audio files have no Edit or Appearance tab, so the cover, the player branding and Replace are on Share and Files & API), or with POST /videos/{id}/poster/upload.

Audio files have their own allowance on your plan, separate from videos, so they never use up the video one: Free 15, Starter 100, Pro 1000, Max 5000. Their files count towards storage like any other. GET /usage reports them as audio, next to limits.audio. See pricing.

Upload an audio file

Upload it as you would a video: the dashboard's Videos page takes audio files (drop them in with your videos), and POST /videos/upload and upload sessions of kind video take any audio/* type: mp3, m4a and aac, wav, flac, ogg and opus, webm audio and so on. The answer has kind: "audio".

Audio files are listed with your videos, marked Audio. To see only them, pick Audio in the Videos page's kind filter, beside its status filter (queued or processing, failed, or ready).

Upload an MP3
1
curl https://api.fileboy.io/videos/upload -H "Authorization: public YOUR_PUBLIC_KEY" -F "file=@episode-12.mp3;type=audio/mpeg" -F 'data={"name": "Episode 12"}'
Response
1
2
3
4
5
6
7
8
9
{
  "id": "AUDIO_ID",
  "name": "Episode 12",
  "description": "",
  "tags": [],
  "metadata": {},
  "rawFileId": "FILE_ID",
  "kind": "audio"
}

The kind is set again from what the file holds once Fileboy reads it: a file with sound and no picture is audio, whatever its type said (a voice memo saved as video/webm is audio), and cover art doesn't make it a video. A file with neither sound nor picture fails with "The video has no video or audio track."

The same limits apply as to video: files that are really playlists are refused, processing has a time limit for the file's length, and audio can be up to 4 hours long. A recording with no length in its headers (as a browser's MediaRecorder makes) is measured as it is processed, and gets the same limit.

Play it

The Fileboy player (1.10.0 and later) switches to its audio layout by itself for an audio file: the cover at the side, the title, the waveform as the seek bar (click or drag it, or use the arrow keys), play, volume, time, speed, captions as a line of text, and the transcript panel below the player. There is no video area, full screen or picture in picture. The watch page, embeds and playlists all use it.

Embed the player
1
2
3
4
<script type="module" src="https://cdn.jsdelivr.net/npm/@cd2/fileboy-player@1.20/dist/fileboy-player.js"></script>

<!-- kind="audio" is optional: it starts in the audio layout before the data loads -->
<fileboy-player video-id="AUDIO_ID" kind="audio"></fileboy-player>

With another player, play urls.hls as you would a video's: an audio file's HLS playlist lists its two AAC renditions as audio-only streams.

What audio files don't have

These work on the picture, so an audio file doesn't have them: trimming, cutting, clips, filler removal, blurring, stitching, seek-preview thumbnails, poster suggestions, the animated preview and MP4 downloads. Their routes answer 409 not_supported_for_audio, and the dashboard leaves them out of an audio file's page. Its thumbnails and extras show as skipped.

In the API and SDKs

Videos in the management API and /videos/{id}/data have kind (video or audio) and waveform (null for a video; for audio its status and, once ready, its url). GET /videos?kind=audio lists only audio files. Webhooks for uploads and processing carry kind, and video.ready has urls.waveform when a waveform was made.

SDKs
1
2
3
4
5
6
7
8
// Node (Ruby, Python and PHP have the same in their own style)
const { data: episodes } = await fileboy.listVideos({ kind: "audio" })
const episode = episodes[0]
episode.kind // "audio"
episode.waveform // { status: "ready", url: "https://api.fileboy.io/videos/.../waveform.json" }

// The waveform's URL, to draw it yourself (sign it for an app that requires signed reads)
const url = fileboy.buildVideoWaveformUrl(episode.id, { version: episode.version })

Get the waveform

An audio file's peaks, to draw its waveform: the BBC audiowaveform JSON format (version 2, one channel, 8 bit), about 1,800 points, data holding a min and a max (-128 to 127) for each. Point i starts at i × samples_per_pixel / sample_rate seconds. Follows the video's read access like the poster: in an app that requires signed reads, sign the URL or add signVideo's query (waveform.url in the video's data carries it on). 404 waveform_not_found for a video, or while the audio is processing.

GET
1
https://api.fileboy.io/videos/{id}/waveform.json

URL Params

id string

The audio file's id (a video id).

Example

REQUEST
1
curl https://api.fileboy.io/videos/AUDIO_ID/waveform.json
RESPONSE
1
2
3
4
5
6
7
8
9
{
  "version": 2,
  "channels": 1,
  "sample_rate": 8000,
  "samples_per_pixel": 18,
  "bits": 8,
  "length": 1778,
  "data": [-3, 4, -41, 39, -88, 90, ...]
}

Related guides