Audio & Video Metadata API

Read duration, bitrate, codecs, resolution, fps, sample rate, channels, tags and cover art of MP3, M4A, FLAC, OGG, WAV, MP4, MOV, WebM and MKV files.

GETPOSThttps://apibox.io.vn/v1/media-metadata

Upload the file as multipart file (or raw body / file_base64), or give a public url: only the first max_mb MB (default 8, max 25) are downloaded, which is enough for most files. Formats: MP3 (ID3v1 / v2), AAC (ADTS), M4A / MP4 / MOV (ISO BMFF), FLAC, Ogg Vorbis / Opus, WAV, AIFF, WebM / MKV (Matroska), WMA / ASF and more, parsed with the music-metadata library.

The response has the container, main codec, duration (seconds and duration_hms), bitrate, sample_rate, channels, bits_per_sample, lossless, and for video the width, height, fps and video_codec (H.264, H.265 / HEVC, VP9, AV1…). tracks lists every audio / video / subtitle track; tags holds title, artist, album, year, genre, track number, comment and encoder.

cover describes embedded cover art; with cover=true it includes a JPEG thumbnail (max 300 px) as a data URL. When a URL is read only partly, duration and bitrate may be estimates and MP4 files with their index at the end may lack details (the response says so).

Parameters

NameInTypeRequiredDefault
filebodyfilenoAudio or video file (multipart, raw body or file_base64), up to your plan’s file limit.
urlbody|querystringnoPublic URL of the file instead of an upload.
max_mbbody|querynumberno8Megabytes read from the URL (1-25).
coverbody|querybooleannofalseInclude a JPEG thumbnail of the embedded cover art.

Example

curl -X POST "https://apibox.io.vn/v1/media-metadata" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@./my-file"

Response

{
  "file": {
    "name": "bai-giang.mp4",
    "bytes": 31997,
    "kind": "file"
  },
  "container": "isom/iso2/avc1/mp41",
  "codec": "MPEG-4/AAC",
  "codec_profile": null,
  "duration": 2.023,
  "duration_hms": "00:02.023",
  "bitrate": 127988,
  "overall_bitrate": 127988,
  "sample_rate": 44100,
  "channels": 1,
  "bits_per_sample": 16,
  "lossless": false,
  "has_audio": true,
  "has_video": true,
  "width": 320,
  "height": 240,
  "fps": 25,
  "video_codec": "H.264 / AVC",
  "tracks": [
    {
      "id": 1,
      "type": "video",
      "codec": "H.264 / AVC",
      "codec_id": "avc1",
      "language": null,
      "duration": 2,
      "bitrate": 45020,
      "width": 320,
      "height": 240,
      "display_width": 320,
      "display_height": 240,
      "fps": 25,
      "interlaced": null
    },
    {
      "id": 2,
      "type": "audio",
      "codec": "MPEG-4/AAC",
      "codec_id": "mp4a",
      "language": null,
      "duration": 2.023,
      "bitrate": 69699,
      "sample_rate": 44100,
      "channels": 1,
      "bit_depth": 16
    }
  ],
  "tags": {
    "title": "MP4 test",
    "encodedby": "Lavf62.3.100"
  },
  "tag_types": [
    "iTunes"
  ],
  "cover": null
}

Use cases

  • Validate uploaded lecture videos (resolution, duration) in an LMS
  • Fill podcast or music catalogue fields from ID3 / Vorbis tags
  • Check codec and resolution before sending a video to transcoding
  • Extract cover art thumbnails for an audio library

FAQ

Is the whole file downloaded for a URL?

No. Only the first max_mb megabytes (default 8) are read. That covers the headers of almost all audio files and MP4 files with the index at the start (fast start).

Does it read video resolution and frame rate?

Yes for MP4, MOV, M4V, WebM and MKV: width, height, fps and the video codec of each video track.

Are the files stored?

No. Files are processed in memory for the request and discarded.

Related APIs

Start with 1,000 free requests every month. Get free API key →