Media
Query codec, resolution, duration, bitrate, streams, and tags of video and audio files with ffprobe
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/media/index.md to help me query Media with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
See what you can query
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT media.main.media_format('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS format,
media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS seconds,
media.main.stream_count('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS streams
| format | seconds | streams |
|---|---|---|
| mov,mp4,m4a,3gp,3g2,mj2 | 1 | 1 |
Quick start
Choose where to run Media, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach the release directly
Downloads the latest release for your platform and caches it locally.
ATTACH 'media' AS media (
TYPE vgi,
LOCATION 'github-auto://Query-farm/vgi-media'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'media' AS media (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-media:0.5.0'
);
3. Run a query
SELECT media.main.media_format('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS format,
media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS seconds,
media.main.stream_count('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS streams
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'media' AS media
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT media.main.media_format('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS format,
media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS seconds,
media.main.stream_count('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS streams
Query Farm operates Media for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use media as the catalog alias for the query below.
4. Run a query
SELECT media.main.media_format('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS format,
media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS seconds,
media.main.stream_count('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS streams
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach the release directly
Uses the verified release each time you attach the connector.
ATTACH 'media' AS media (
TYPE vgi,
LOCATION 'github-auto://Query-farm/[email protected]'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'media' AS media (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-media:0.5.0'
);
Overview
Extract video/audio/container metadata from media files via ffprobe.

Inspect video, audio, and container files directly from DuckDB SQL: read codec, resolution, duration, bitrate, frame rate, and embedded metadata tags from MP4, MKV, MOV, WAV, MP3, WebM, and every other format that FFmpeg can open — no manual transcoding, no external scripts.
This extension is for data engineers, media pipelines, and anyone who needs to take inventory of a media library, triage transcoding jobs, or run quality and conformance checks at scale. Instead of shelling out to a command-line tool and parsing JSON by hand, you query your media the same way you query any other table, and join the results against the rest of your warehouse.
How it works
Under the hood the worker runs ffprobe, the media analyzer that ships with the FFmpeg project, in a sandboxed subprocess with bounded probe size and timeouts so that truncated or untrusted bytes can never hang a query. Every function accepts either a filesystem path (VARCHAR) or the raw media bytes (BLOB), so you can probe files on disk or BLOB columns already loaded into DuckDB. ffprobe's findings are surfaced over Apache Arrow as native SQL columns; missing or unparseable fields return NULL rather than erroring.
What you can read
The worker groups its surface into a few kinds of reading:
- Container-level facts — one value per file, such as the format name, playback duration, overall bit rate, byte size, and how many elementary streams the file holds.
- Video attributes — for the first video track: its codec, pixel width and height, a combined resolution string, and the average frame rate.
- Audio attributes — for the first audio track, such as its codec.
- Full enumeration — table functions that return one row per elementary stream, and one row per format-level metadata tag, when you need every detail rather than a single summary value.
When to use it
Reach for this worker whenever media files are part of your data and you want their technical metadata available in SQL: cataloguing an asset library, validating that uploads meet a resolution or codec policy, or driving transcoding decisions from a query rather than a bespoke script.
See the official ffprobe documentation and the broader FFmpeg documentation for details on the underlying analyzer.
Catalog
Everything media exposes once attached — read straight from the worker's
released build.
main 1 view · 13 functions
Media metadata extraction functions (scalars + table functions) over ffprobe.
Schema examples (7)
Summarize a media file in one row: container format, duration in seconds, and elementary-stream count.
SELECT media.main.media_format('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS format,
media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS seconds,
media.main.stream_count('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS streams;
| format | seconds | streams |
|---|---|---|
| mov,mp4,m4a,3gp,3g2,mj2 | 1 | 1 |
Read the first video stream's codec, resolution, and frame rate.
SELECT media.main.video_codec('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS codec,
media.main.resolution('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS resolution,
media.main.fps('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS fps;
List every elementary stream in a media file, one row per stream, ordered by stream index.
SELECT idx, type, codec
FROM media.main.media_streams('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4')
ORDER BY idx;
List the container-level metadata tags of a media file as key/value rows, ordered by tag name.
SELECT key, value
FROM media.main.media_tags('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4')
ORDER BY key;
3 more examples
Inventory a list of media files (here the two sample URLs; a local folder works the same through glob()): for each file, its container format, whether it is video or audio-only (from video_codec / audio_codec), the codec, the video resolution (NULL for audio-only), and the duration.
SELECT parse_filename(file) AS file_name,
media.main.media_format(file) AS format,
CASE WHEN media.main.video_codec(file) IS NOT NULL THEN 'video' WHEN media.main.audio_codec(file) IS NOT NULL THEN 'audio-only' ELSE 'unknown' END AS kind,
coalesce(media.main.video_codec(file), media.main.audio_codec(file)) AS codec,
media.main.resolution(file) AS resolution,
round(media.main.duration(file), 2) AS seconds
FROM (VALUES ('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4'), ('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/silent.wav')) AS f(file)
ORDER BY file_name;
One-row file card: container format and duration, the stream layout aggregated from media_streams (e.g. 'video:h264'), and the MP4 major_brand container tag from media_tags.
SELECT media.main.media_format('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS format,
round(media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4'), 2) AS seconds,
(SELECT string_agg(s.type || ':' || s.codec, ', ' ORDER BY s.idx) FROM media.main.media_streams('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS s) AS stream_layout,
(SELECT t.value FROM media.main.media_tags('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS t WHERE t.key = 'major_brand') AS major_brand;
Compare every stream's duration with the container's duration and show the drift in seconds (media_streams + duration); a non-zero drift flags a track that ends early or late, as in a truncated or badly remuxed file.
SELECT s.idx, s.type, s.codec, s.duration AS stream_seconds,
media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS container_seconds,
round(abs(s.duration - media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4')), 3) AS drift_seconds
FROM media.main.media_streams('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS s
ORDER BY s.idx;
media_functions
Browsable registry of every media metadata function in this catalog, with its category, kind, and SQL return type.
List every video-category function and its return type, alphabetically.
SELECT name, result_type
FROM media.main.media_functions
WHERE category = 'video'
ORDER BY name;
Count how many functions fall into each navigation category.
SELECT category, count(*) AS n
FROM media.main.media_functions
GROUP BY category
ORDER BY category;
audio_codec (input ANY)
Codec name of the first audio stream
Return the codec name of the first audio stream (e.g. 'aac').
SELECT media.main.audio_codec('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/silent.wav');
bitrate (input ANY)
Container bit rate in bits per second
Return the overall container bit rate in bits per second.
SELECT media.main.bitrate('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
duration (input ANY)
Container duration in seconds
Return the duration of a media file in seconds.
SELECT media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
fps (input ANY)
Frames per second of the first video stream (from avg_frame_rate)
Return the average frame rate (fps) of the first video stream.
SELECT media.main.fps('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
height (input ANY)
Pixel height of the first video stream
Return the pixel height of the first video stream.
SELECT media.main.height('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
media_format (input ANY)
Container format name (format_name), e.g. 'mov,mp4,m4a,3gp,3g2,mj2'
Return the container format name of a media file given its path.
SELECT media.main.media_format('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
media_size (input ANY)
Container size in bytes
Return the size of a media file in bytes as reported by ffprobe.
SELECT media.main.media_size('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
resolution (input ANY)
Resolution of the first video stream as 'WIDTHxHEIGHT' (e.g. '1920x1080')
Return the resolution of the first video stream as 'WIDTHxHEIGHT'.
SELECT media.main.resolution('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
stream_count (input ANY)
Number of elementary streams in the container
Count the elementary streams (video/audio/subtitle/data) in a media file.
SELECT media.main.stream_count('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
video_codec (input ANY)
Codec name of the first video stream
Return the codec name of the first video stream (e.g. 'h264').
SELECT media.main.video_codec('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
Inventory a list of media files (here the two sample URLs; a local folder works the same through glob()): for each file, its container format, whether it is video or audio-only (from video_codec / audio_codec), the codec, the video resolution (NULL for audio-only), and the duration.
SELECT parse_filename(file) AS file_name,
media.main.media_format(file) AS format,
CASE WHEN media.main.video_codec(file) IS NOT NULL THEN 'video' WHEN media.main.audio_codec(file) IS NOT NULL THEN 'audio-only' ELSE 'unknown' END AS kind,
coalesce(media.main.video_codec(file), media.main.audio_codec(file)) AS codec,
media.main.resolution(file) AS resolution,
round(media.main.duration(file), 2) AS seconds
FROM (VALUES ('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4'), ('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/silent.wav')) AS f(file)
ORDER BY file_name;
width (input ANY)
Pixel width of the first video stream
Return the pixel width of the first video stream.
SELECT media.main.width('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4');
media_streams (input ANY)
One row per elementary stream (video/audio/subtitle/data) in the media
List each elementary stream of an audio-only WAV file with its index, type, codec, channel count, sample rate, and bit rate, ordered by stream index.
SELECT idx, type, codec, channels, sample_rate, bit_rate
FROM media.main.media_streams('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/silent.wav')
ORDER BY idx;
Compare every stream's duration with the container's duration and show the drift in seconds (media_streams + duration); a non-zero drift flags a track that ends early or late, as in a truncated or badly remuxed file.
SELECT s.idx, s.type, s.codec, s.duration AS stream_seconds,
media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS container_seconds,
round(abs(s.duration - media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4')), 3) AS drift_seconds
FROM media.main.media_streams('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS s
ORDER BY s.idx;
SELECT media.main.media_format('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS format,
media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS seconds,
media.main.stream_count('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS streams;
| format | seconds | streams |
|---|---|---|
| mov,mp4,m4a,3gp,3g2,mj2 | 1 | 1 |
3 more examples
SELECT media.main.video_codec('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS codec,
media.main.resolution('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS resolution,
media.main.fps('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS fps;
SELECT idx, type, codec
FROM media.main.media_streams('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4')
ORDER BY idx;
SELECT key, value
FROM media.main.media_tags('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4')
ORDER BY key;
media_tags (input ANY)
One row per format-level metadata tag (title, artist, encoder, ...)
List the container-level metadata tags (title, artist, encoder, ...) of a WAV file as key/value rows, ordered by tag name.
SELECT key, value
FROM media.main.media_tags('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/silent.wav')
ORDER BY key;
One-row file card: container format and duration, the stream layout aggregated from media_streams (e.g. 'video:h264'), and the MP4 major_brand container tag from media_tags.
SELECT media.main.media_format('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS format,
round(media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4'), 2) AS seconds,
(SELECT string_agg(s.type || ':' || s.codec, ', ' ORDER BY s.idx) FROM media.main.media_streams('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS s) AS stream_layout,
(SELECT t.value FROM media.main.media_tags('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS t WHERE t.key = 'major_brand') AS major_brand;
Try these queries
Read the first video stream's codec, resolution, and frame rate.
SELECT media.main.video_codec('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS codec,
media.main.resolution('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS resolution,
media.main.fps('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS fps
List every elementary stream in a media file, one row per stream, ordered by stream index.
SELECT idx, type, codec
FROM media.main.media_streams('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4')
ORDER BY idx
Uses media_streams
List the container-level metadata tags of a media file as key/value rows, ordered by tag name.
SELECT key, value
FROM media.main.media_tags('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4')
ORDER BY key
Uses media_tags
Inventory a list of media files (here the two sample URLs; a local folder works the same through glob()): for each file, its container format, whether it is video or audio-only (from video_codec / audio_codec), the codec, the video resolution (NULL for audio-only), and the duration.
SELECT parse_filename(file) AS file_name,
media.main.media_format(file) AS format,
CASE WHEN media.main.video_codec(file) IS NOT NULL THEN 'video' WHEN media.main.audio_codec(file) IS NOT NULL THEN 'audio-only' ELSE 'unknown' END AS kind,
coalesce(media.main.video_codec(file), media.main.audio_codec(file)) AS codec,
media.main.resolution(file) AS resolution,
round(media.main.duration(file), 2) AS seconds
FROM (VALUES ('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4'), ('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/silent.wav')) AS f(file)
ORDER BY file_name
Compare every stream's duration with the container's duration and show the drift in seconds (media_streams + duration); a non-zero drift flags a track that ends early or late, as in a truncated or badly remuxed file.
SELECT s.idx, s.type, s.codec, s.duration AS stream_seconds,
media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS container_seconds,
round(abs(s.duration - media.main.duration('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4')), 3) AS drift_seconds
FROM media.main.media_streams('https://raw.githubusercontent.com/Query-farm/vgi-media/v0.4.0/test/sql/data/tiny.mp4') AS s
ORDER BY s.idx
List every video-category function and its return type, alphabetically.
SELECT name, result_type
FROM media.main.media_functions
WHERE category = 'video'
ORDER BY name
Uses media_functions
15 more examples in the Catalog, each listed under the table or function it uses.
Media is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Audio
Documents & media
Measure duration, tempo, loudness, spectral timbre, MFCCs and musical key of audio files with librosa
Image
Documents & media
Decode images, read EXIF and GPS tags, spot near-duplicates by perceptual hash, and make thumbnails
Documents & media
Pull tables, words with their positions, page geometry, form fields and metadata out of PDFs, and render pages to PNG