The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

POE::Component::Enc::Ogg - POE component to wrap Ogg Vorbis encoder oggenc

SYNOPSIS

  use POE qw(Component::Enc::Ogg);

  $encoder1 = POE::Component::Enc::Ogg->new();
  $encoder1->enc(input => "/tmp/track03.wav");

  $encoder2 = POE::Component::Enc::Ogg->new(
    parent    => 'MainSession',
    priority  => 10,
    quality   => 6,
    status    => 'oggStatus',
    error     => 'oggError',
    warning   => 'oggWarning',
    done      => 'oggDone',
    album     => 'Flood',
    genre     => 'Alternative'
    );
  $encoder2->enc(
    artist      => 'They Might be Giants',
    title       => 'Birdhouse in your Soul',
    input       => "/tmp/track02.wav",
    output      => "/tmp/02.ogg",
    tracknumber => 'Track 2',
    date        => '1990',
    comment     => ['origin=CD', 'loudness=medium']
    );

  POE::Kernel->run();

ABSTRACT

POE is a multitasking framework for Perl. Ogg Vorbis is an open standard for compressed audio and oggenc is an encoder for this standard. This module wraps oggenc into the POE framework, simplifying its use in, for example, a CD music ripper and encoder application.

DESCRIPTION

This POE component encodes wav and flac audio files into Ogg Vorbis format. It's merely a wrapper for the oggenc program. For flac files, the flac(1) program is also required.

METHODS

The module provides an object oriented interface as follows.

new

Used to create an encoder instance. The following parameters are available. All of these are optional.

priority

This is the delta priority for the encoder relative to the caller, default is 0. A positive value lowers the encoder's priority. See POE::Wheel:Run(3pm) and nice(1).

parent

Names the session to which events are posted. By default this is main.

quality

Sets the encoding quality to the given value, between -1 (low) and 10 (high). If unspecified, the default quality level is 3. Fractional quality levels such as 2.5 are permitted.

status
error
warning
done

These parameters specify the events that are posted to the main session. By default the events are status, error, warning and done respectively.

album
genre

These parameters are used to pass information to the encoder.

enc

Encodes the given file, naming the result with a .ogg extension. The only mandatory parameter is the name of the file to encode.

input

The input file to be encoded. This must be a .wav file or a .flac file.

output

The output file to encode to. This will be a .ogg file. This parameter is optional, and if unspecied the output file name will be formed by replacing the extension of the input file name with .ogg.

delete

A true value for this parameter indicates that the original input file should be deleted after encoding.

tracknumber
title
artist
date

These parameters are used to pass information to the encoder. They all all optional.

comment

For the comment parameter, the encoder expects tag-value pairs separated with an equals sign ('tag=value'). Multiple pairs can be specified because this parameter is a list. Note that this parameter must always be passed as a list even if it has only one element. This parameter is optional.

You can use this parameter as a generic way to specify all the specific parameters listed above (i.e. album, genre, tracknumber, title, artist & date), and you can name your own tags. For example, the following two statements are equivalent.

  $encoder2->enc(
    input       => "/tmp/track02.wav"),
    artist      => 'They Might be Giants',
    title       => 'Birdhouse in your Soul',
    comment     => ['source=CD'],   # my non-'standard' tag
    );

  $encoder2->enc(
    input       => "/tmp/track02.wav"),
    comment     => [
                    'artist=They Might be Giants',
                    'title=Birdhouse in your Soul',
                    'source=CD',    # my non-'standard' tag
                   ],
    );

EVENTS

Events are passed to the session specified to the new() method to indicate progress, completion, warnings and errors. These events are described below, with their default names; alternative names may be specified when calling new().

The first argument (ARG0) passed with these events is always the instance of the encoder as returned by new(). ARG1 and ARG2 are always the input and output file names respectively.

status

Sent during encoding to indicate progress. ARG3 is the percentage of completion so far, and ARG4 is the estimated number of seconds remaining to completion.

warning

Sent when the encoder emits a warning. ARG3 is the warning message.

error

Sent in the event of an error from the encoder. ARG3 is the error code from the encoder and ARG4 is the error message if provided, otherwise ''.

done

This event is sent upon completion of encoding.

SEE ALSO

Vorbis Tools oggenc(1), POE::Component::Enc::Flac, POE::Component::Enc::Mp3, POE::Component::CD::Detect, POE::Component::CD::Rip.

http://www.ambrosia.plus.com/perl/modules/POE-Component-Enc-Ogg/

AUTHOR

Steve James <steATcpanDOTorg>

This module was inspired by Erick Calder's POE::Component::Enc::Mp3

DATE

$Date: 2004/05/31 08:10:55 $

VERSION

$Revision: 1.5 $

COPYRIGHT AND LICENSE

Copyright (c) 2004 Steve James

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.