Generate subtitles in SubRip format (aka SRT).
More...
#include <tsSubRipGenerator.h>
|
| | SubRipGenerator (const fs::path &fileName=UString(), Report &report=(ts::NullReport::Instance())) |
| | Constructor.
|
| |
| | SubRipGenerator (std::ostream *stream) |
| | Constructor.
|
| |
|
| ~SubRipGenerator () |
| | Destructor.
|
| |
| template<class Rep1 , class Period1 , class Rep2 , class Period2 > |
| void | addFrame (const cn::duration< Rep1, Period1 > &showTimestamp, const cn::duration< Rep2, Period2 > &hideTimestamp, const UString &line) |
| | Add a one-line subtitle frame.
|
| |
| template<class Rep1 , class Period1 , class Rep2 , class Period2 > |
| void | addFrame (const cn::duration< Rep1, Period1 > &showTimestamp, const cn::duration< Rep2, Period2 > &hideTimestamp, const UStringList &lines) |
| | Add a multi-lines subtitle frame.
|
| |
|
void | close () |
| | Close the generator.
|
| |
| int | frameCount () const |
| | Get the number of generated frames fo far.
|
| |
| bool | isOpen () |
| | Check if the generator is open and ready to output frames.
|
| |
| bool | open (const fs::path &fileName, Report &report=(ts::NullReport::Instance())) |
| | Open or re-open the generator to a new file.
|
| |
| bool | setStream (std::ostream *stream) |
| | Open or re-open the generator to a new text stream.
|
| |
|
| template<class Rep1 , class Period1 , class Rep2 , class Period2 > |
| static UString | FormatDuration (const cn::duration< Rep1, Period1 > &showTimestamp, const cn::duration< Rep2, Period2 > &hideTimestamp) |
| | Format a duration as SRT header.
|
| |
| template<class Rep , class Period > |
| static UString | FormatTime (const cn::duration< Rep, Period > ×tamp) |
| | Format a timestamp as SRT time.
|
| |
Generate subtitles in SubRip format (aka SRT).
◆ SubRipGenerator() [1/2]
Constructor.
- Parameters
-
| [in] | fileName | Optional output file name. If non-empty, the file is created and open. Use isOpen() to check if the file was correctly created. |
| [in,out] | report | Where to report errors. |
◆ SubRipGenerator() [2/2]
| ts::SubRipGenerator::SubRipGenerator |
( |
std::ostream * |
stream | ) |
|
|
explicit |
Constructor.
- Parameters
-
| [in] | stream | Output text stream. The generator is considered "open" if stream is not zero. |
◆ open()
Open or re-open the generator to a new file.
The previous file is closed.
- Parameters
-
| [in] | fileName | Output file name. |
| [in,out] | report | Where to report errors. |
- Returns
- True if the file was correctly created and open, false otherwise.
◆ setStream()
| bool ts::SubRipGenerator::setStream |
( |
std::ostream * |
stream | ) |
|
Open or re-open the generator to a new text stream.
The previous file is closed.
- Parameters
-
| [in] | stream | Output text stream. |
- Returns
- True if stream is not zero, false otherwise.
◆ isOpen()
| bool ts::SubRipGenerator::isOpen |
( |
| ) |
|
|
inline |
Check if the generator is open and ready to output frames.
- Returns
- True if the generator is open and ready.
◆ addFrame() [1/2]
template<class Rep1 , class Period1 , class Rep2 , class Period2 >
| void ts::SubRipGenerator::addFrame |
( |
const cn::duration< Rep1, Period1 > & |
showTimestamp, |
|
|
const cn::duration< Rep2, Period2 > & |
hideTimestamp, |
|
|
const UStringList & |
lines |
|
) |
| |
Add a multi-lines subtitle frame.
- Parameters
-
| [in] | showTimestamp | Show frame at this timestamp (from start of stream) |
| [in] | hideTimestamp | Hide frame at this timestamp (from start of stream) |
| [in] | lines | Text lines. |
◆ addFrame() [2/2]
template<class Rep1 , class Period1 , class Rep2 , class Period2 >
| void ts::SubRipGenerator::addFrame |
( |
const cn::duration< Rep1, Period1 > & |
showTimestamp, |
|
|
const cn::duration< Rep2, Period2 > & |
hideTimestamp, |
|
|
const UString & |
line |
|
) |
| |
|
inline |
Add a one-line subtitle frame.
- Parameters
-
| [in] | showTimestamp | Show frame at this timestamp (from start of stream) |
| [in] | hideTimestamp | Hide frame at this timestamp (from start of stream) |
| [in] | line | Text line. |
◆ frameCount()
| int ts::SubRipGenerator::frameCount |
( |
| ) |
const |
|
inline |
Get the number of generated frames fo far.
- Returns
- The number of generated frames fo far.
◆ FormatTime()
template<class Rep , class Period >
| static UString ts::SubRipGenerator::FormatTime |
( |
const cn::duration< Rep, Period > & |
timestamp | ) |
|
|
static |
Format a timestamp as SRT time.
- Parameters
-
| [in] | timestamp | Timestamp in milliseconds. |
- Returns
- SRT formatted time.
◆ FormatDuration()
template<class Rep1 , class Period1 , class Rep2 , class Period2 >
| static UString ts::SubRipGenerator::FormatDuration |
( |
const cn::duration< Rep1, Period1 > & |
showTimestamp, |
|
|
const cn::duration< Rep2, Period2 > & |
hideTimestamp |
|
) |
| |
|
inlinestatic |
Format a duration as SRT header.
- Parameters
-
| [in] | showTimestamp | Show frame at this timestamp (in ms from start of stream) |
| [in] | hideTimestamp | Hide frame at this timestamp (in ms from start of stream) |
- Returns
- SRT formatted duration.
The documentation for this class was generated from the following file: