libquicktime: Reading text

Functions

# Reading text
[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.

## Detailed Description

Decode text.

## Function Documentation

int lqt_text_tracks | ( | quicktime_t * | file ) |

Get the number of text tracks.

Parameters:

  file | A quicktime handle

Returns:
  The number of text tracks found in the file

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

Get the text language.

Parameters:

  file | A quicktime handle
  track | Track index (starting with 0)
  language | Returns 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".

int lqt_text_time_scale | ( | quicktime_t * | file,
|  | int | track
| ) |  |

Get the timescale for a text track.

Parameters:

  file | A quicktime handle
  track | Track index (starting with 0)

Returns:
  The timescale of the 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.

Parameters:

  file | A quicktime handle
  track | Track index (starting with 0)
  top | Returns the top border
  left | Returns the left border
  bottom | Returns the bottom border
  right | Returns the right border

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:

  file | A quicktime handle
  track | Track index (starting with 0)
  text | Address of a buffer
  text_alloc | Allocated bytes for this buffer (will be changed)
  timestamp | Returns the timestamp of the sample
  duration | Returns 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.

int lqt_is_chapter_track | ( | quicktime_t * | file,
|  | int | track
| ) |  |

Check if a track is a chapter track.

Parameters:

  file | A quicktime handle
  track | Track index (starting with 0)

Returns:
  1 if the text track is a chapter track, 0 else

int64_t lqt_text_samples | ( | quicktime_t * | file,
|  | int | track
| ) |  |

Get the total number of text samples.

Parameters:

  file | A quicktime handle
  track | Track index (starting with 0)

Returns:
  The number of samples

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

Go to a specific sample.

Parameters:

  file | A quicktime handle
  track | Track index (starting with 0)
  position | The sample position (starting with 0)

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

Go to a specific time.

Parameters:

  file | A quicktime handle
  track | Track index (starting with 0)
  time | Time

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.

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:

  file | A quicktime handle
  track | Track index (starting with 0)
  r | Returns red
  g | Returns green
  b | Returns blue
  a | Returns alpha

Color values are between 0x0000 and 0xffff.

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:

  file | A quicktime handle
  track | Track index (starting with 0)
  r | Returns red
  g | Returns green
  b | Returns blue
  a | Returns alpha

Color values are between 0x0000 and 0xffff.