<p>I'm using guide provided at <a href="https://trac.ffmpeg.org/wiki/Encode/H.264#twopass" rel="nofollow noreferrer">this</a> page to compress videos to specific size with ffmpeg. The sizes I'm aiming are relatively small (8mb wanted compared to 50mb original) and when I'm trying to compress video by inputting the calculated bitrate according to the guide into ffmpeg the result sometimes overshoots the target size and it's not fine for me. One solution could probably be to target sizes smaller (-0.5mb from wanted), but that's not really what I want it to be.</p>
<p>I assume that some bit of file is dedicated to store some metadata which is not important for me. My strategy is to guess what the size of that metadata will be and target the wanted size minus the size of metadata.</p>
<p>Of course, there could be something else that may increase filesize. So, the question is, how to compress video with ffmpeg to target size with more precision?</p>

CC BY-SA 4.0
2022-03-04T09:11:51.673Z
Encoding to a specific size is hard, sometimes, data is just not more compressabale than it is already. Try to aim below the bitrate that you want. If it doesn't at all want to go lower, you'll have to lower resolution, bitdepth or framerate
Timothy Lukas H.
CC BY-SA 4.0
2022-03-04T10:57:48.373Z
@TimothyLukasH. It does go lower when I aim for lower sizes, so it's definitely compressable.
Anton
CC BY-SA 4.0
2022-03-05T16:37:59.213Z
Then you'll have to just set a lower target. There's no way to foce VBR to a specific size. Otherwise you'll have to use CBR (Constant Bitrate) but that may be negative on image quality.
Timothy Lukas H.
CC BY-SA 4.0
2022-03-07T02:55:13.320Z
Quality is not that much of a deal, honestly. I'm fine with that.
Anton
<ffmpeg><mp4>
Compressing video to specific size accurately
Anton
# Compressing video to specific size accurately

(Asked by: username_0 on 2022-03-03)

I'm using guide provided at [this](https://trac.ffmpeg.org/wiki/Encode/H.264#twopass) page to compress videos to specific size with ffmpeg. The sizes I'm aiming are relatively small (8mb wanted compared to 50mb original) and when I'm trying to compress video by inputting the calculated bitrate according to the guide into ffmpeg the result sometimes overshoots the target size and it's not fine for me. One solution could probably be to target sizes smaller (-0.5mb from wanted), but that's not really what I want it to be.

I assume that some bit of file is dedicated to store some metadata which is not important for me. My strategy is to guess what the size of that metadata will be and target the wanted size minus the size of metadata.

Of course, there could be something else that may increase filesize. So, the question is, how to compress video with ffmpeg to target size with more precision?

**Tags:** ffmpeg, mp4

> **Comments:**
> **username_1**: Encoding to a specific size is hard, sometimes, data is just not more compressabale than it is already. Try to aim below the bitrate that you want. If it doesn't at all want to go lower, you'll have to lower resolution, bitdepth or framerate  
> **username_0**: @TimothyLukasH. It does go lower when I aim for lower sizes, so it's definitely compressable.  
> **username_1**: Then you'll have to just set a lower target. There's no way to foce VBR to a specific size. Otherwise you'll have to use CBR (Constant Bitrate) but that may be negative on image quality.  
> **username_0**: Quality is not that much of a deal, honestly. I'm fine with that.  

---

## 0 answers

