我正在使用mp4parser将两个视频添加到一个安卓应用程序中,但是输出是一个我无法使用我的手机或计算机(和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));
}发布于 2015-05-22 11:37:52
由于问题来自MP4Parser本身,所以我转到了FFMpeg,在那里我可以成功地组合视频。
我使用了demuxer和以后的引用;下面是我使用的命令:
"ffmpeg -y -f concat -i temp.txt -c copy output.mp4"
https://stackoverflow.com/questions/30352419
复制相似问题