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.
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
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
file | body | file | no | Audio or video file (multipart, raw body or file_base64), up to your plan’s file limit. | |
url | body|query | string | no | Public URL of the file instead of an upload. | |
max_mb | body|query | number | no | 8 | Megabytes read from the URL (1-25). |
cover | body|query | boolean | no | false | Include 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"const form = new FormData();
form.append('file', fileInput.files[0]);
const res = await fetch('https://apibox.io.vn/v1/media-metadata', {
method: 'POST',
headers: { Authorization: 'Bearer YOUR_API_KEY' },
body: form,
});
console.log(await res.json());import requests
res = requests.post(
"https://apibox.io.vn/v1/media-metadata",
headers={"Authorization": "Bearer YOUR_API_KEY"},
files={"file": open("my-file", "rb")},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/media-metadata');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
CURLOPT_POSTFIELDS => ['file' => new CURLFile('my-file')],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));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
Image Metadata & EXIF
Read image dimensions, format, EXIF camera data, capture settings and GPS location from JPEG, PNG, WebP, HEIC, AVIF, GIF and more – upload or URL.
PDFPDF Metadata
Read PDF metadata: page count, title, author, creator, producer, dates, PDF version, encryption, form fields and the size of each page (A4, Letter…).
PDF₫Quote & Receipt PDF
Generate clean PDF quotations, receipts, orders and simple invoices from JSON, with Vietnamese text, VAT, totals in words and a VietQR code for payment.