1

I am trying to trim an audio using mp4Parser.
Is that possible?

I tried ffmpeg which is quite time consuming.
Our app does require both video and audio processing.

Any suggestions on this?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

3 Answers3

1

ffmpeg is fast. What command did you use? maybe you made ffmpeg transcode, which is slow?

What about

 fmpeg -i audiofile.mp3 -ss 3 -t 5 -acodec copy outfile.mp3

This remuxes starting from second 3 for 5 seconds into outfile.mp3, very fast.

micha137
  • 1,195
  • 8
  • 22
0

Yes, possible with mp4Parser and FFMPEG also. You have to use some command key for faster processing in FFMPEG.

You could take a look into this library :

k4l-video-trimmer

0

Yes its possible to trim audio with mp4parser.

It should be something like following

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);
}

Use the above method to trim track/tracks as per your desired start and end points.

movie.addTrack(getCroppedTrack(track, 0, 8000));
Prajyot Tote
  • 670
  • 5
  • 12