Encoder package¶
Core module¶
- 
class 
timeside.core.encoder.GstEncoder(output, streaming=False, overwrite=False)[source]¶ - 
- 
process(self, frames, eod=False)[source]¶ Process input frames and return a (output_frames, eod) tuple. Both input and output frames are 2D numpy arrays, where columns are channels, and containing an undetermined number of frames. eod=True means that the end-of-data has been reached.
Output-only processors (such as decoders) will raise an exception if the frames argument is not None. All processors (even encoders) return data, even if that means returning the input unchanged.
Warning: it is required to call setup() before this method.
- 
release(self)[source]¶ Release resources owned by this processor. The processor cannot be used anymore after calling this method.
- 
set_metadata(self, metadata)[source]¶ Set the metadata to be embedded in the encoded output.
In non-streaming mode, this method updates the metadata directly into the output file, without re-encoding the audio data, provided this file already exists.
It isn’t required to call this method, but if called, it must be before process().
- 
type= 'encoder'¶ 
 - 
 
Encoders¶
Flac encoder¶
- 
class 
timeside.plugins.encoder.flac.FlacEncoder(output, streaming=False, overwrite=False)[source]¶ FLAC encoder based on Gstreamer
- 
static 
format()[source]¶ Return the encode/encoding format as a short string Example: “MP3”, “OGG”, “AVI”, …
- 
static 
id()[source]¶ Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…
- 
set_metadata(self, metadata)[source]¶ Set the metadata to be embedded in the encoded output.
In non-streaming mode, this method updates the metadata directly into the output file, without re-encoding the audio data, provided this file already exists.
It isn’t required to call this method, but if called, it must be before process().
- 
setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None)[source]¶ Allocate internal resources and reset state, so that this processor is ready for a new run.
The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.
- 
static 
 
Aac encoder¶
- 
class 
timeside.plugins.encoder.m4a.AacEncoder(output, streaming=False, overwrite=False)[source]¶ AAC encoder based on Gstreamer
- 
static 
format()[source]¶ Return the encode/encoding format as a short string Example: “MP3”, “OGG”, “AVI”, …
- 
static 
id()[source]¶ Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…
- 
set_metadata(self, metadata)[source]¶ Set the metadata to be embedded in the encoded output.
In non-streaming mode, this method updates the metadata directly into the output file, without re-encoding the audio data, provided this file already exists.
It isn’t required to call this method, but if called, it must be before process().
- 
setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None)[source]¶ Allocate internal resources and reset state, so that this processor is ready for a new run.
The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.
- 
static 
 
Mp3 encoder¶
- 
class 
timeside.plugins.encoder.mp3.Mp3Encoder(output, streaming=False, overwrite=False, target='quality', target_value=2, cbr=False)[source]¶ MP3 encoder based on Gstreamer
- 
static 
format()[source]¶ Return the encode/encoding format as a short string Example: “MP3”, “OGG”, “AVI”, …
- 
static 
id()[source]¶ Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…
- 
setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None)[source]¶ Allocate internal resources and reset state, so that this processor is ready for a new run.
The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.
- 
static 
 
Vorbis encoder¶
- 
class 
timeside.plugins.encoder.ogg.VorbisEncoder(output, streaming=False, overwrite=False)[source]¶ OGG Vorbis encoder based on Gstreamer
- 
static 
format()[source]¶ Return the encode/encoding format as a short string Example: “MP3”, “OGG”, “AVI”, …
- 
static 
id()[source]¶ Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…
- 
set_metadata(self, metadata)[source]¶ Set the metadata to be embedded in the encoded output.
In non-streaming mode, this method updates the metadata directly into the output file, without re-encoding the audio data, provided this file already exists.
It isn’t required to call this method, but if called, it must be before process().
- 
setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None)[source]¶ Allocate internal resources and reset state, so that this processor is ready for a new run.
The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.
- 
static 
 
Wav encoder¶
- 
class 
timeside.plugins.encoder.wav.WavEncoder(output, streaming=False, overwrite=False)[source]¶ WAV encoder based on Gstreamer
- 
static 
format()[source]¶ Return the encode/encoding format as a short string Example: “MP3”, “OGG”, “AVI”, …
- 
static 
id()[source]¶ Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…
- 
set_metadata(self, metadata)[source]¶ Set the metadata to be embedded in the encoded output.
In non-streaming mode, this method updates the metadata directly into the output file, without re-encoding the audio data, provided this file already exists.
It isn’t required to call this method, but if called, it must be before process().
- 
setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None)[source]¶ Allocate internal resources and reset state, so that this processor is ready for a new run.
The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.
- 
static 
 
WebM encoder¶
- 
class 
timeside.plugins.encoder.webm.WebMEncoder(output, streaming=False, overwrite=False, video=False)[source]¶ WebM encoder based on Gstreamer
- 
static 
format()[source]¶ Return the encode/encoding format as a short string Example: “MP3”, “OGG”, “AVI”, …
- 
static 
id()[source]¶ Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…
- 
set_metadata(self, metadata)[source]¶ Set the metadata to be embedded in the encoded output.
In non-streaming mode, this method updates the metadata directly into the output file, without re-encoding the audio data, provided this file already exists.
It isn’t required to call this method, but if called, it must be before process().
- 
setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None)[source]¶ Allocate internal resources and reset state, so that this processor is ready for a new run.
The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.
- 
static 
 
AudioSink encoder¶
- 
class 
timeside.plugins.encoder.audiosink.AudioSink(output_sink='autoaudiosink')[source]¶ Gstreamer-based Audio Sink
This encoder plays the decoded audio stream to the sound card
- Parameters
 - output_sinkstr, optional
 Gstreamer sink element Default to ‘autoaudiosink’ Possible values : ‘autoaudiosink’, ‘alsasink’, ‘osssink’
- >>> import timeside
 - >>> from timeside.core import get_processor
 - >>> from timeside.core.tools.test_samples import samples
 - >>> wav_file = samples[‘sine440Hz_mono_1s.wav’]
 - >>> d = get_processor(‘file_decoder’)(wav_file)
 - >>> e = get_processor(‘live_encoder’)()
 - >>> (d|e).run() # doctest: +SKIP
 
- 
static 
format()[source]¶ Return the encode/encoding format as a short string Example: “MP3”, “OGG”, “AVI”, …
- 
static 
id()[source]¶ Short alphanumeric, lower-case string which uniquely identify this processor, suitable for use as an HTTP/GET argument value, in filenames, etc…
- 
set_metadata(self, metadata)[source]¶ Set the metadata to be embedded in the encoded output.
In non-streaming mode, this method updates the metadata directly into the output file, without re-encoding the audio data, provided this file already exists.
It isn’t required to call this method, but if called, it must be before process().
- 
setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None)[source]¶ Allocate internal resources and reset state, so that this processor is ready for a new run.
The channels, samplerate and/or blocksize and/or totalframes arguments may be required by processors which accept input. An error will occur if any of these arguments is passed to an output-only processor such as a decoder.