Video streaming addon
- ALLEGRO_VIDEO_EVENT_TYPE
- al_open_video
- al_close_video
- al_start_video
- al_start_video_with_voice
- al_get_video_event_source
- al_pause_video
- al_is_video_paused
- al_get_video_aspect_ratio
- al_get_video_audio_rate
- al_get_video_fps
- al_get_video_width
- al_get_video_height
- al_get_video_frame
- al_get_video_position
- al_seek_video
These functions are declared in the following header file. Link with allegro_video.
#include <allegro5/allegro_video.h>
Currently we have an ffmpeg backend and a Ogg backend (Theora + Vorbis). The choice is fixed at compile time. See http://ffmpeg.org/ and http://xiph.org/ for installation instructions, licensing information and supported video formats.
ALLEGRO_VIDEO_EVENT_TYPE
enum ALLEGRO_VIDEO_EVENT_TYPE
- ALLEGRO_EVENT_VIDEO_FRAME_ALLOC
- ALLEGRO_EVENT_VIDEO_FRAME_SHOW
Since: 5.1.0
al_open_video
ALLEGRO_VIDEO *al_open_video(char const *filename)
Reads a video file. This does not start streaming yet but reads the meta info so you can query e.g. the size or audio rate.
Since: 5.1.0
al_close_video
void al_close_video(ALLEGRO_VIDEO *video)
Closes the video and frees all allocated resources. The video pointer is invalid after the function returns.
Since: 5.1.0
al_start_video
void al_start_video(ALLEGRO_VIDEO *video, ALLEGRO_MIXER *mixer)
Starts streaming the video from the beginning.
Since: 5.1.0
al_start_video_with_voice
void al_start_video_with_voice(ALLEGRO_VIDEO *video, ALLEGRO_VOICE *voice)
Like al_start_video but audio is routed to the provided voice.
Since: 5.1.0
al_get_video_event_source
ALLEGRO_EVENT_SOURCE *al_get_video_event_source(ALLEGRO_VIDEO *video)
Get an event source for the video. The possible events are described under ALLEGRO_VIDEO_EVENT_TYPE.
Since: 5.1.0
al_pause_video
void al_pause_video(ALLEGRO_VIDEO *video, bool paused)
Paused or resumes playback.
Since: 5.1.0
al_is_video_paused
bool al_is_video_paused(ALLEGRO_VIDEO *video)
Returns true if the video is currently paused.
Since: 5.1.0
al_get_video_aspect_ratio
double al_get_video_aspect_ratio(ALLEGRO_VIDEO *video)
Returns the aspect ratio of the video. Videos often do not use square pixels so you should always check the aspect ratio before displaying video frames.
Returns zero or negative value if the aspect ratio is unknown.
Since: 5.1.0
al_get_video_audio_rate
double al_get_video_audio_rate(ALLEGRO_VIDEO *video)
Returns the audio rate of the video, in Hz.
Since: 5.1.0
al_get_video_fps
double al_get_video_fps(ALLEGRO_VIDEO *video)
Returns the speed of the video in frames per second. Often this will not be an integer value.
Since: 5.1.0
al_get_video_width
int al_get_video_width(ALLEGRO_VIDEO *video)
Returns the number of pixel raw pixel columns in the video stream. Multiply this with the aspect ratio to get the true width.
Since: 5.1.0
See also: al_get_video_aspect_ratio
al_get_video_height
int al_get_video_height(ALLEGRO_VIDEO *video)
Returns the number of rows in the video. Typically this will be 720 or 1080.
Since: 5.1.0
al_get_video_frame
ALLEGRO_BITMAP *al_get_video_frame(ALLEGRO_VIDEO *video)
Returns the current video frame. The bitmap is owned by the video so do not attempt to free it. The bitmap will stay valid until the next call to al_get_video_frame.
Since: 5.1.0
al_get_video_position
double al_get_video_position(ALLEGRO_VIDEO *video, int which)
Returns the current position of the video stream in seconds since the beginning. The parameter has the following meaning:
- 0: Return the actual position.
- 1: Return the video decoding position. If this lags behind video decoding is taking too long and the video can't be displayed properly.
- 2: Return the audio decoding position. Audio gets easily out of sync for some reason - but this addon does not provide any means to do much about it.
Since: 5.1.0
al_seek_video
bool al_seek_video(ALLEGRO_VIDEO *video, double pos_in_seconds)
Seek to a different position in the video. Right now this does not work very well in the ffmpeg backend when seeking backwards and will often lose audio/video synchronization if doing so.
Since: 5.1.0