Java MP4Parser创建损坏的mp4

Java MP4Parser创建损坏的mp4,java,android,video,mp4,mp4parser,Java,Android,Video,Mp4,Mp4parser,我正在使用mp4parser在android应用程序中添加两个视频,但输出的是一个文件,我无法用手机或电脑Windows Media Player和VLC播放。这是我使用的函数 public void MergeVideos(String[] pathsToVideos, String pathToOutput) throws IOException, InterruptedException { List<Track> tracks = new LinkedList<

我正在使用mp4parser在android应用程序中添加两个视频,但输出的是一个文件,我无法用手机或电脑Windows Media Player和VLC播放。这是我使用的函数

public void MergeVideos(String[] pathsToVideos, String pathToOutput) throws IOException, InterruptedException
{
    List<Track> tracks = new LinkedList<Track>();
    Movie outputVideo = new Movie();

    for (int i = 0; i < pathsToVideos.length; i++)
    {
        Movie video = MovieCreator.build(pathsToVideos[i]);
        List<Track> trackss = video.getTracks();   
        for (Track track : trackss) 
        {
            if (track.getHandler().equals("vide"))
            {
                tracks.add(track);
            }
        }
    }

    outputVideo.addTrack(new AppendTrack(tracks.toArray(new Track[tracks.size()])));
    Container out = new DefaultMp4Builder().build(outputVideo);

    File outputFile = new File(pathToOutput);

    if(!outputFile.exists())
    {
        outputFile.createNewFile();
    }

    //write mp4 file
    FileChannel fc = new RandomAccessFile(String.format(pathToOutput), "rw").getChannel();
    out.writeContainer(fc);
    fc.close();

    //Add to the android media gallery so i can see it on my computer
    addToGallery(new File(pathToOutput));
}

由于问题来自MP4Parser本身,我转而使用FFMpeg,从中我可以成功地组合视频

我使用了demuxer,供以后参考;这是我使用的命令:


ffmpeg-y-f concat-i temp.txt-c copy output.mp4

令人遗憾的是,Mp4Parser产生了损坏的文件。