Audio-Opusfile

 view release on metacpan or  search on metacpan

lib/Audio/Opusfile.pm  view on Meta::CPAN


sub new_from_memory {
	my ($class, $buf) = @_;
	open_memory($buf)
}

1;
__END__

=encoding utf-8

=head1 NAME

Audio::Opusfile - partial interface to the libopusfile Ogg Opus library

=head1 SYNOPSIS

  use Audio::Opusfile;
  my $of = Audio::Opusfile->new_from_file('silence.opus');
  my $tags = $of->tags;
  say $tags->query('TITLE'); # Cellule

=head1 DESCRIPTION

Opus is a totally open, royalty-free, highly versatile audio codec.
Opus is unmatched for interactive speech and music transmission over
the Internet, but is also intended for storage and streaming
applications. It is standardized by the Internet Engineering Task
Force (IETF) as RFC 6716 which incorporated technology from Skype's
SILK codec and Xiph.Org's CELT codec.

libopusfile is a library for decoding and basic manipulation of Ogg
Opus files.

Audio::Opusfile is an interface to libopusfile. It exports nearly all
of the functions for obtaining metadata of an Opus file or buffer in
that library. Future versions will additionally provide functions for
decoding Opus data into PCM.

The API might change in future versions.

=head1 METHODS

=over

=item Audio::Opusfile->B<new_from_file>(I<$file>)

Creates a new Audio::Opusfile object from an Ogg Opus file.

Dies if the given file does not exist or is not a valid Ogg Opus file.

=item Audio::Opusfile->B<new_from_memory>(I<$buffer>)

Creates a new Audio::Opusfile object from a buffer containing Ogg Opus
data.

Dies if the given buffer does not contain valid data.

=item Audio::Opusfile::test(I<$buffer>)

Returns true if the given buffer looks like the beginning of a valid
Ogg Opus file, false otherwise.

Dies if the given buffer does not have sufficient data to tell if it
is an Opus stream or if it looks like a Opus stream but parsing it
failed.

=item $of->B<head>

Returns an L<Audio::Opusfile::Head> object corresponding to the file.

=item $of->B<tags>

Returns an L<Audio::Opusfile::Tags> object corresponding to the file.

=item $of->B<seekable>

Returns whether or not the data source being read is seekable.

=item $of->B<link_count>

Returns the number of links in this chained stream. Always returns 1
for unseekable sources.

=item $of->B<serialno>([I<$link_index>])

Get the serial number of the given link in a (possibly-chained) Ogg
Opus stream. If the given index is greater than the total number of
links, this returns the serial number of the last link.

If the source is not seekable, I<$link_index> is negative, or
I<$link_index> is not given, then this function returns the serial
number of the current link.

=item $of->B<raw_total>([I<$link_index>])

Get the total (compressed) size of the stream (with no arguments), or
of an individual link in a (possibly-chained) Ogg Opus stream (with
one nonnegative argument), including all headers and Ogg muxing
overhead.

The stream must be seekable to get the total. A negative value is
returned if the stream is not seekable.

B<Warning:> If the Opus stream (or link) is concurrently multiplexed
with other logical streams (e.g., video), this returns the size of the
entire stream (or link), not just the number of bytes in the first
logical Opus stream. Returning the latter would require scanning the
entire file.

=item $of->B<pcm_total>([I<$link_index>])

Get the total PCM length (number of samples at 48 kHz) of the stream
(with no arguments), or of an individual link in a (possibly-chained)
Ogg Opus stream (with one nonnegative argument).

Users looking for op_time_total() should use this function instead.
Because timestamps in Opus are fixed at 48 kHz, there is no need for a
separate function to convert this to seconds.

The stream must be seekable to get the total. A negative value is
returned if the stream is not seekable.

=item $of->B<current_link>



( run in 0.816 second using v1.01-cache-2.11-cpan-5735350b133 )