Reduce video size (without quality loss?)

Sorry, but that is (nearly always) bullshit! It’s only possible if you remove unused parts like audio channels or subtitles or if you use of a lossless video compression. All the other ways including a quality loss. The aim should be to get an exceptable relation between the quality and the size.


Parameters

  • Resolution
    The resolution makes a major impact on the required bit rate of a video. It makes no sence to watch a video at a higher resolution then the used screen supports. Streaming server normally let you choose the preferred resolution and/or set it for you to provide a lag less experience.
  • Frame Rate
    The frame rate makes another impact on the required bit rate. Again it makes no sence to watch a movie with a higher frequency then your screen supports, which shouldn’t really happen these days. Most streaming server don’t let you choose between different frame rates.
  • Bit Rate (/ Compression Level)
    The set bit rate will force the codec to a specific level of compression to achieve the goal. The bit rate should match the technical possibilities of the compressor for the preset resolution and frame rate. If the bit rate is to low you will get compression artifacts.

Showcase

The original video has a size of ca. 150 MB and is 10 s long. Let’s try to reduce its size to ca. 6 MB.

  • The original video ▼

    • Link to the video
    • File details ▼
      $ mediainfo vid.mp4
      General
      Complete name                            : vid.mp4
      Format                                   : MPEG-4
      Format profile                           : Base Media / Version 2
      Codec ID                                 : mp42 (mp42/mp41)
      File size                                : 145 MiB
      Duration                                 : 10 s 0 ms
      Overall bit rate                         : 121 Mb/s
      ...
      
      Video
      ID                                       : 1
      Format                                   : AVC
      Format/Info                              : Advanced Video Codec
      Format profile                           : Main@L6.1
      Format settings                          : CABAC / 4 Ref Frames
      Format settings, CABAC                   : Yes
      Format settings, Reference frames        : 4 frames
      Codec ID                                 : avc1
      Codec ID/Info                            : Advanced Video Coding
      Duration                                 : 10 s 0 ms
      Bit rate                                 : 121 Mb/s
      Width                                    : 3 840 pixels
      Height                                   : 2 160 pixels
      Display aspect ratio                     : 16:9
      Frame rate mode                          : Constant
      Frame rate                               : 60.000 FPS
      Color space                              : YUV
      Chroma subsampling                       : 4:2:0
      Bit depth                                : 8 bits
      Scan type                                : Progressive
      Bits/(Pixel*Frame)                       : 0.243
      Stream size                              : 144 MiB (100%)
      ...
      
  • The video with only decreased bit rate ▼

    • Compression details ▼
      $ ffmpeg -i vid.mp4 -b:v 5M -minrate 5M -maxrate 5M vid_cbr5m.mp4
      
    • File details ▼
      $ mediainfo vid_cbr5m.mp4
      General
      Complete name                            : vid_cbr5m.mp4
      Format                                   : MPEG-4
      Format profile                           : Base Media
      Codec ID                                 : isom (isom/iso2/avc1/mp41)
      File size                                : 6.17 MiB
      Duration                                 : 10 s 6 ms
      Overall bit rate mode                    : Variable
      Overall bit rate                         : 5 169 kb/s
      ...
      
      Video
      ID                                       : 1
      Format                                   : AVC
      Format/Info                              : Advanced Video Codec
      Format profile                           : High@L5.2
      Format settings                          : CABAC / 4 Ref Frames
      Format settings, CABAC                   : Yes
      Format settings, Reference frames        : 4 frames
      Codec ID                                 : avc1
      Codec ID/Info                            : Advanced Video Coding
      Duration                                 : 10 s 0 ms
      Bit rate                                 : 5 000 kb/s
      Maximum bit rate                         : 5 157 kb/s
      Width                                    : 3 840 pixels
      Height                                   : 2 160 pixels
      Display aspect ratio                     : 16:9
      Frame rate mode                          : Constant
      Frame rate                               : 60.000 FPS
      Color space                              : YUV
      Chroma subsampling                       : 4:2:0
      Bit depth                                : 8 bits
      Scan type                                : Progressive
      Bits/(Pixel*Frame)                       : 0.010
      Stream size                              : 6.15 MiB (100%)
      ...
      
  • The video with decreased resolution and bit rate ▼

    • Compression details ▼
      $ ffmpeg -i vid.mp4 -vf scale=1920:1080 vid_1080p.mp4
      $ ffmpeg -i vid_1080p.mp4 -b:v 5M -minrate 5M -maxrate 5M vid_1080p_cbr5m.mp4
      
    • File details ▼
      mediainfo vid_1080p_cbr5m.mp4 
      General
      Complete name                            : vid_1080p_cbr5m.mp4
      Format                                   : MPEG-4
      Format profile                           : Base Media
      Codec ID                                 : isom (isom/iso2/avc1/mp41)
      File size                                : 6.07 MiB
      Duration                                 : 10 s 6 ms
      Overall bit rate mode                    : Variable
      Overall bit rate                         : 5 092 kb/s
      ...
      
      Video
      ID                                       : 1
      Format                                   : AVC
      Format/Info                              : Advanced Video Codec
      Format profile                           : High@L4.2
      Format settings                          : CABAC / 4 Ref Frames
      Format settings, CABAC                   : Yes
      Format settings, Reference frames        : 4 frames
      Codec ID                                 : avc1
      Codec ID/Info                            : Advanced Video Coding
      Duration                                 : 10 s 0 ms
      Bit rate                                 : 5 000 kb/s
      Maximum bit rate                         : 5 082 kb/s
      Width                                    : 1 920 pixels
      Height                                   : 1 080 pixels
      Display aspect ratio                     : 16:9
      Frame rate mode                          : Constant
      Frame rate                               : 60.000 FPS
      Color space                              : YUV
      Chroma subsampling                       : 4:2:0
      Bit depth                                : 8 bits
      Scan type                                : Progressive
      Bits/(Pixel*Frame)                       : 0.040
      Stream size                              : 6.06 MiB (100%)
      ...
      
  • The video with decreased resolution, frame rate and bit rate ▼

    • Compression details ▼
      $ ffmpeg -i vid.mp4 -vf "scale=1920:1080,fps=30" vid_1080p_30fps.mp4
      $ ffmpeg -i vid_1080p_30fps.mp4 -b:v 5M -minrate 5M -maxrate 5M vid_1080p_30fps_cbr5m.mp4
      
    • File details ▼
      $ mediainfo vid_1080p_30fps_cbr5m.mp4 
      General
      Complete name                            : vid_1080p_30fps_cbr5m.mp4
      Format                                   : MPEG-4
      Format profile                           : Base Media
      Codec ID                                 : isom (isom/iso2/avc1/mp41)
      File size                                : 6.10 MiB
      Duration                                 : 10 s 6 ms
      Overall bit rate mode                    : Variable
      Overall bit rate                         : 5 117 kb/s
      ...
      
      Video
      ID                                       : 1
      Format                                   : AVC
      Format/Info                              : Advanced Video Codec
      Format profile                           : High@L4
      Format settings                          : CABAC / 4 Ref Frames
      Format settings, CABAC                   : Yes
      Format settings, Reference frames        : 4 frames
      Codec ID                                 : avc1
      Codec ID/Info                            : Advanced Video Coding
      Duration                                 : 10 s 0 ms
      Bit rate                                 : 5 000 kb/s
      Maximum bit rate                         : 5 109 kb/s
      Width                                    : 1 920 pixels
      Height                                   : 1 080 pixels
      Display aspect ratio                     : 16:9
      Frame rate mode                          : Constant
      Frame rate                               : 30.000 FPS
      Color space                              : YUV
      Chroma subsampling                       : 4:2:0
      Bit depth                                : 8 bits
      Scan type                                : Progressive
      Bits/(Pixel*Frame)                       : 0.080
      Stream size                              : 6.09 MiB (100%)
      ...
      
    • Background infos ▼

      There is not so much of a win with reducing the frame rate, cause there are just 10 I-frames in the original video and the other 590 frames are B- and P-frames. (More details)

      $ ffprobe -show_frames vid.mp4 | grep pict_type=I
      ...
      pict_type=I
      pict_type=I
      pict_type=I
      pict_type=I
      pict_type=I
      pict_type=I
      pict_type=I
      pict_type=I
      pict_type=I
      pict_type=I
      

For that huge video size reduction it’s a good idea to also reduce the resolution and the frame rate.