Script: video identification (Bash)

This script displays mplayer's information/identification lines of a multimedia file. Nowadays I prefer to use an undocumented feature of vcs (see below)

#!/bin/bash

# This script displays mplayer's information/identification lines of a multimedia file
# Put in the public domain. <http://w.corvera.eu/2007/11/shell-vidid/>

vididf() {
        mplayer -identify -frames 0 -ao null -vo null "$1" 2>/dev/null | grep ID_ | sort
}

for F in "$@"; do vididf "$F" ; done

Example:

$ vidid file.avi

ID_AUDIO_BITRATE=160000
ID_AUDIO_BITRATE=160000
ID_AUDIO_CODEC=mp3
ID_AUDIO_FORMAT=85
ID_AUDIO_ID=1
ID_AUDIO_NCH=0
ID_AUDIO_NCH=2
ID_AUDIO_RATE=0
ID_AUDIO_RATE=48000
ID_DEMUXER=avi
ID_FILENAME=file.avi
ID_LENGTH=2569.52
ID_VIDEO_ASPECT=0.0000
ID_VIDEO_BITRATE=1223960
ID_VIDEO_CODEC=ffodivx
ID_VIDEO_FORMAT=XVID
ID_VIDEO_FPS=25.000
ID_VIDEO_HEIGHT=360
ID_VIDEO_ID=0
ID_VIDEO_WIDTH=640
VCS version:
$ vcs -Z idonly somefile.avi
[...]
=========== Mplayer Identification ===========
Length: 42:39.52
Video
    Codec: XVID (Xvid (MPEG-4))
    Dimensions: 704x396
    FPS: 23.976
    Aspect:
Audio
    Codec: 85 (MPEG Layer III (MP3))
    Channels: 2
==============================================

=========== FFmpeg Identification ===========
Length: 42:39.51
Video
    Codec: mpeg4 (MPEG-4)
    Dimensions: 704x396
    FPS: 23.98
    Aspect: 16/9
Audio
    Codec: mp3 (MPEG Layer III (MP3))
    Channels: 2
=============================================

=========== Combined Identification ===========
Length: 42:38.01
Video
    Codec: XVID (Xvid (MPEG-4))
    Dimensions: 704x396
    FPS: 23.976
    Aspect: 16/9 (1.7778)
Audio
    Codec: 85 (MPEG Layer III (MP3))
    Channels: 2
=============================================

VCS update 2007-11-08: 1.0.10 released

New version released wth a bugfix and a couple new features: allow disabling timestamps and/or shadows.
See the changelog below.

I've also published a bit of information on the future of VCS and comments would be very welcome (in short, most probably, I'll be rewriting it in a different language than bash).

Finally, I'm moving the documentation into a wiki and filling in a bit more, will be live soonish I hope.

VCS OOP Rewrite?

Note: VCS stands for Video Contact Sheet *NIX, visit http://p.outlyer.net/vcs/ for details.

Abstract
I'm considering an alternative language in which to rewrite VCS. It must support OOP well enough and be relatively common-place. Current candidates are Java, Python and PHP5. Comments/suggestions/preferences are welcome, either here or by mail (outlyer@gmail.com) (but leave alone language hatred/fandom!).

VCS is, no matter how you look at it, a script. It's a piece of software that basically interfaces with other
pieces of software simplifying a task that could be done manually (yet in a harder way) with them. So a scripting language was the right choice, bash is the one I know better, it is really
powerful and most computers already have it installed. The-right-choice… *but*. Writing a relatively long and complex piece
of code and keeping it as modular as possible in bash is a pain; anyone that may have looked at the code should agree it's hard to read, let alone maintain. So, almost from the start I've been considering alternatives to bash.

The problem is I want to maintain the feats that make a script desirable (after all, it will remain technically a script as I have no intention to interface directly with ImageMagick's or libavcodec's libs). These
features can be summarised as cross platform, no compilation and a single file approach: users should be able to download the script file and run it right away (after filling dependencies of course, just as currently).

My language candidates are PHP version 5, Python and Java.

Java, while the less script-ish of them can still be single-file (JAR) and would need no compilation (by final users). PHP since version 5 has a lot more power in regards of OOP and of course it has that massive
library web developers love and hate 🙂 Python is the least known by me, it's meaningful whitespace still feels weird but apparently it's a very good option for OOP software.

I'm currently rewriting vcs in PHP and I'm even more convinced to switch languages after having some more power on my hands. I fear though that switching away from a shell script might make some people overlook vcs.

Comments would be greatly appreaciated.

Scroll to Top