-1

I am building an application in which I need to trim videos. It is possible to do this using ffmpeg, but I can't use it because it uses the gpl license.

I tried using mediaCodec but can't use the codes I found.

How can i trim videos on android?

Vitor Ferreira
  • 1,075
  • 1
  • 14
  • 28

1 Answers1

2

I had to develop trim functionality into my app a few months back and found that FFMPEG is very heavy and wasn't as accurate as MediaCodec.

None of the examples helped me but as I was developing in Kotlin I had to rewrite it anyway.

Here is the breakdown of how to use MediaCodec:

  1. Pass the file to your mediacodec class
  2. Extract the video from a file
  3. Create your buffer size
  4. Seek to where you want to file to be trimmed from or to
  5. Mux your audio and video together

We tried to find a way to do the start and finish times together but we ended up just duplicating the clip first and passing both in with a start and and end time.

You'll need to post your code and show where you're having the issue with MediaCodec for people to help you.

AngryCubeDev
  • 155
  • 2
  • 16