当前位置: 首页>>代码示例>>Java>>正文


Java CroppedTrack类代码示例

本文整理汇总了Java中com.googlecode.mp4parser.authoring.tracks.CroppedTrack的典型用法代码示例。如果您正苦于以下问题:Java CroppedTrack类的具体用法?Java CroppedTrack怎么用?Java CroppedTrack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CroppedTrack类属于com.googlecode.mp4parser.authoring.tracks包,在下文中一共展示了CroppedTrack类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: crop

import com.googlecode.mp4parser.authoring.tracks.CroppedTrack; //导入依赖的package包/类
private boolean crop() {
  try {
    // オリジナル動画を読み込み
    String filePath = Environment.getExternalStorageDirectory() + "/sample1.mp4";
    Movie originalMovie = MovieCreator.build(filePath);

    // 分割
    Track track = originalMovie.getTracks().get(0);
    Movie movie = new Movie();
    movie.addTrack(new AppendTrack(new CroppedTrack(track, 200, 400)));

    // 出力
    Container out = new DefaultMp4Builder().build(movie);
    String outputFilePath = Environment.getExternalStorageDirectory() + "/output_crop.mp4";
    FileOutputStream fos = new FileOutputStream(new File(outputFilePath));
    out.writeContainer(fos.getChannel());
    fos.close();
  } catch (Exception e) {
    e.printStackTrace();
    return false;
  }
  return true;
}
 
开发者ID:suwa-yuki,项目名称:Mp4ParserSample,代码行数:24,代码来源:MainActivity.java

示例2: startTrim

import com.googlecode.mp4parser.authoring.tracks.CroppedTrack; //导入依赖的package包/类
public static void startTrim(File src, File dst, double startTime, double endTime) throws IOException {
    FileDataSourceImpl file = new FileDataSourceImpl(src);
    Movie movie = MovieCreator.build(file);
    List<Track> tracks = movie.getTracks();
    movie.setTracks(new LinkedList<Track>());

    Log.d(TAG, "startTrim: " + startTime + " " + endTime);
    for (Track track : tracks) {
        long currentSample = 0;
        double currentTime = 0;
        long startSample = -1;
        long endSample = -1;
        for (int i = 0; i < track.getSampleDurations().length; i++) {
            if (currentTime <= startTime) {

                // current sample is still before the new starttime
                startSample = currentSample;
            }
            if (currentTime <= endTime) {
                // current sample is after the new start time and still before the new endtime
                endSample = currentSample;
            } else {
                // current sample is after the end of the cropped video
                break;
            }
            currentTime += (double) track.getSampleDurations()[i] / (double) track.getTrackMetaData().getTimescale();
            currentSample++;
        }
        movie.addTrack(new CroppedTrack(track, startSample, endSample));
    }
    Container out = new DefaultMp4Builder().build(movie);
    MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
    mvhd.setMatrix(Matrix.ROTATE_180);
    if (!dst.exists()) {
        dst.createNewFile();
    }
    FileOutputStream fos = new FileOutputStream(dst);
    WritableByteChannel fc = fos.getChannel();
    try {
        out.writeContainer(fc);
    }catch (Exception e){
        e.printStackTrace();
    } finally {
        fc.close();
        fos.close();
        file.close();
    }
}
 
开发者ID:stfalcon-studio,项目名称:patrol-android,代码行数:49,代码来源:ProcessVideoUtils.java


注:本文中的com.googlecode.mp4parser.authoring.tracks.CroppedTrack类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。