QtlMovie 1.12 (A specialized FFmpeg front-end)
QtlSubRipGenerator Class Reference

Generate subtitles in SubRip format (aka SRT). More...

Public Member Functions

 QtlSubRipGenerator (const QString &fileName=QString())
 Constructor. More...
 
 QtlSubRipGenerator (QTextStream *stream)
 Constructor. More...
 
 ~QtlSubRipGenerator ()
 Destructor. More...
 
void addFrame (quint64 showTimestamp, quint64 hideTimestamp, const QStringList &lines)
 Add a multi-lines subtitle frame. More...
 
void addFrame (quint64 showTimestamp, quint64 hideTimestamp, const QString &line)
 Add a one-line subtitle frame. More...
 
void close ()
 Close the generator. More...
 
int frameCount () const
 Get the number of generated frames fo far. More...
 
bool isOpen ()
 Check if the generator is open and ready to output frames. More...
 
bool open (const QString &fileName)
 Open or re-open the generator to a new file. More...
 
bool setStream (QTextStream *stream)
 Open or re-open the generator to a new text stream. More...
 

Static Public Member Functions

static QString formatDuration (quint64 showTimestamp, quint64 hideTimestamp)
 Format a duration as SRT header. More...
 
static QString formatTime (quint64 timestamp)
 Format a timestamp as SRT time. More...
 

Private Member Functions

void configureStream ()
 Configure the output stream. More...
 

Private Attributes

int _frameCount
 Number of output frames. More...
 
QFile _outputFile
 Output file descriptor. More...
 
QTextStream _outputStream
 Text stream for output file. More...
 
QTextStream * _stream
 Output text stream. More...
 

Detailed Description

Generate subtitles in SubRip format (aka SRT).

Constructor & Destructor Documentation

◆ QtlSubRipGenerator() [1/2]

QtlSubRipGenerator::QtlSubRipGenerator ( const QString &  fileName = QString())
explicit

Constructor.

Parameters
[in]fileNameOptional output file name. If non-empty, the file is created and open. Use isOpen() to check if the file was correctly created.

◆ QtlSubRipGenerator() [2/2]

QtlSubRipGenerator::QtlSubRipGenerator ( QTextStream *  stream)
explicit

Constructor.

Parameters
[in]streamOutput text stream. The generator is considered "open" if stream is not zero.

◆ ~QtlSubRipGenerator()

QtlSubRipGenerator::~QtlSubRipGenerator ( )

Destructor.

Member Function Documentation

◆ open()

bool QtlSubRipGenerator::open ( const QString &  fileName)

Open or re-open the generator to a new file.

The previous file is closed.

Parameters
[in]fileNameOutput file name.
Returns
True if the file was correctly created and open, false otherwise.

◆ setStream()

bool QtlSubRipGenerator::setStream ( QTextStream *  stream)

Open or re-open the generator to a new text stream.

The previous file is closed.

Parameters
[in]streamOutput text stream.
Returns
True if stream is not zero, false otherwise.

◆ close()

void QtlSubRipGenerator::close ( )

Close the generator.

◆ isOpen()

bool QtlSubRipGenerator::isOpen ( )
inline

Check if the generator is open and ready to output frames.

◆ addFrame() [1/2]

void QtlSubRipGenerator::addFrame ( quint64  showTimestamp,
quint64  hideTimestamp,
const QStringList &  lines 
)

Add a multi-lines subtitle frame.

Parameters
[in]showTimestampShow frame at this timestamp (in ms from start of stream)
[in]hideTimestampHide frame at this timestamp (in ms from start of stream)
[in]linesText lines.

◆ addFrame() [2/2]

void QtlSubRipGenerator::addFrame ( quint64  showTimestamp,
quint64  hideTimestamp,
const QString &  line 
)
inline

Add a one-line subtitle frame.

Parameters
[in]showTimestampShow frame at this timestamp (in ms from start of stream)
[in]hideTimestampHide frame at this timestamp (in ms from start of stream)
[in]lineText line.

◆ frameCount()

int QtlSubRipGenerator::frameCount ( ) const
inline

Get the number of generated frames fo far.

Returns
The number of generated frames fo far.

◆ formatTime()

QString QtlSubRipGenerator::formatTime ( quint64  timestamp)
static

Format a timestamp as SRT time.

Parameters
[in]timestampTimestamp in milliseconds.
Returns
SRT formatted time.

◆ formatDuration()

QString QtlSubRipGenerator::formatDuration ( quint64  showTimestamp,
quint64  hideTimestamp 
)
static

Format a duration as SRT header.

Parameters
[in]showTimestampShow frame at this timestamp (in ms from start of stream)
[in]hideTimestampHide frame at this timestamp (in ms from start of stream)
Returns
SRT formatted duration.

◆ configureStream()

void QtlSubRipGenerator::configureStream ( )
private

Configure the output stream.

Member Data Documentation

◆ _outputFile

QFile QtlSubRipGenerator::_outputFile
private

Output file descriptor.

◆ _outputStream

QTextStream QtlSubRipGenerator::_outputStream
private

Text stream for output file.

◆ _stream

QTextStream* QtlSubRipGenerator::_stream
private

Output text stream.

◆ _frameCount

int QtlSubRipGenerator::_frameCount
private

Number of output frames.


The documentation for this class was generated from the following files: