Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg library is too slow to compress the video file. Android [duplicate]

Tags:

android

ffmpeg

I'm using ffmpeg library for video file compression in my Android project.

To implement ffmpeg I refereed this link, but ffmpeg is taking too much time just to compress the video (currently taking 1 min for 6 seconds video). I'm using below command for video compression--

ffmpeg -y -i /sdcard/videokit/in.mp4 -strict experimental -vf transpose=1 -s 160x120 -r 30 -aspect 4:3 -ab 48000 -ac 2 -ar 22050 -b 2097k /sdcard/videokit/out.mp4

Please let me know if it is possible to reduce compression time, may be by changing some setting or parameters in above command. Or is there any other way to compress the video faster than ffmpeg. Thank you.

like image 832
Leo Wiki Avatar asked Dec 29 '25 00:12

Leo Wiki


1 Answers

There aren't many things you can do, but there are certainly a few things worth considering:

  • you can set the -preset value to fast/veryfast/ultrafast
  • you can set the -crf value (usually 18 to 28).
  • The most important thing to note is that if you do not want to alter your audio/video codecs, you should retain the original settings using: -c copy (this can drastically improve the execution time, depending upon your use-case)

Refer this link for preset and crf settings

like image 160
Sarthak Mittal Avatar answered Dec 30 '25 16:12

Sarthak Mittal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!