首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mp4parser旋转和保存视频

mp4parser旋转和保存视频
EN

Stack Overflow用户
提问于 2014-03-10 22:27:03
回答 1查看 2.1K关注 0票数 0

我需要在我的Android项目中将视频旋转90度。我在谷歌上搜索了一下,找到了可以与安卓系统集成的mp4parser。视频存储在设备上,也将保存在设备上(不确定是否使用不同的名称,但这并不重要)。以下是我使用的代码(使用isoviewer-1.0-RC-35制作),但如果需要,我可以将库更改为2.0版:

代码语言:javascript
复制
try 
{
    String inputVideoName = "path_to_a_video";

    IsoFile out =  new IsoFile(inputVideoName);
    out.getMovieBox().getMovieHeaderBox().setMatrix(Matrix.ROTATE_90);

    File outputVideoName = new File("path_to_a_saved_processed_video");
    if (!outputVideoName.exists())
        outputVideoName.createNewFile();

    FileOutputStream fos = new FileOutputStream(outputVideoName);
    out.writeContainer(fos.getChannel());
    fos.close();
    out.close();
} 
catch (IOException e) {
    Log.e("test", "some exception", e);
}

代码编译、运行、保存视频,但使用原始旋转,因此不会对其进行任何更改。怎么了?

EN

回答 1

Stack Overflow用户

发布于 2015-04-16 14:54:10

这有帮助吗?另外,你不认为你应该使用Isoparser而不是Isoviewer吗?

代码语言:javascript
复制
package com.googlecode.mp4parser;

import com.googlecode.mp4parser.authoring.Movie;
import com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder;
import com.googlecode.mp4parser.authoring.container.mp4.MovieCreator;
import com.googlecode.mp4parser.util.Matrix;

import java.io.FileOutputStream; 
import java.io.IOException;


public class Rotate {
public static void main(String[] args) throws IOException {

    String f1 = AppendExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/1365070268951.mp4";

    Movie inMovie = MovieCreator.build(f1);
    inMovie.setMatrix(Matrix.ROTATE_90);

    new DefaultMp4Builder().build(inMovie).writeContainer(new FileOutputStream("output.mp4").getChannel());
}
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22302907

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档