8 releases

0.1.9 Apr 18, 2024
0.1.8 Apr 28, 2023
0.1.7 Jul 23, 2022
0.1.6 Jul 27, 2020
0.1.2 Sep 20, 2018

#46 in Multimedia

Download history 24/week @ 2024-07-08 23/week @ 2024-07-15 3/week @ 2024-07-22 70/week @ 2024-07-29 22/week @ 2024-08-05 25/week @ 2024-08-12 18/week @ 2024-08-19 57/week @ 2024-08-26 43/week @ 2024-09-02 46/week @ 2024-09-09 16/week @ 2024-09-16 43/week @ 2024-09-23 20/week @ 2024-09-30 20/week @ 2024-10-07 15/week @ 2024-10-14 14/week @ 2024-10-21

74 downloads per month
Used in hashporn

MIT license

60KB
1.5K SLoC

metadata

Homebrew crates.io Build status

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):

ffprobe mediainfo

(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 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:

$ 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:

$ 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:

$ 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

$ make release

You should find metadata and metadata.1 in dist/<version>/.

Usage

$ 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 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 (c) 2018-2020 Zhiming Wang metadata@zhimingwang.org. The MIT License.

Dependencies

~7–18MB
~259K SLoC