Skip to content

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
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
Result
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.

setup.sql
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;

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'
);

3. Run a query

query.sql
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
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
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]'
);

Overview

Extract video/audio/container metadata from media files via ffprobe.

Catalog

Everything media exposes once attached — read straight from the worker's released build.

media 1 schema
main 1 view · 13 functions

Media metadata extraction functions (scalars + table functions) over ffprobe.

Schema examples (7)
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;
Result
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;
Views
media_functions 2 examples5 cols

Browsable registry of every media metadata function in this catalog, with its category, kind, and SQL return type.

Columns
name VARCHAR
Function name as called in SQL (e.g. media_format, media_streams).
kind VARCHAR
Whether the object is a 'scalar' function or a 'table' function.
category VARCHAR
Navigation category: 'container', 'video', 'audio', or 'enumeration'.
result_type VARCHAR
SQL type the scalar returns, or 'TABLE' for a table function.
description VARCHAR
One-line summary of what the function returns.
Examples (2)

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;
Link
Scalar functions
audio_codec (input ANY) 1 example

Codec name of the first audio stream

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsVARCHAR
Example

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');
Link
bitrate (input ANY) 1 example

Container bit rate in bits per second

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsBIGINT
Example

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');
Link
duration (input ANY) 1 example

Container duration in seconds

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsDOUBLE
Example

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');
Link
fps (input ANY) 1 example

Frames per second of the first video stream (from avg_frame_rate)

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsDOUBLE
Example

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');
Link
height (input ANY) 1 example

Pixel height of the first video stream

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsINTEGER
Example

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');
Link
media_format (input ANY) 1 example

Container format name (format_name), e.g. 'mov,mp4,m4a,3gp,3g2,mj2'

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsVARCHAR
Example

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');
Link
media_size (input ANY) 1 example

Container size in bytes

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsBIGINT
Example

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');
Link
resolution (input ANY) 1 example

Resolution of the first video stream as 'WIDTHxHEIGHT' (e.g. '1920x1080')

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsVARCHAR
Example

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');
Link
stream_count (input ANY) 1 example

Number of elementary streams in the container

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsINTEGER
Example

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');
Link
video_codec (input ANY) 2 examples

Codec name of the first video stream

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsVARCHAR
Examples (2)

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;
Link
width (input ANY) 1 example

Pixel width of the first video stream

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to extract the requested metadata
ReturnsINTEGER
Example

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');
Link
Table functions
media_streams (input ANY) 6 examples

One row per elementary stream (video/audio/subtitle/data) in the media

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to enumerate the output rows
Returns columns
idx INTEGER
Zero-based index of the stream within the container.
type VARCHAR
Stream codec type: 'video', 'audio', 'subtitle', or 'data'.
codec VARCHAR
Codec name for the stream (e.g. 'h264', 'aac'), or NULL when unknown.
width INTEGER
Pixel width for video streams, or NULL for non-video streams.
height INTEGER
Pixel height for video streams, or NULL for non-video streams.
bit_rate BIGINT
Stream bit rate in bits per second, or NULL when unknown.
duration DOUBLE
Stream duration in seconds, or NULL when unknown.
channels INTEGER
Audio channel count for audio streams, or NULL otherwise.
sample_rate INTEGER
Audio sample rate in Hz for audio streams, or NULL otherwise.
Examples (6)

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;
Result
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;
Link
media_tags (input ANY) 2 examples

One row per format-level metadata tag (title, artist, encoder, ...)

Arguments
input ANY
The media to probe: either a filesystem path to a media file or the raw media bytes themselves; ffprobe reads it to enumerate the output rows
Returns columns
key VARCHAR
Container-level metadata tag name (e.g. 'title', 'artist', 'encoder').
value VARCHAR
Value of the metadata tag.
Examples (2)

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;
Link

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

Uses video_codecresolutionfps

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

Uses media_formatvideo_codecaudio_codecresolutionduration

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

Uses durationmedia_streams

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.