Frame Server API
[Flix Engine Core Library]


Detailed Description

Flix Engine Frame Server API.

The Frame Server API allows an application to provide the engine with raw audio and video frames rather than entire files. This service is only available via the core Flix Engine library (libflixengine2_core.so). It is not available through the daemon (flixd) / rpc client library (libflixengine2.so) pair or the language extensions that are built to interface with libflixengine2.so.

Example Usage

   //initialize the library, create a handle to the engine and set our outfile
   Flix2_Init();
   Flix2_Create(&flix);
   Flix2_SetOutputFile(flix,"frameserver-out.flv");

   //enable the frame server
   Flix2_SetFrameServer(flix,on2true);

   //setup our video input, 320x240@29.97fps, bgra
   Flix2_SetVideoProperties(flix,VideoFormatBGRA,320,240,320*4,2997,1000);
   //setup our audio input, 2ch/16bitsps/44.1kHz
   Flix2_SetAudioProperties(flix,2,16,44100);

   //encode audio/video using the library's default encoding parameters
   Flix2_EncodeFrame(flix, FrameTypeVideo, on2false,
       vidframe, 320*240*4, 0);
   Flix2_EncodeFrame(flix, FrameTypeAudio, on2false,
       audframe, audframesiz, 0);
   ...
   Flix2_EncodeFrame(flix, FrameTypeVideo, on2false,
       vidframe, 320*240*4, 300300);
   Flix2_EncodeFrame(flix, FrameTypeAudio, on2false,
       audframe, audframesiz, 0);
   ...
   //set eos on both inputs
   Flix2_EncodeFrame(flix, FrameTypeVideo, on2true,
       NULL, 0, 303303);
   Flix2_EncodeFrame(flix, FrameTypeAudio, on2true,
       NULL, 0, 0);
   //finish encoding any queued frames
   do {
       Flix2_IsEncoderRunning(flix,&b);
   } while(b);

   //cleanup
   Flix2_Destroy(flix);
   Flix2_Deinit();

Attention:
The Frame Server API does not currently support resampling of the input audio.
Note:
As the Frame Server API deals with raw video and audio, which use a large amount of storage, no sample is distributed with the Flix Engine. If you are interested in using the Frame Server API and require a sample please contact support.


Enumerations

enum  FE2_FrameType {
  FrameTypeAudio,
  FrameTypeVideo
}
 Frame type being passed to Flix2_EncodeFrame(). More...
enum  FE2_VideoFormat {
  VideoFormatYV12,
  VideoFormatBGRA
}
 Format of input video used in calls to Flix2_SetVideoProperties(). More...

Functions

on2sc Flix2_SetFrameServer (FLIX2HANDLE flix, on2bool enable)
 Enable/disable the frame server for this session.
on2sc Flix2_GetFrameServer (FLIX2HANDLE flix, on2bool *enabled)
 Retrieve the current frame server status.
on2sc Flix2_SetAudioProperties (FLIX2HANDLE flix, uint8_t channels, int16_t bitspersample, int32_t samplerate)
 Set the input audio properties for the frame server.
on2sc Flix2_SetVideoProperties (FLIX2HANDLE flix, FE2_VideoFormat format, int32_t width, int32_t height, int32_t pitch, int32_t rate, int32_t scale)
 Set the input video properties for the frame server.
on2sc Flix2_EncodeFrame (FLIX2HANDLE flix, FE2_FrameType type, on2bool eos, uint8_t *frame, uint32_t len, int64_t ts90k)
 Queue an input frame for encoding.

Enumeration Type Documentation

Frame type being passed to Flix2_EncodeFrame().

Attention:
Available only in the Flix Engine Core Library
Enumerator:
FrameTypeAudio 
FrameTypeVideo 

Definition at line 88 of file fs_options.h.

Format of input video used in calls to Flix2_SetVideoProperties().

Attention:
Available only in the Flix Engine Core Library
Enumerator:
VideoFormatYV12 
VideoFormatBGRA 

Definition at line 95 of file fs_options.h.


Function Documentation

on2sc Flix2_EncodeFrame ( FLIX2HANDLE  flix,
FE2_FrameType  type,
on2bool  eos,
uint8_t frame,
uint32_t  len,
int64_t  ts90k 
)

Queue an input frame for encoding.

Parameters:
[in] flix Handle to the flix engine returned from Flix2_Create() or Flix2_CreateEx()
[in] type Input type
[in] eos End of stream indicator. Must be set for all streams to complete an encode (a null frame may be passed after all valid frames have been sent)
[in] frame Pointer to raw data buffer. (1 video frame or a chunk of audio samples based on the type parameter).
[in] len Size in bytes of the raw data pointed to by frame
[in] ts90k Timestamp for this frame in units of 90kHz. Currently only used for FrameTypeVideo
Return values:
ON2_OK on success
ON2_INVALID_PARAMS should one or more of the preconditions fail
<ON2_OK if there was an error completing encoder setup. Call Flix2_Errno() for further detail
Precondition:
flix is not NULL
frame is not NULL or eos is set
input of type type was setup using the corresponding Flix2_SetXXXProperties call
Attention:
Available only in the Flix Engine Core Library
Note:
The engine handles interleaving of the output file so input need not be perfectly interleaved. Making a reasonable attempt at interleaving the input will reduce memory usage, however.
Flix2_IsEncoderRunning() should be called after setting eos to ensure all frames have been encoded.
See also:
Example Usage

on2sc Flix2_GetFrameServer ( FLIX2HANDLE  flix,
on2bool enabled 
)

Retrieve the current frame server status.

Parameters:
[in] flix Handle to the flix engine returned from Flix2_Create() or Flix2_CreateEx()
[out] enabled Enabled (on2true) or disabled (on2false)
Return values:
ON2_OK on success
ON2_INVALID_PARAMS should one or more of the preconditions fail
Precondition:
flix is not NULL
Attention:
Available only in the Flix Engine Core Library
Note:
Default: on2false (disabled)
If enabled the user should call at least one of Flix2_SetAudioProperties() or Flix2_SetVideoProperties() before calling Flix2_EncodeFrame()

on2sc Flix2_SetAudioProperties ( FLIX2HANDLE  flix,
uint8_t  channels,
int16_t  bitspersample,
int32_t  samplerate 
)

Set the input audio properties for the frame server.

When FrameTypeAudio is passed to Flix2_EncodeFrame() the frame server will assume the input is of this format. The sample rate given will be used to calculate a timestamp.

Parameters:
[in] flix Handle to the flix engine returned from Flix2_Create() or Flix2_CreateEx()
[in] channels Number of audio channels (1/2)
[in] bitspersample The bits per input sample (8/16)
[in] samplerate The input sample rate in Hz (11025/22050/44100)
Return values:
ON2_OK on success
ON2_INVALID_PARAMS should one or more of the preconditions fail
Precondition:
flix is not NULL
channels is >0 and <= 2
bitspersample is 8 or 16
samplerate is 11025, 22050 or 44100
Attention:
Available only in the Flix Engine Core Library
Remarks:
Taken together with Flix2_SetVideoProperties(), can be viewed as the analogue of Flix2_SetInputFile()
Note:
MUST be called before Flix2_EncodeFrame() if audio output is desired
Calling this function after calling Flix2_EncodeFrame(FrameTypeAudio) is NOT supported

on2sc Flix2_SetFrameServer ( FLIX2HANDLE  flix,
on2bool  enable 
)

Enable/disable the frame server for this session.

Parameters:
[in] flix Handle to the flix engine returned from Flix2_Create() or Flix2_CreateEx()
[in] enable Enable (on2true) or disable (on2false) frame server mode
Return values:
ON2_OK on success
ON2_INVALID_PARAMS should the precondition fail
Precondition:
flix is not NULL
Attention:
Available only in the Flix Engine Core Library
Note:
Default: on2false (disabled)
If enabled the user should call at least one of Flix2_SetAudioProperties() or Flix2_SetVideoProperties() before calling Flix2_EncodeFrame()

on2sc Flix2_SetVideoProperties ( FLIX2HANDLE  flix,
FE2_VideoFormat  format,
int32_t  width,
int32_t  height,
int32_t  pitch,
int32_t  rate,
int32_t  scale 
)

Set the input video properties for the frame server.

When FrameTypeVideo is passed to Flix2_EncodeFrame() the frame server will assume the input is of this format.

Parameters:
[in] flix Handle to the flix engine returned from Flix2_Create() or Flix2_CreateEx()
[in] format Raw video format
[in] width Video width
[in] height Video height
[in] pitch Video pitch (stride) in bytes. For YV12 stride is typically equal to width, for BGRA it's width * 4
[in] rate Video rate (rate / scale = framerate)
[in] scale Video scale (rate / scale = framerate)
Return values:
ON2_OK on success
ON2_INVALID_PARAMS should one or more of the preconditions fail
Precondition:
flix is not NULL
format is a valid member of FE2_VideoFormat
width and height are > 0
pitch is non-zero
Attention:
Available only in the Flix Engine Core Library
Remarks:
Taken together with Flix2_SetAudioProperties(), can be viewed as the analogue of Flix2_SetInputFile()
Note:
MUST be called before Flix2_EncodeFrame() if video output is desired
Calling this function after calling Flix2_EncodeFrame(FrameTypeVideo) is NOT supported
If the input video is of variable framerate rate and scale may be omitted (i.e. set to 0)


On2 Technologies, Inc Flix Engine Linux documentation, generated on Tue Nov 2 16:53:01 2010 by doxygen 1.5.5