2

I have a video(.mp4) file in my SDCard,I want to reduce a size of .mp4 file and upload this file to a server.

Maroti
  • 501
  • 2
  • 9
  • 25
  • The file size and quality are inversely proportional. Mp4's are already compressed. I don't think there is a way to significantly decrease the file size without loosing quality. – Suragch Mar 13 '15 at 12:49
  • You have any solution for only decrease file size don't worry about a quality. If you have can you share with me. – Maroti Mar 14 '15 at 12:19
  • You want to reduce it programmatically in Android? – Suragch Mar 14 '15 at 12:37
  • Yes, I want to reduce it programmatically in Android. – Maroti Mar 14 '15 at 12:43
  • I haven't done this myself but when I did a google search for "compress video programmatically android" I got lots of results for other people with a similar question. There were a number of suggestions for solutions. Try some of these out. If none of them work then update your question with what you tried and why it didn't work. That may catch the eye of someone who knows how to do it. – Suragch Mar 14 '15 at 12:55
  • did you get any solution? – Pawandeep May 08 '20 at 08:45

1 Answers1

0

One way you can do this is to use ffmpeg.

There are several ways of using ffmpeg in an Android program:

  • use the native libraries directly from c using JNI
  • use a library which provides a wrapper around the 'ffmpeg' cmd line utility (also uses JNI in the wrapper library)
  • call ffmpeg cmd line via 'exec' from within you Android app

Of the three, I personally have used the wrapper approach in the past and found it worked well. IMHO, the documentation and examples available with the native libraries represented quite a steep learning curve.

Note, if you do use 'exec' there are some things it is worth being aware of - see bottom of this answer: https://stackoverflow.com/a/25002844/334402.

The wrapper does have limitations - at heart, the ffmpeg cmd line tool is not intended to be used this way and you have to keep that in mind, but it does work. There is an example project available on github which seems to have a reasonable user base - I did not use it myself but I did refer to it and found it useful, especially for an issue you will find if you need to call your ffmpeg wrapper more than once from the same activity or task:

See this answer (and the questions and answers it is part if) for some more specifics on the 'calling ffmpeg two times' solution:

Community
  • 1
  • 1
Mick
  • 24,231
  • 1
  • 54
  • 120