libquicktime
Reading text

Decode text. More...

Functions

int lqt_text_tracks (quicktime_t *file)
 Get the number of text tracks.
 
int lqt_get_text_language (quicktime_t *file, int track, char *language)
 Get the text language.
 
int lqt_text_time_scale (quicktime_t *file, int track)
 Get the timescale for a text track.
 
void lqt_get_text_box (quicktime_t *file, int track, uint16_t *top, uint16_t *left, uint16_t *bottom, uint16_t *right)
 Set the text box of a text track.
 
int lqt_read_text (quicktime_t *file, int track, char **text, int *text_alloc, int64_t *timestamp, int64_t *duration)
 Read a text sample.
 
int lqt_is_chapter_track (quicktime_t *file, int track)
 Check if a track is a chapter track.
 
int64_t lqt_text_samples (quicktime_t *file, int track)
 Get the total number of text samples.
 
void lqt_set_text_position (quicktime_t *file, int track, int64_t position)
 Go to a specific sample.
 
void lqt_set_text_time (quicktime_t *file, int track, int64_t time)
 Go to a specific time.
 
void lqt_get_text_fg_color (quicktime_t *file, int track, uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *a)
 Get the foreground color of a text track.
 
void lqt_get_text_bg_color (quicktime_t *file, int track, uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *a)
 Get the background color of a text track.
 
int64_t lqt_get_text_pts_offset (quicktime_t *file, int track)
 Get an video pts offset.
 

Detailed Description

Decode text.

Function Documentation

◆ lqt_text_tracks()

int lqt_text_tracks ( quicktime_t * file)

Get the number of text tracks.

Parameters
fileA quicktime handle
Returns
The number of text tracks found in the file

◆ lqt_get_text_language()

int lqt_get_text_language ( quicktime_t * file,
int track,
char * language )

Get the text language.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
languageReturns ISO-639 Language code
Returns
1 on success, 0 on error.

The language code is a 3-character code, English is "eng", Japanese is "jpn".

◆ lqt_text_time_scale()

int lqt_text_time_scale ( quicktime_t * file,
int track )

Get the timescale for a text track.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
Returns
The timescale of the track.

◆ lqt_get_text_box()

void lqt_get_text_box ( quicktime_t * file,
int track,
uint16_t * top,
uint16_t * left,
uint16_t * bottom,
uint16_t * right )

Set the text box of a text track.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
topReturns the top border
leftReturns the left border
bottomReturns the bottom border
rightReturns the right border

◆ lqt_read_text()

int lqt_read_text ( quicktime_t * file,
int track,
char ** text,
int * text_alloc,
int64_t * timestamp,
int64_t * duration )

Read a text sample.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
textAddress of a buffer
text_allocAllocated bytes for this buffer (will be changed)
timestampReturns the timestamp of the sample
durationReturns the duration of the sample
Returns
1 if a sample was decoded, 0 if the track is finished

This funtion calls realloc() to make sure there is enough space for for the text. It's a good idea to always pass the same buffer to this function (set to NULL initially) and free it after the file is closed.

◆ lqt_is_chapter_track()

int lqt_is_chapter_track ( quicktime_t * file,
int track )

Check if a track is a chapter track.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
Returns
1 if the text track is a chapter track, 0 else

◆ lqt_text_samples()

int64_t lqt_text_samples ( quicktime_t * file,
int track )

Get the total number of text samples.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
Returns
The number of samples

◆ lqt_set_text_position()

void lqt_set_text_position ( quicktime_t * file,
int track,
int64_t position )

Go to a specific sample.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
positionThe sample position (starting with 0)

◆ lqt_set_text_time()

void lqt_set_text_time ( quicktime_t * file,
int track,
int64_t time )

Go to a specific time.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
timeTime

This wil reposition the text track such, that the next call to lqt_read_text will return a sample with at least the timestamp you specified.

◆ lqt_get_text_fg_color()

void lqt_get_text_fg_color ( quicktime_t * file,
int track,
uint16_t * r,
uint16_t * g,
uint16_t * b,
uint16_t * a )

Get the foreground color of a text track.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
rReturns red
gReturns green
bReturns blue
aReturns alpha

Color values are between 0x0000 and 0xffff.

◆ lqt_get_text_bg_color()

void lqt_get_text_bg_color ( quicktime_t * file,
int track,
uint16_t * r,
uint16_t * g,
uint16_t * b,
uint16_t * a )

Get the background color of a text track.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
rReturns red
gReturns green
bReturns blue
aReturns alpha

Color values are between 0x0000 and 0xffff.

◆ lqt_get_text_pts_offset()

int64_t lqt_get_text_pts_offset ( quicktime_t * file,
int track )

Get an video pts offset.

Parameters
fileA quicktime handle
trackTrack index (starting with 0)
Returns
PTS offset of the subtitles (in timescale units)