mp4parse 游戏中时光倒流帧率

mp4parse timelapse frame rate

我正在尝试提取 mp4 文件并将其设为延时摄影。它适用于下面附带的代码。但是,输出文件的帧速率为 16*originalFrameRate。由于我不打算将其作为 slow motion 视频播放,因此我宁愿删除那些冗余帧以使输出文件更小。

Movie inputMovie = MovieCreator.build(fileUri);

List<Track> videoTracks = new LinkedList<>();

for (Track track : inputMovie.getTracks()) {
    if (track.getHandler().equals("vide")) {
        videoTracks.add(track);
    }
}

final int speedByFactorOf = 16;

Movie outputMovie = new Movie();

AppendTrack appendedTracks = new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()]));
outputMovie.addTrack(new WrappingTrack(appendedTracks) {
    @Override
    public long[] getSampleDurations() {
        long[] l = super.getSampleDurations();
        for (int i = 0; i < l.length; i++) {
            l[i] /= speedByFactorOf;
        }
        return l;
    }
});

BasicContainer out = (BasicContainer) new DefaultMp4Builder().build(outputMovie);

FileChannel fc = new RandomAccessFile("timelapse.mp4", "rw").getChannel();
out.writeContainer(fc);
fc.close();
out.close();

我找不到任何有关如何更改输出帧速率的示例。

如@tarun-lalwani 所述,如果您所指的项目是 https://github.com/sannies/mp4parser then it is only able to edit the MP4 container and NOT the video / audio / media etc. held within the container. Even if you could use metadata to accelerate the FPS by sixteen times, the file size would not become any smaller because all the frames would still be within the file (just shown for a shorter duration). You would need to use something like FFmpeg (e.g. via https://github.com/bramp/ffmpeg-cli-wrapper ) 或其他一些程序化视频编辑器来执行您所描述的操作,因此仅保留视频的第 16 帧,因此视频文件实际上变小了。

TLDR; mp4parser 不是编辑视频的正确项目(与元数据相反),您想要实现的目标听起来超出了摆弄容器的范围。