使用mp4Parser修剪音频。或者有其他选择吗?

时间:2018-06-05 06:34:34

标签: android ffmpeg trim android-ffmpeg mp4parser

我正在尝试使用mp4Parser修剪音频 那可能吗?

我试过ffmpeg这很费时间 我们的应用程序确实需要视频和音频处理。

对此有何建议?

3 个答案:

答案 0 :(得分:1)

ffmpeg很快。你用了什么命令?也许你做了ffmpeg转码,这很慢?

怎么样?
 fmpeg -i audiofile.mp3 -ss 3 -t 5 -acodec copy outfile.mp3

此重新启动从第二个3开始持续5秒进入outfile.mp3,非常快。

答案 1 :(得分:0)

是的,mp4Parser和FFMPEG也可以。 您必须使用一些命令键才能在FFMPEG中加快处理速度。

你可以看看这个库:

k4l-video-trimmer

答案 2 :(得分:0)

是的,可以使用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));
相关问题