Friday, 4 December 2015

All You Need to Compress Videos on Android

Warning: Compressing videos on android devices can take a long time.

Download and install the FFmpeg Media Encoder from Google Play

Here's an example screenshot:



It's pretty straight forward to use. Select an input file then an output file and format. Next you'll want to select a template or create your own.
My templates:
240p veryfast (mp4):
-vf scale='-2:240' -preset veryfast -strict -2
360p veryfast (mp4):
-vf scale='-2:360' -preset veryfast -strict -2
480p veryfast (mp4):
-vf scale='-2:480' -preset veryfast -strict -2
720p veryfast (mp4):
-vf scale='-2:720' -preset veryfast -strict -2
1080p veryfast (mp4):
-vf scale='-2:1080' -preset veryfast -strict -2
veryfast (mp4):
-preset veryfast -strict -2
Explanation of the options I used.

-vf scale='-2:240' -vf stands for video filter and the video filter we are applying is scale='-2:240'. The -2 automatically calculates the width based on the height to an even number. If we used -1 instead of -2 it would calculate it to the exact whole number but this could result in an error because the codec (we didn't specify a codec, but the default for mp4 is H.264) we are using has to have even numbers for width and height. The 240 is pretty straight forward; it sets the height of the video to 240 pixels.

-preset veryfast -preset option is to set a preset for H.264 encoding. The general guideline is to use the slowest preset that you have patience for which will lead to a smaller file size. Current presets in descending order of speed are: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow. The default preset is medium.

-strict -2 -strict experimental or -strict -2 option is needed to encode audio to aac.

No comments:

Post a Comment