1

mp4parser を使用して 2 つのビデオを 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));
}
4

1 に答える 1

0

問題は MP4Parser 自体に起因するものだったので、私は FFMpeg に移行しました。そこから動画をうまく組み合わせることができます。

私はデマルチプレクサーを使用しており、後で参照します。これは私が使用したコマンドです:

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

于 2015-05-22T11:37:52.873 に答える