I want to reduce the size of a video size. The video may be .flv, .avi, etc. I want it done from the terminal. How can I do that?

1 Answer 1


This should start with a caveat, that transcoding between lossy media formats will generally involve loss of quality.

There are lots of options here:

  • Convert older formats (MPEG-1, DivX 3 etc) to newer and more efficient codecs (eg x264, theora) which will generally mostly preserve video/audio quality in a smaller output.

  • Reduce the target bitrate or target output size, improving size at the cost of reproduction quality.

  • Reduce the video dimensions, allowing similar reproduction quality at lower total size.

Unless you have strong reasons for another choice, x264 for video and aac for audio in an mp4 container is a good choice for quality and reasonably wide compatibility (but you should encode something short and try it on anything you'll want to play it on - getting widely playable transcoded results remains an exercise in witchcraft).

I find the current command serves me fairly well for converting older formats:

avconv -y -i INPUT -pre:v libx264-slower -b:a 96k -c:v libx264 -c:a libvo_aacenc OUTPUT.mp4

You can scale down the image size by adding -vf scale=iw*0.5:ih*0.5 before the output name, or set a video bitrate -b:v, or play with multi-pass options... but mostly the above will produce a reasonable outcome.

  • On 16.04 "Preset libx264-slower specified for stream 0:0, but could not be opened."
    – HilarieAK
    Oct 31, 2017 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.