# metadata
[](#homebrew)
[](https://crates.io/crates/metadata)
[](https://github.com/zmwangx/metadata/actions)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [History](#history)
- [Installation](#installation)
- [Homebrew](#homebrew)
- [Debian/Ubuntu](#debianubuntu)
- [Usage](#usage)
- [Performance](#performance)
- [Bugs](#bugs)
- [Copyright](#copyright)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
`metadata` is a media metadata parser and formatter designed for human consumption. Powered by FFmpeg.
Example:
```
$ metadata '20160907 Apple Special Event.m4v'
Title: Apple Special Event, September 2016 (1080p)
Filename: 20160907 Apple Special Event.m4v
File size: 6825755188 (6.83GB, 6.36GiB)
Container format: MPEG-4 Part 14 (M4V)
Duration: 01:59:15.88
Pixel dimensions: 1920x800
Sample aspect ratio: 1:1
Display aspect ratio: 12:5
Scan type: Progressive scan*
Frame rate: 29.97 fps
Bit rate: 7631 kb/s
#0: Video, H.264 (High Profile level 4), yuv420p, 1920x800 (SAR 1:1, DAR 12:5), 29.97 fps, 7500 kb/s
#1: Audio (und), AAC (LC), 48000 Hz, stereo, 125 kb/s
#2: Subtitle (eng), EIA-608 closed captions
```
Compare this to `ffprobe` or `mediainfo` (both great tools, just not so human-readable):


(`mediainfo` prints so much, the output doesn't even fit on my screen with 85 lines. Now try using it in a 80x24 terminal.)
`metadata` can print tags too if you want to, hopefully better organized:
```
$ metadata -t '20160907 Apple Special Event.m4v'
Title: Apple Special Event, September 2016 (1080p)
Filename: 20160907 Apple Special Event.m4v
File size: 6825755188 (6.83GB, 6.36GiB)
Container format: MPEG-4 Part 14 (M4V)
Duration: 01:59:15.88
Pixel dimensions: 1920x800
Sample aspect ratio: 1:1
Display aspect ratio: 12:5
Scan type: Progressive scan*
Frame rate: 29.97 fps
Bit rate: 7631 kb/s
Streams:
#0: Video, H.264 (High Profile level 4), yuv420p, 1920x800 (SAR 1:1, DAR 12:5), 29.97 fps, 7500 kb/s
#1: Audio (und), AAC (LC), 48000 Hz, stereo, 125 kb/s
#2: Subtitle (eng), EIA-608 closed captions
Tags:
title: Apple Special Event, September 2016 (1080p)
artist: Apple
album: Apple Keynotes (1080p)
compilation: 0
description: iPhone 7, iPhone 7 Plus, AirPods, Apple Watch Series 2, Apple Watch Hermès and Apple Watch Nike+
podcast: 1
episode_uid: 104
synopsis: See Apple CEO Tim Cook and team introduce the iPhone 7, iPhone 7 Plus, AirPods, Apple Watch Series 2, Apple Watch Hermès and Apple Watch Nike+.
genre: Podcast
gapless_playback: 0
date: 2016-09-09T12:00:00Z
rating: 0
season_number: 0
episode_sort: 0
media_type: 0
#2
rotate: 0
language: eng
```
You can also request *all* tags with `-A, --all-tags`. Output not shown here for the sake of brevity (that ship has sailed, but still).
## History
`metadata` is a Rust port of the Python tool of the same name bundled in my [storyboard](https://pypi.org/project/storyboard/) project. I started the storyboard project to replicate the storyboard/thumbnail images generated by some proprietary media players, in order to facilitate media file sharing on online forums. While I long stopped sharing media files online (and hence stopped using `storyboard`), I still love the command line metadata formatter that came out of the storyboard effort, and use it all the time in place of `ffprobe` or `mediainfo`. Years later, `metadata` could use some decoupling and refresh, and I could learn myself some Rust, so I started this port.
Since this is my intro to Rust project, *the code is guaranteed to be shitty*.
## Installation
### Homebrew
On macOS, `metadata` can be installed with Homebrew:
```console
$ brew tap zmwangx/metadata https://github.com/zmwangx/metadata
$ brew install zmwangx/metadata/metadata
```
### Ubuntu PPA
On Ubuntu 18.04 and 20.04, `metadata` can be installed from [ppa:zmwangx/metadata](https://launchpad.net/~zmwangx/+archive/ubuntu/metadata/):
```console
$ add-apt-repository ppa:zmwangx/metadata
$ apt update && apt install metadata
```
### Building from source
**FFmpeg with development headers and the Rust toolchain are required.** FFmpeg 3.4 and later are supported.
On macOS, the following command should satisfy the non-Rust dependencies:
```console
$ brew install ffmpeg pkg-config
```
On Debian/Ubuntu, the following command should satisfy the non-Rust dependencies:
```
$ apt install -y build-essential clang libavcodec-dev libavformat-dev libavutil-dev pkg-config
```
Similarly for other distros.
The basic build command to run once you have the dependencies is
```console
$ make release
```
You should find `metadata` and `metadata.1` in `dist/<version>/`.
## Usage
```console
$ metadata -h
metadata 0.1.4
Zhiming Wang <metadata@zhimingwang.org>
Media file metadata for human consumption.
USAGE:
metadata [FLAGS] <FILE>...
FLAGS:
-A, --all-tags Print all metadata tags
-c, --checksum Include file checksum(s)
-h, --help Prints help information
-s, --scan Decode frames to determine scan type (slower, but determines interlaced more accurately; see man
page for details)
-t, --tags Print metadata tags, except mundane ones
-V, --version Prints version information
ARGS:
<FILE>... Media file(s)
```
The [man page](man/metadata.1.adoc) has more details.
## Performance
`metadata` is fast (a vast improvement over the old Python tool). I tested a collection of ~1300 video files on one of my USB 3.0 media drives, and `metadata` (with `xargs`) managed to chew through all of them within 50 seconds, less than 40ms per file on average. It might be faster for files hosted on a native SSD. `ffprobe` was actually slower in the test since it only accepts one file at a time.
## Bugs
<https://github.com/zmwangx/metadata/issues>.
## Copyright
Copyright (c) 2018-2020 Zhiming Wang <metadata@zhimingwang.org>. The MIT License.