Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I use ffmpeg to reduce the size of a video by lowering the quality (as minimally as possible, naturally, but I need it to run on a mobile device that doesn't have much available space)?

I forgot to write one thing yet. When the video can use subtitles (*.srt or *.sub) I'd like to convert them too to fit the parameters of converted video file.

share|improve this question
I haven't used it but the ffmpeg man page shows a -fs option to limit the output size, does something like ffmpeg -i in.avi -fs 100M out.avi work? –  Kevin Jan 10 '12 at 23:41
I will not redirect you to the man page: man ffmpeg | wc -l --> 5254 –  user13742 Jan 11 '12 at 0:11
The .avi is not the main issue.. avi is just a container. The main issue is which codecs you use.. Many (most?) .avi vids use older style codecs (eg XviD) which are fine, but are larger for the same quality when compared to the later generation of codecs .. You can typically get a tight encoding by using the H.264 video compression standard (eg. codecx264) and aac compression for audio.. The container and codecs you use is up to you and your phone... The .mp4 container is well accepted.. (but can your phone handle it: see this link –  Peter.O Jan 11 '12 at 1:16
@Kevin This wants more parameters for conversion. –  xralf Jan 11 '12 at 8:34
@hesse What does it mean? –  xralf Jan 11 '12 at 8:36

2 Answers 2

See this answer. Quoted below for convenience:

Calculate the bitrate you need by dividing 1 GB by the video length in seconds. So, for a video of length 16:40 (1000 seconds), use a bitrate of 1000000 bytes/sec:

ffmpeg -i input.mp4 -b 1000000 output.mp4

Additional options that might be worth considering is setting the Constant Rate Factor, which lowers the average bit rate, but retains better quality. Vary the CRF between around 18 and 24 — the lower, the higher the bitrate.

ffmpeg -i input.mp4 -vcodec libx264 -crf 20 output.mp4
share|improve this answer
The video of size 338 MB was reduced on size 130 MB. The quality rapidly lowered. Is there some explanation for this process? The original author doesn't explain his guidline. –  xralf May 11 '12 at 7:41
Another thing are the subtitles. I don't want them to embed, but I'd like the new srt or sub file to fit the new converted video. –  xralf May 11 '12 at 7:42
You could try a higher bit-rate, or maybe experiment with the Constant Rate Factor the original author talks about. Other than that, I'm sorry, but I don't have much knowledge of ffmpeg. I was able to answer only because I've wanted to compress videos with ffmpeg in the past and had come across that answer. –  Vicky Chijwani May 11 '12 at 9:16
Thanks, your answer shifts the question closer to the solution. I will leave it open for some time yet. –  xralf May 11 '12 at 9:24

As far as I know, there are mainly two methods to shrink MKV video file size:

Method one: Compress MKV by converting MKV to MP4, AVI, 3GP or other video formats

In the same video quality situation, the MKV file size is much larger than other video formats like MP4. To shrink MKV without loss of video quality, we may convert MKV to MP4, 3GP, AVI and etc. If you do not want to change the video format, you may refer to Method two.

Method two: Shrink MKV by adjusting MKV video bit rate, resolution, frame rate etc

This method helps to resize MKV files to get a good balance of quality and file size. And you may choose to compress MKV as well as keep the MKV as the output video format. You may also choose to shrink and convert MKV to other video format.

Detailed guide at http://www.idealshare.net/video-converter/mkv-compressor.html

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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