Audio-StreamGenerator

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "create a 'radio' stream by mixing ('cross fading') multiple audio sources (files or anything that can be converted to PCM audio) and sending it to a streaming server (like Icecast)",
   "author" : [
      "Sander Plas <oele@cpan.org>",
      "Bartosz Jarzyna <bbrtj.pro@gmail.com>"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "freebsd"
   ],
   "meta-spec" : {

META.yml  view on Meta::CPAN

---
abstract: "create a 'radio' stream by mixing ('cross fading') multiple audio sources (files or anything that can be converted to PCM audio) and sending it to a streaming server (like Icecast)"
author:
  - 'Sander Plas <oele@cpan.org>'
  - 'Bartosz Jarzyna <bbrtj.pro@gmail.com>'
build_requires:
  ExtUtils::MakeMaker: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010'
license: open_source

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

}

1;

__END__

=pod

=head1 NAME

Audio::StreamGenerator - create a 'radio' stream by mixing ('cross fading') multiple audio sources (files or anything that can be converted to PCM audio) and sending it to a streaming server (like Icecast)

=head1 SYNOPSIS

    use strict;
    use warnings;
    use Audio::StreamGenerator;

    my $out_command = q~
            ffmpeg -re -f s16le -acodec pcm_s16le -ac 2 -ar 44100 -i -  \
            -acodec libopus -ac 2 -b:a 160k -content_type application/ogg -format ogg icecast://source:hackme@localhost:8000/our_radio.opus \

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

    my $streamer = Audio::StreamGenerator->new(
        out_fh => $out_fh,
        get_new_source => \&get_new_source,
        run_every_second => \&run_every_second,
    );

    $streamer->stream();

=head1 DESCRIPTION

This module creates a 'live' audio stream that can be broadcast using streaming technologies like Icecast or HTTP Live Streaming.

It creates one ongoing audio stream by mixing or 'crossfading' multiple sources (normally audio files).

Although there is nothing stopping you from using this to generate a file that can be played back later, its intended use is to create a 'radio' stream that can be streamed or 'broadcast' live on the internet.

The module takes raw PCM audio from a file handle as input, and outputs raw PCM audio to another file handle. This means that an external program is necessary to decode (mp3/flac/etc) source files, and to encode & stream the actual output. For both p...

=head1 CONSTRUCTOR METHOD

    my $streamer = Audio::StreamGenerator->new( %options );

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

    my $streamer_sub = $streamer->get_streamer($sec_per_call);

    while (1) {
        $streamer_sub->();
    }

Get an anonymous subroutine that will produce C<$sec_per_call> seconds of a stream when called.

C<$sec_per_call> is optional, and is by default C<1>.

Use this method instead of L<stream> if you want to have more control over the streaming process, for example, running the streamer inside an event loop:

    use Mojo::IOLoop;

    my $loop = Mojo::IOLoop->singleton;
    my $streamer_sub = $streamer->get_streamer(0.25);

    $loop->recurring(0.1 => $streamer_sub);
    $loop->start;

Note: event loop will be blocked for up to 0.25 seconds every time the timer is done.



( run in 0.255 second using v1.01-cache-2.11-cpan-4d50c553e7e )