[vorbis-dev] using vorbiscomment

Kenneth Arnold ken at arnoldnet.net
Sun Oct 15 13:20:11 PDT 2000



On Sun, Oct 15, 2000 at 01:17:01PM -0400, Alex Shinn wrote:
Content-Description: message body and .signature
> 
> As far as I could find, nowhere in the documentation or even source
> does it actually explain how to use vorbiscomment.  Just a simple
> "vorbiscomment reads TAG=VALUE pairs on separate lines from stdin"
> would save people a lot of time.  Of course, this is still a painful
> tool to use, and since I had some .ogg's lying around with broken
> comments (from my first ogg vorbis patch to grip), I wrote a little
> Perl script (attached) to behave like mp3info.  It has short and long
> command options for all of the suggested vorbis comment fields, and
> can act on multiple files listed on the command line.

That was _exactly_ why I made vorbiscomment with that simplistic interface,
so others can go write more complex wrapper programs for it. Very nice :)
Add this to the CVS tree, anyone?

> BTW, is anyone working on a vorbis Perl module?  If not, I'll probably
> put one together.

not afaik. It would be useful, and pretty easy if libvorbisfile could write
as well as read (can it yet? I've been too busy to keep up with things).

See comments inline.

Content-Description: ogginfo perl script
> #!/usr/bin/perl -w

# If your Perl implementation resides somewhere other than /usr/bin/perl,
# change the above line to reflect that.

> 
> ## ogginfo -- Ogg Vorbis Comment Editor
> 
> ## Created:    <Sun Oct 15 02:57:05 EDT 2000>
> ## Time-stamp: <Sun Oct 15 12:44:08 EDT 2000>
> ## Author:     Alex Shinn <foof at debian.org>
> 
> # Modules
> use strict;
> use Getopt::Long;
> 
> 
> # Variables
> my $version = '0.1';
> my %opt;
> my %old;
> my %new;
> 
> 
> # Parse Options
> GetOptions(\%opt, 'h!','help!','V!','ogg-version!','t:s','title:s',
>            'v:s','version:s','l:s','album:s','a:s','artist:s',
>            'o:s','organization:s','D:s','description:s','g:s','genre:s',
>            'd:s','date:s','p:s','location:s','c:s','copyright:s')
>   or usage();
> usage() if $opt{h} || $opt{help};
> version() if $opt{V} || $opt{'ogg-version'};
> # Translate short options
> $opt{title} = $opt{t} if exists $opt{t};
> $opt{version} = $opt{v} if exists $opt{v};
> $opt{album} = $opt{l} if exists $opt{l};
> $opt{artist} = $opt{a} if exists $opt{a};
> $opt{organization} = $opt{o} if exists $opt{o};
> $opt{description} = $opt{D} if exists $opt{D};
> $opt{genre} = $opt{g} if exists $opt{g};
> $opt{date} = $opt{d} if exists $opt{d};
> $opt{location} = $opt{p} if exists $opt{p};
> $opt{copyright} = $opt{c} if exists $opt{c};

It would seem like there should be an easier way to implement that...
Don't ask me, though.

> # Read comment options
> $new{title} = $opt{title} if exists $opt{title};
> $new{version} = $opt{version} if exists $opt{version};
> $new{album} = $opt{album} if exists $opt{album};
> $new{artist} = $opt{artist} if exists $opt{artist};
> $new{organization} = $opt{organization} if exists $opt{organization};
> $new{description} = $opt{description} if exists $opt{description};
> $new{genre} = $opt{genre} if exists $opt{genre};
> $new{date} = $opt{date} if exists $opt{date};
> $new{location} = $opt{location} if exists $opt{location};
> $new{copyright} = $opt{copyright} if exists $opt{copyright};
> 
> 
> # Act on each remaining arg
> foreach my $ogg (@ARGV) {
>   # Get existing comments
>   %old = map { my ($tag, $value) = split(/=/,$_,2); chop($value);
>                "\L$tag", $value }
>     `vorbiscomment -l $ogg 2>/dev/null`;
>   next if $?;
>   # Merge new comments
>   while (my ($k, $v) = each(%new)) {
>     $old{$k} = $v;
>   }
>   if (%new) {
>     # Set new comments
>     open(OUTPUT, "| vorbiscomment $ogg 2>/dev/null") || next;
>     while (my ($k, $v) = each(%old)) {
>       if ($v) {
>         print OUTPUT "\U$k", "=$v\n";
>       }
>     }
>     close(OUTPUT);
>   }
>   else {
>     while (my ($k, $v) = each(%old)) {
>       print "\U$k", "=$v\n";
>     }
>   }
> }
> 
> 
> 
> # Print a usage summary
> sub usage {
>   print <<EOF;
> usage: $0 [options] [file ...]
> 
>   -h, --help                 display this message
>   -V, --ogg-version          print version info
>   -t, --title=TITLE          set title
>   -v, --version=VER          set title version
>   -l, --album=ALBUM          set album
>   -a, --artist=artist        set artist
>   -o, --organization=ORG     set organization/record label
>   -D, --description=DESC     set brief contents description
>   -g, --genre=GENRE          set short genre description
>   -d, --date=DATE            set date
>   -p, --location=PLACE       set recording location info
>   -c, --copyright=COPY       set copyright info
> EOF
>   exit 0;
> }

How about custom comments? The script should provide a means to insert,
delete, and move these around. Also, it is possible (and indeed useful)
to have multiple artist, description, title, location, etc. tags. Maybe
you need to rethink the interface just a little.

> 
> # Print version info
> sub version {
>   print "$0 $version\n";
>   exit 0;
> }


-- 
Kenneth Arnold <ken at arnoldnet.net> / kcarnold / Linux user #180115
http://arnoldnet.net/~kcarnold/

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.




More information about the Vorbis-dev mailing list