{"id":6667,"date":"2020-05-04T13:18:22","date_gmt":"2020-05-04T13:18:22","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=6667"},"modified":"2024-02-16T10:13:17","modified_gmt":"2024-02-16T10:13:17","slug":"reduce-bit-rate-without-quality-loss","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=6667","title":{"rendered":"Reduce video size (without quality loss?)"},"content":{"rendered":"<p>Sorry, but that is (nearly always) bullshit! It&#8217;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.<\/p>\n<hr>\n<p><strong>Parameters<\/strong><\/p>\n<ul>\n<li><u>Resolution<\/u><br \/>\nThe 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.<\/li>\n<li><u>Frame Rate<\/u><br \/>\nThe 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&#8217;t really happen these days. Most streaming server don&#8217;t let you choose between different frame rates.<\/li>\n<li><u>Bit Rate<\/u> (\/ Compression Level)<br \/>\nThe 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.<\/li>\n<\/ul>\n<hr>\n<p><strong>Showcase<\/strong><\/p>\n<p>The original video has a size of ca. 150 MB and is 10 s long. Let&#8217;s try to reduce its size to ca. 6 MB.<\/p>\n<ul>\n<li>\n<details>\n<summary>The original video \u25bc<\/summary>\n<p><a href=\"http:\/\/www.max-sperling.bplaced.net\/wp-content\/uploads\/2020\/05\/vid.mp4.jpg\"><img decoding=\"async\" src=\"http:\/\/www.max-sperling.bplaced.net\/wp-content\/uploads\/2020\/05\/vid.mp4-1024x576.jpg\" class=\"aligncenter\" \/><\/a><\/p>\n<ul>\n<li><a href=\"https:\/\/www.vecteezy.com\/video\/1908959-abstract-cool-triangle-science-fiction-3d-illustration-dj-loop\">Link to the video<\/a><\/li>\n<li>\n<details>\n<summary>File details \u25bc<\/summary>\n<pre>\r\n$ mediainfo vid.mp4\r\nGeneral\r\nComplete name                            : vid.mp4\r\nFormat                                   : MPEG-4\r\nFormat profile                           : Base Media \/ Version 2\r\nCodec ID                                 : mp42 (mp42\/mp41)\r\nFile size                                : 145 MiB\r\nDuration                                 : 10 s 0 ms\r\nOverall bit rate                         : 121 Mb\/s\r\n...\r\n\r\nVideo\r\nID                                       : 1\r\nFormat                                   : AVC\r\nFormat\/Info                              : Advanced Video Codec\r\nFormat profile                           : Main@L6.1\r\nFormat settings                          : CABAC \/ 4 Ref Frames\r\nFormat settings, CABAC                   : Yes\r\nFormat settings, Reference frames        : 4 frames\r\nCodec ID                                 : avc1\r\nCodec ID\/Info                            : Advanced Video Coding\r\nDuration                                 : 10 s 0 ms\r\nBit rate                                 : 121 Mb\/s\r\nWidth                                    : 3 840 pixels\r\nHeight                                   : 2 160 pixels\r\nDisplay aspect ratio                     : 16:9\r\nFrame rate mode                          : Constant\r\nFrame rate                               : 60.000 FPS\r\nColor space                              : YUV\r\nChroma subsampling                       : 4:2:0\r\nBit depth                                : 8 bits\r\nScan type                                : Progressive\r\nBits\/(Pixel*Frame)                       : 0.243\r\nStream size                              : 144 MiB (100%)\r\n...\r\n<\/pre>\n<\/details>\n<\/li>\n<\/ul>\n<\/details>\n<\/li>\n<li>\n<details>\n<summary>The video with only decreased bit rate \u25bc<\/summary>\n<p><a href=\"http:\/\/www.max-sperling.bplaced.net\/wp-content\/uploads\/2020\/05\/vid_cbr5m.mp4.jpg\"><img decoding=\"async\" src=\"http:\/\/www.max-sperling.bplaced.net\/wp-content\/uploads\/2020\/05\/vid_cbr5m.mp4-1024x576.jpg\" class=\"aligncenter\" \/><\/a><\/p>\n<ul>\n<li>\n<details>\n<summary>Compression details \u25bc<\/summary>\n<pre>\r\n$ ffmpeg -i vid.mp4 -b:v 5M -minrate 5M -maxrate 5M vid_cbr5m.mp4\r\n<\/pre>\n<\/details>\n<\/li>\n<li>\n<details>\n<summary>File details \u25bc<\/summary>\n<pre>\r\n$ mediainfo vid_cbr5m.mp4\r\nGeneral\r\nComplete name                            : vid_cbr5m.mp4\r\nFormat                                   : MPEG-4\r\nFormat profile                           : Base Media\r\nCodec ID                                 : isom (isom\/iso2\/avc1\/mp41)\r\nFile size                                : 6.17 MiB\r\nDuration                                 : 10 s 6 ms\r\nOverall bit rate mode                    : Variable\r\nOverall bit rate                         : 5 169 kb\/s\r\n...\r\n\r\nVideo\r\nID                                       : 1\r\nFormat                                   : AVC\r\nFormat\/Info                              : Advanced Video Codec\r\nFormat profile                           : High@L5.2\r\nFormat settings                          : CABAC \/ 4 Ref Frames\r\nFormat settings, CABAC                   : Yes\r\nFormat settings, Reference frames        : 4 frames\r\nCodec ID                                 : avc1\r\nCodec ID\/Info                            : Advanced Video Coding\r\nDuration                                 : 10 s 0 ms\r\nBit rate                                 : 5 000 kb\/s\r\nMaximum bit rate                         : 5 157 kb\/s\r\nWidth                                    : 3 840 pixels\r\nHeight                                   : 2 160 pixels\r\nDisplay aspect ratio                     : 16:9\r\nFrame rate mode                          : Constant\r\nFrame rate                               : 60.000 FPS\r\nColor space                              : YUV\r\nChroma subsampling                       : 4:2:0\r\nBit depth                                : 8 bits\r\nScan type                                : Progressive\r\nBits\/(Pixel*Frame)                       : 0.010\r\nStream size                              : 6.15 MiB (100%)\r\n...\r\n<\/pre>\n<\/details>\n<\/li>\n<\/ul>\n<\/details>\n<\/li>\n<li>\n<details>\n<summary>The video with decreased resolution and bit rate \u25bc<\/summary>\n<p><a href=\"http:\/\/www.max-sperling.bplaced.net\/wp-content\/uploads\/2020\/05\/vid_1080p_cbr5m.mp4.jpg\"><img decoding=\"async\" src=\"http:\/\/www.max-sperling.bplaced.net\/wp-content\/uploads\/2020\/05\/vid_1080p_cbr5m.mp4-1024x576.jpg\" class=\"aligncenter\" \/><\/a><\/p>\n<ul>\n<li>\n<details>\n<summary>Compression details \u25bc<\/summary>\n<pre>\r\n$ ffmpeg -i vid.mp4 -vf scale=1920:1080 vid_1080p.mp4\r\n$ ffmpeg -i vid_1080p.mp4 -b:v 5M -minrate 5M -maxrate 5M vid_1080p_cbr5m.mp4\r\n<\/pre>\n<\/details>\n<\/li>\n<li>\n<details>\n<summary>File details \u25bc<\/summary>\n<pre>\r\nmediainfo vid_1080p_cbr5m.mp4 \r\nGeneral\r\nComplete name                            : vid_1080p_cbr5m.mp4\r\nFormat                                   : MPEG-4\r\nFormat profile                           : Base Media\r\nCodec ID                                 : isom (isom\/iso2\/avc1\/mp41)\r\nFile size                                : 6.07 MiB\r\nDuration                                 : 10 s 6 ms\r\nOverall bit rate mode                    : Variable\r\nOverall bit rate                         : 5 092 kb\/s\r\n...\r\n\r\nVideo\r\nID                                       : 1\r\nFormat                                   : AVC\r\nFormat\/Info                              : Advanced Video Codec\r\nFormat profile                           : High@L4.2\r\nFormat settings                          : CABAC \/ 4 Ref Frames\r\nFormat settings, CABAC                   : Yes\r\nFormat settings, Reference frames        : 4 frames\r\nCodec ID                                 : avc1\r\nCodec ID\/Info                            : Advanced Video Coding\r\nDuration                                 : 10 s 0 ms\r\nBit rate                                 : 5 000 kb\/s\r\nMaximum bit rate                         : 5 082 kb\/s\r\nWidth                                    : 1 920 pixels\r\nHeight                                   : 1 080 pixels\r\nDisplay aspect ratio                     : 16:9\r\nFrame rate mode                          : Constant\r\nFrame rate                               : 60.000 FPS\r\nColor space                              : YUV\r\nChroma subsampling                       : 4:2:0\r\nBit depth                                : 8 bits\r\nScan type                                : Progressive\r\nBits\/(Pixel*Frame)                       : 0.040\r\nStream size                              : 6.06 MiB (100%)\r\n...\r\n<\/pre>\n<\/details>\n<\/li>\n<\/ul>\n<\/details>\n<\/li>\n<li>\n<details>\n<summary>The video with decreased resolution, frame rate and bit rate \u25bc<\/summary>\n<p><a href=\"http:\/\/www.max-sperling.bplaced.net\/wp-content\/uploads\/2020\/05\/vid_1080p_30fps_cbr5m.mp4.jpg\"><img decoding=\"async\" src=\"http:\/\/www.max-sperling.bplaced.net\/wp-content\/uploads\/2020\/05\/vid_1080p_30fps_cbr5m.mp4-1024x576.jpg\" class=\"aligncenter\" \/><\/a><\/p>\n<ul>\n<li>\n<details>\n<summary>Compression details \u25bc<\/summary>\n<pre>\r\n$ ffmpeg -i vid.mp4 -vf \"scale=1920:1080,fps=30\" vid_1080p_30fps.mp4\r\n$ ffmpeg -i vid_1080p_30fps.mp4 -b:v 5M -minrate 5M -maxrate 5M vid_1080p_30fps_cbr5m.mp4\r\n<\/pre>\n<\/details>\n<\/li>\n<li>\n<details>\n<summary>File details \u25bc<\/summary>\n<pre>\r\n$ mediainfo vid_1080p_30fps_cbr5m.mp4 \r\nGeneral\r\nComplete name                            : vid_1080p_30fps_cbr5m.mp4\r\nFormat                                   : MPEG-4\r\nFormat profile                           : Base Media\r\nCodec ID                                 : isom (isom\/iso2\/avc1\/mp41)\r\nFile size                                : 6.10 MiB\r\nDuration                                 : 10 s 6 ms\r\nOverall bit rate mode                    : Variable\r\nOverall bit rate                         : 5 117 kb\/s\r\n...\r\n\r\nVideo\r\nID                                       : 1\r\nFormat                                   : AVC\r\nFormat\/Info                              : Advanced Video Codec\r\nFormat profile                           : High@L4\r\nFormat settings                          : CABAC \/ 4 Ref Frames\r\nFormat settings, CABAC                   : Yes\r\nFormat settings, Reference frames        : 4 frames\r\nCodec ID                                 : avc1\r\nCodec ID\/Info                            : Advanced Video Coding\r\nDuration                                 : 10 s 0 ms\r\nBit rate                                 : 5 000 kb\/s\r\nMaximum bit rate                         : 5 109 kb\/s\r\nWidth                                    : 1 920 pixels\r\nHeight                                   : 1 080 pixels\r\nDisplay aspect ratio                     : 16:9\r\nFrame rate mode                          : Constant\r\nFrame rate                               : 30.000 FPS\r\nColor space                              : YUV\r\nChroma subsampling                       : 4:2:0\r\nBit depth                                : 8 bits\r\nScan type                                : Progressive\r\nBits\/(Pixel*Frame)                       : 0.080\r\nStream size                              : 6.09 MiB (100%)\r\n...\r\n<\/pre>\n<\/details>\n<\/li>\n<li>\n<details>\n<summary>Background infos \u25bc<\/summary>\n<p>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. (<a href=\"http:\/\/www.max-sperling.bplaced.net\/?p=6724\">More details<\/a>)<\/p>\n<pre>\r\n$ ffprobe -show_frames vid.mp4 | grep pict_type=I\r\n...\r\npict_type=I\r\npict_type=I\r\npict_type=I\r\npict_type=I\r\npict_type=I\r\npict_type=I\r\npict_type=I\r\npict_type=I\r\npict_type=I\r\npict_type=I\r\n<\/pre>\n<\/details>\n<\/li>\n<\/ul>\n<\/details>\n<\/li>\n<\/ul>\n<p>For that huge video size reduction it&#8217;s a good idea to also reduce the resolution and the frame rate.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sorry, but that is (nearly always) bullshit! It&#8217;s only possible if you remove unused parts like audio channels or subtitles<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[45],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/6667"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6667"}],"version-history":[{"count":1,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/6667\/revisions"}],"predecessor-version":[{"id":16705,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/6667\/revisions\/16705"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6667"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}