Track textTrack;
try
{
textTrack = movie.addTrack(TEXT_TRACK_WIDTH, TEXT_TRACK_HEIGHT, 0);
Media textMedia = new TextMedia(textTrack, movie.getTimeScale());
TextMediaHandler handler = (TextMediaHandler)textMedia.getHandler();
textMedia.beginEdits();
byte[] msgBytes = text.getBytes();
QTPointer msgPoint = new QTPointer(msgBytes);
handler.addTextSample(msgPoint, QDFont.getFNum(fontName), fontSize, style,
new QDColor(fgColor[0] / 255f, fgColor[1] / 255f, fgColor[2] / 255f),
new QDColor(bgColor[0] / 255f, bgColor[1] / 255f, bgColor[2] / 255f),
QDConstants.teJustLeft, textBox, dfFlag, QDFont.getFNum(fontName), 0, 0,
QDColor.white, Math.round(duration * movie.getTimeScale()));
textMedia.endEdits();