//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();
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. |
enum FE2_FrameType |
Frame type being passed to Flix2_EncodeFrame().
Definition at line 88 of file fs_options.h.
enum FE2_VideoFormat |
Format of input video used in calls to Flix2_SetVideoProperties().
Definition at line 95 of file fs_options.h.
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.
[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 |
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 |
NULL
NULL
or eos is set on2sc Flix2_GetFrameServer | ( | FLIX2HANDLE | flix, | |
on2bool * | enabled | |||
) |
Retrieve the current frame server status.
[in] | flix | Handle to the flix engine returned from Flix2_Create() or Flix2_CreateEx() |
[out] | enabled | Enabled (on2true ) or disabled (on2false ) |
ON2_OK | on success | |
ON2_INVALID_PARAMS | should one or more of the preconditions fail |
NULL
on2false
(disabled) 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.
[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) |
ON2_OK | on success | |
ON2_INVALID_PARAMS | should one or more of the preconditions fail |
NULL
on2sc Flix2_SetFrameServer | ( | FLIX2HANDLE | flix, | |
on2bool | enable | |||
) |
Enable/disable the frame server for this session.
[in] | flix | Handle to the flix engine returned from Flix2_Create() or Flix2_CreateEx() |
[in] | enable | Enable (on2true ) or disable (on2false ) frame server mode |
ON2_OK | on success | |
ON2_INVALID_PARAMS | should the precondition fail |
NULL
on2false
(disabled) 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.
[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) |
ON2_OK | on success | |
ON2_INVALID_PARAMS | should one or more of the preconditions fail |
NULL