我正在尝试使用 mp4Parser修剪音频。
这可能吗?
我尝试了ffmpeg,这非常耗时。
我们的应用程序确实需要视频和音频处理。
对此有什么建议吗?
ffmpeg 很快。 你用了什么命令? 也许你做了FFMPEG转码,这很慢?
怎么样
fmpeg -i audiofile.mp3 -ss 3 -t 5 -acodec copy outfile.mp3
这从第 3 秒开始 5 秒进入outfile.mp3
,非常快。
是的,也可以使用 mp4Parser 和 FFMPEG。 您必须使用一些命令键才能在 FFMPEG 中更快地处理。
你可以看看这个库:
K4L-视频修剪器
是的,可以使用 mp4parser 修剪音频。
它应该是像下面这样
private CroppedTrack getCroppedTrack(Track track, int startTimeMs, int endTimeMs)
{
long currentSample = 0;
double currentTime = 0;
long startSample = -1;
long endSample = -1;
double startTime = startTimeMs / 1000;
double endTime = endTimeMs / 1000;
for (int i = 0; i < track.getSampleDurations().length; i++)
{
if (currentTime <= startTime)
{
// current sample is still before the new starttime
startSample = currentSample;
}
if (currentTime <= endTime) {
// current sample is after the new start time and still before the new endtime
endSample = currentSample;
}
else
{
// current sample is after the end of the cropped video
break;
}
currentTime += (double) track.getSampleDurations()[i] / (double) track.getTrackMetaData().getTimescale();
currentSample++;
}
return new CroppedTrack(track, startSample, endSample);
}
使用上述方法根据您想要的起点和终点修剪轨道。
movie.addTrack(getCroppedTrack(track, 0, 8000));