Recursive AI

Inspect a video file from the command line

All onemedia recipes

onemedia info <file> prints a video file’s format, duration, tracks with their codec strings, tags and capture facts. Add --json for the same as JSON, with every candidate for each fact. It is a .NET tool, so it needs the .NET 10 SDK or runtime. The files are MDN’s CC0 flower clip and the iPhone-style test file from the OneMedia repository (synthetic picture, invented tags).

Terminal
dotnet tool install --global RecursiveAI.OneMedia.Tool --version 0.1.0-preview.1
curl -L -o flower.mp4 https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4
curl -L -o iphone-style.mov https://raw.githubusercontent.com/recursive-ai-oss/onemedia-csharp/v0.1.0-preview.1/testdata/metadata/tags_keys.mov
onemedia --version
Text
0.1.0-preview.1

Text

Terminal
onemedia info flower.mp4
Text
format: isobmff
duration: 00:00:05.0550000
track 0: video h264 (avc1.64001F) [avc1] 960x540 30000/1001 fps lang=und disposition=Default
track 1: audio aac (mp4a.40.2) [mp4a] 48000 Hz 2 ch lang=und disposition=Default
captureTime: 2018-03-07T15:21:21Z (mvhd, 1 candidate(s))
rotation: 0 (tkhd.matrix, 1 candidate(s))

Each track line is: index, kind, codec, the RFC 6381 string in parentheses, the container’s codec tag in brackets, then size, rotation (rotate 90 when there is one) and frame rate for video, or rate and channels for audio, then language and flags. A file with tags and device facts prints more lines:

Terminal
onemedia info iphone-style.mov
Text
format: isobmff
duration: 00:00:01
track 0: video h264 (avc1.64000B) [avc1] 160x120 25/1 fps lang=und disposition=Default
track 1: audio aac (mp4a.40.2) [mp4a] 44100 Hz 1 ch lang=und disposition=Default
tag Title: Keyed_Title
tag Author: Pat_Doe
tag Comment: Keyed_comment
tag Encoder: Lavf61.1.100
captureTime: 2023-04-05T10:11:12+02:00 (mdta:com.apple.quicktime.creationdate, 1 candidate(s))
location: 37.7749,-122.4194,12.5 (mdta:com.apple.quicktime.location.ISO6709, 1 candidate(s))
make: Contoso (mdta:com.apple.quicktime.make, 1 candidate(s))
model: Camera_X1 (mdta:com.apple.quicktime.model, 1 candidate(s))
software: 17.1 (mdta:com.apple.quicktime.software, 1 candidate(s))
rotation: 0 (tkhd.matrix, 1 candidate(s))

Each fact line shows the value, where it came from, and how many candidates the file holds. Damage the reader found prints as defect: lines.

JSON

Terminal
onemedia info iphone-style.mov --json

The object has format, the durations as exact ticks and timescales, tracks (with rfc6381, size, rotation, rate and channels), tags, facts and defects. Each fact lists every candidate:

Text
"location": {
  "value": "37.7749,-122.4194,12.5",
  "candidates": [
    {
      "value": "37.7749,-122.4194,12.5",
      "source": "mdta:com.apple.quicktime.location.ISO6709",
      "raw": "\u002B37.7749-122.4194\u002B012.500/",
      "interpretation": "ISO 6709 latitude, longitude and optional altitude",
      "timezone": "Unknown"
    }
  ]
}

The JSON escapes + as \u002B; any JSON parser reads it back as +.

Exit codes

0 when the file was read, 1 when it couldn’t be (not found, or not a format OneMedia reads: unsupported: The data is not in any registered format. on standard error), and 2 with a usage message for anything but info <file> [--json] or --version.

Limits

  • One command. 0.1 has info and --version only. It doesn’t convert, extract, trim or edit anything.
  • Formats. MP4, MOV, 3GP, M4A/M4V, fragmented MP4, MKV and WebM, as for the library.
  • Text output shows the best candidate of each fact and the number of candidates; use --json to see them all. It doesn’t print track names; --json doesn’t either, so use the library for those (see List the tracks of a video).
  • Matroska frame rates print as the container’s fraction of nanoseconds, such as 200000000/8333333 fps for 24 fps.

The same information from C#: Get video duration, resolution and codec.