扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
图 1. iPod 视频播放器 |
import quicktime.*; import quicktime.io.*; import quicktime.std.image.*; import quicktime.std.movies.media.*; import quicktime.std.movies.*; import quicktime.std.*; import quicktime.qd.*; import quicktime.util.QTPointer; import java.io.*; public class CaptionAdder { public static void main (String args[]) { if (args.length != 1){ System.out.println("Usage: java CaptionAdder [input_filename]"); } else { try { QTSession.open(); System.out.println ("QuickTime version: " + QTSession.getMajorVersion() + "." + QTSession.getMinorVersion()); QTFile qtfile = new QTFile(new File(args[0])); DataRef urlMovie = new DataRef ("file://" + qtfile.getPath()); Movie movie = Movie.fromDataRef (urlMovie,StdQTConstants.newMovieActive); float textTrackHeight = 32; QDRect movieBounds = movie.getNaturalBoundsRect(); float movieWidth = movieBounds.getWidthF(); float movieHeight = movieBounds.getHeightF(); Track textTrack = movie.addTrack(movieWidth, textTrackHeight, 0); Matrix textTrackMatrix = textTrack.getMatrix(); textTrackMatrix.translate (0, movieHeight - textTrackHeight); textTrack.setMatrix (textTrackMatrix); textTrack.setEnabled (true); int movieTimeScale = movie.getTimeScale(); TextMedia textMedia = new TextMedia (textTrack, movieTimeScale); QDRect textBounds = new QDRect (movieWidth, movieHeight); textMedia.beginEdits(); TimeInfo sampleTime = new TimeInfo (0, movie.getDuration()/2); String text = new String ("1234 Main St. - Listing price: $164,000"); TextMediaHandler textMediaHandler = textMedia.getTextHandler(); QTPointer textPointer = new QTPointer ( text.length() + 1, true ); textPointer.copyFromArray ( 0, text.getBytes(), 0, text.length() ); textMediaHandler.addTextSample ( textPointer, QDFont.getFNum("Times"), 16, 0, QDColor.white, QDColor.black, QDConstants.teCenter, textBounds, StdQTConstants.dfClipToTextBox | StdQTConstants.dfKeyedText, 0,0,0, null, sampleTime.duration ); textMedia.endEdits(); textTrack.insertMedia (sampleTime.time, 0, sampleTime.duration, 1 ); OpenMovieFile outStream = OpenMovieFile.asWrite (qtfile); movie.updateResource (outStream, StdQTConstants.movieInDataForkResID, qtfile.getName()); } catch (Exception e) { e.printStackTrace(); QTSession.close(); System.exit(0); } QTSession.close(); // end else } System.out.println ("complete."); //end method } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者