Giter VIP home page Giter VIP logo

metadata's Introduction

metadata

Homebrew crates.io Nix 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

Nix

On NixOS and any other Linux distro using Nix, metadata can be installed with Nix using the unstable channel:

$ # Install it to your local profile:
$ nix-env -iA metadata
$ # As a Nix shell:
$ nix-shell -p 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 <[email protected]>
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

Copyright (c) 2018-2020 Zhiming Wang [email protected]. The MIT License.

metadata's People

Contributors

zmwangx avatar myclevorname avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.