How to encode for a specific file size?

  • As the title suggests, I would like to aim for a certain maximum file size while maintaining the best possible image quality.

    Normally, Constant Quantizer is used, but since the video is very long, this is not an option.

    For testing purposes I took 1min (=60sec or 3600frames) video and aim for 10MByte (= 10240KByte = 81920kbit).

    The easiest approach for a certain file size would be CBR

    Audio 256 kbit/s => 256*60 = 15360 kbit

    Video (81920 - 15360)/60 = 1109 kbit/s (encode a little less for being on the safe side, so 1100)

    HVENC (NVIDIA NVENC) then gives me a file with 10.199.040 bytes (9960 KByte) at the end. So far so good.

    But since the bitrate is constant it will not give the best picture quality for 10MByte as a result.

    If I try the whole thing (Video 1100 Audio 256) with VBR I get "something" at the end (23 887 872 bytes)

    I used to use MeGUI, here I can specify a desired file size when encoding and the program will do a 2-pass encoding with VBR in the background. I don't have to specify anything except the file size and the encoder.

    Since I would like to encode on the GPU for speed reasons I try to reproduce the same in Voukoder and fail miserably so far. I am aware that encoding on the GPU gives worse results anyway but then I want to get the best possible results.

    So what would be the best setup to get a specific maximum file size? (I'm working with Magix Vegas Pro 16 if this is of any interest)

  • Yes, in your case CBR and VBR (with a max. bitrate limitation) would be the right choice.

    To increase the quality you'd need the old-school encoder tuning. I'd recommend to start with increase b-frames and reduce the gop. But maybe other users here can provide the optimal and exact settings.

    Help to improve this plugin and support me on patreon or paypal. Thank you.