<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pavel Dittenbier on Medium]]></title>
        <description><![CDATA[Stories by Pavel Dittenbier on Medium]]></description>
        <link>https://medium.com/@dipaolo?source=rss-72d42ebbbf20------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Kliwb1uKfO-wbS2xSr2LKg@2x.jpeg</url>
            <title>Stories by Pavel Dittenbier on Medium</title>
            <link>https://medium.com/@dipaolo?source=rss-72d42ebbbf20------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 15:18:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dipaolo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[3 Cases from a Video Expert: Encoding Basics]]></title>
            <link>https://medium.com/vicuesoft-techblog/3-cases-from-a-video-expert-encoding-basics-b1ba1c398af8?source=rss-72d42ebbbf20------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1ba1c398af8</guid>
            <category><![CDATA[vidéo]]></category>
            <category><![CDATA[video-quality]]></category>
            <category><![CDATA[expert]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[ffmpeg]]></category>
            <dc:creator><![CDATA[Pavel Dittenbier]]></dc:creator>
            <pubDate>Thu, 25 Jun 2020 15:01:01 GMT</pubDate>
            <atom:updated>2020-06-25T15:01:01.871Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>At <strong>ViCue Soft</strong> (<a href="https://vicuesoft.com/">https://vicuesoft.com</a>) we have a huge amount of expertise in video encoding which we would like to share with you. Starting with this article, we’re launching a series of articles with a number of real and practical usage examples, and we will explain these cases clearly. Please don’t hesitate to ask any questions in the comments below, and feel free to write an email to the author.</p><h3>Basics</h3><p>There are some basics that I would like to start with. These basics will help you to get a clear understanding of the forthcoming articles. I will also introduce some basic terms that we will be using very often, so I would like to make sure that we’re on the same page. Moreover, I will share some handy yet professional tools that will be very useful in our case studies.</p><p>So, let’s get started!</p><p>First of all, let’s introduce the most basic of the basics:</p><p><strong>Encoding</strong> is the process of converting any kind of information to a new form so that it requires much less memory space and, at the same time, it saves (almost) the same amount of information while being <strong>decoded</strong>.</p><p><strong>Video encoding</strong> is encoding of video data, obviously.</p><p>There are two groups of encoding (the <em>almost </em>above is referring exactly to this): <strong>lossless</strong> is when we encode without losing any single byte of the source information, and <strong>lossy</strong> is when some information is lost during the encoding-decoding cycle. How much is lost? It depends on the encoding parameters. We will discuss this later in the article.</p><p>The next load of t terms:</p><p>With the term <strong>codec</strong> we assume a set of agreements as to how exactly we transform the <strong>uncompressed</strong> data to <strong>encoded</strong> data and, vice versa, <strong>decode</strong> them back. In the professional world we call these agreements <strong>standards</strong>. Good examples are: <em>ITU-T H.264</em>, <em>ITU-T H.265</em>, <em>ISO/IEC 11172: Part 2</em> and many others.</p><p><strong>A video encoder</strong> is a piece of software that <strong>encodes</strong> video from an <strong>uncompressed </strong>format to an encoded format. It’s just an implementation of a <strong>codec</strong> according to the standard.</p><p><strong>video decoder</strong> software <strong>decodes</strong> video from the encoded format back to <strong>uncompressed video</strong> data.</p><p><strong>uncompressed video</strong> data is the data taken from a camera or any other device, or stored in any initial form and not being processed. It’s mainly represented in the form of <strong>YUV</strong> files. There are some well-known sets of <strong>uncompressed video streams</strong> that we will use widely in this series of articles.</p><p><strong>Y4M</strong> is a format that is widely used. It’s just a regular <strong>YUV</strong> file but with additional information about width, height, and format inside the file.</p><p>An <strong>uncompressed video stream </strong>is a file with uncompressed video data.</p><p>A <strong>video elementary stream (VES)</strong> is the bitstream (to simplify — a file) <strong>encoded</strong> by a <strong>video encoder</strong>.</p><h3>Tools</h3><p>Let’s get an overview of some software tools that we will use in the series of articles.</p><p><strong>FFmpeg</strong> (<a href="http://ffmpeg.org/">http://ffmpeg.org</a>) is a well-known open source framework, designed to encode and decode video, audio and other multimedia data as well as to perform other multimedia operations, such as streaming, etc.</p><p><strong>The VQ Analyzer</strong> (<a href="https://vicuesoft.com/products/analyzer">https://vicuesoft.com/products/analyzer</a>) is a professional tool for deep analysis of video streams, that supports a wide range of codecs such as VVC, AV1, HEVC, AVC, VP-9 and MPEG-2 Video.</p><p><strong>VQ Probe</strong> (<a href="https://vicuesoft.com/products/probe">https://vicuesoft.com/products/probe</a>) is a professional tool for video quality comparison as well as for video metrics calculation.</p><h3>The 3 cases</h3><p>I hope the introduction was clear to you and we’re now on the same page. Let’s start with the first 3 cases of the week.</p><p>Let’s begin with the following simpler items:</p><ol><li>find an uncompressed file</li><li>encode it with different settings</li><li>compare the outputs</li><li>summarize the results</li></ol><p>First of all, please make sure you have <strong>FFmpeg</strong> installed in your system. To check, just type the following command in your terminal:</p><blockquote>ffmpeg</blockquote><p>If you get something like this:</p><blockquote>ffmpeg version 4.2.2 Copyright © 2000–2019 the FFmpeg developers</blockquote><blockquote>built with Apple clang version 11.0.0 (clang-1100.0.33.16)</blockquote><blockquote>configuration: — prefix=/usr/local/Cellar/ffmpeg/4.2.2_1 — enable-shared — enable-pthreads — enable-version3 — enable-avresample — cc=clang — host-cflags=’-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include/darwin -fno-stack-check’ — host-ldflags= — enable-ffplay — enable-gnutls — enable-gpl — enable-libaom — enable-libbluray — enable-libmp3lame — enable-libopus — enable-librubberband — enable-libsnappy — enable-libtesseract — enable-libtheora — enable-libvidstab — enable-libvorbis — enable-libvpx — enable-libwebp — enable-libx264 — enable-libx265 — enable-libxvid — enable-lzma — enable-libfontconfig — enable-libfreetype — enable-frei0r — enable-libass — enable-libopencore-amrnb — enable-libopencore-amrwb — enable-libopenjpeg — enable-librtmp — enable-libspeex — enable-libsoxr — enable-videotoolbox — disable-libjack — disable-indev=jack</blockquote><blockquote>libavutil 56. 31.100 / 56. 31.100</blockquote><blockquote>libavcodec 58. 54.100 / 58. 54.100</blockquote><blockquote>libavformat 58. 29.100 / 58. 29.100</blockquote><blockquote>libavdevice 58. 8.100 / 58. 8.100</blockquote><blockquote>libavfilter 7. 57.100 / 7. 57.100</blockquote><blockquote>libavresample 4. 0. 0 / 4. 0. 0</blockquote><blockquote>libswscale 5. 5.100 / 5. 5.100</blockquote><blockquote>libswresample 3. 5.100 / 3. 5.100</blockquote><blockquote>libpostproc 55. 5.100 / 55. 5.100</blockquote><blockquote>Hyper fast Audio and Video encoder</blockquote><blockquote>usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…</blockquote><p>then FFmpeg is installed and ready to use on your system.</p><p>We’re now ready to proceed to the first step.</p><p><strong>1. find an uncompressed file</strong></p><p>As mentioned earlier, there are many storages of uncompressed data. I will use <a href="https://media.xiph.org/video/derf/">https://media.xiph.org/video/derf/</a> and a specific file tractor from there.</p><p><strong>2. encode it with different settings</strong></p><p>I have <strong>FFmpeg</strong> already installed on my Mac. If you do not, please follow the instructions at FFmpeg homepage to install it.</p><p>Go to the folder you want the output videos to be saved to. I will use <em>~/streams/raw/</em> as the folder where uncompressed video files are stored for me. Please replace it with your own specific directory.</p><blockquote>ffmpeg -i ~/streams/raw/tractor_1080p25.y4m -c:v libx264 -b:v 100k -frames 300 tractor_1080p25_encoded_100kbps.h264</blockquote><p>Following is a step-by-step guide:</p><p><em>ffmpeg</em> specifies the program that we will use to encode our video.</p><p><em>-i input/tractor_1080p25.y4m</em> sets the input file. In our case this is an uncompressed video.</p><p><em>-c:v libx264</em> means we will encode by using video encoder libx264 which is an implementation of H.264 (aka AVC) codec.</p><p><em>-b:v 100k</em>: this is the essence of the whole article! That parameter sets the encoder to encode with the desired bitrate (100 kilobits per second, or 100 kbps) which means how many bits will be used to get 1 seconds of output video. With this article’s 3 cases we’ll see how that parameter affects the video.</p><p><em>-frames 300</em> means that we will encode only 300 frames. That’s quite enough for us in this article. On the other hand, it will take much less time to encode.</p><p><em>tractor_1080p25_encoded_100kbps.h264</em> is the output file name. I recommend you include specific settings used to encode the file. Later, when you have dozens of encoded files, it will be easier to realize what is specific to a single encoded file.</p><p>Now we will encode 3 cases of the article. That’s the essence of the article. So here we go.</p><h3>Case 1: encode with as much low bitrate as we can imagine — just 100 kbps</h3><blockquote>ffmpeg -i input/tractor_1080p25.y4m -c:v libx264 -b:v 100k -frames 300 tractor_1080p25_encoded_100kbps.h264</blockquote><p>I will demonstrate the example of log output once. All subsequent encodings in this article should be very similar:</p><blockquote>ffmpeg version 4.2.2 Copyright © 2000–2019 the FFmpeg developers</blockquote><blockquote>built with Apple clang version 11.0.0 (clang-1100.0.33.16)</blockquote><blockquote>configuration: — prefix=/usr/local/Cellar/ffmpeg/4.2.2_1 — enable-shared — enable-pthreads — enable-version3 — enable-avresample — cc=clang — host-cflags=’-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include/darwin -fno-stack-check’ — host-ldflags= — enable-ffplay — enable-gnutls — enable-gpl — enable-libaom — enable-libbluray — enable-libmp3lame — enable-libopus — enable-librubberband — enable-libsnappy — enable-libtesseract — enable-libtheora — enable-libvidstab — enable-libvorbis — enable-libvpx — enable-libwebp — enable-libx264 — enable-libx265 — enable-libxvid — enable-lzma — enable-libfontconfig — enable-libfreetype — enable-frei0r — enable-libass — enable-libopencore-amrnb — enable-libopencore-amrwb — enable-libopenjpeg — enable-librtmp — enable-libspeex — enable-libsoxr — enable-videotoolbox — disable-libjack — disable-indev=jack</blockquote><blockquote>libavutil 56. 31.100 / 56. 31.100</blockquote><blockquote>libavcodec 58. 54.100 / 58. 54.100</blockquote><blockquote>libavformat 58. 29.100 / 58. 29.100</blockquote><blockquote>libavdevice 58. 8.100 / 58. 8.100</blockquote><blockquote>libavfilter 7. 57.100 / 7. 57.100</blockquote><blockquote>libavresample 4. 0. 0 / 4. 0. 0</blockquote><blockquote>libswscale 5. 5.100 / 5. 5.100</blockquote><blockquote>libswresample 3. 5.100 / 3. 5.100</blockquote><blockquote>libpostproc 55. 5.100 / 55. 5.100</blockquote><blockquote>Input #0, yuv4mpegpipe, from ‘/Users/dipaolo/streams/raw/tractor_1080p25.y4m’:</blockquote><blockquote>Duration: 00:00:27.60, start: 0.000000, bitrate: 622081 kb/s</blockquote><blockquote>Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(progressive), 1920x1080, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 25 tbn, 25 tbc</blockquote><blockquote>Stream mapping:</blockquote><blockquote>Stream #0:0 -&gt; #0:0 (rawvideo (native) -&gt; h264 (libx264))</blockquote><blockquote>Press [q] to stop, [?] for help</blockquote><blockquote>[libx264 @ 0x7fc268008e00] using SAR=1/1</blockquote><blockquote>[libx264 @ 0x7fc268008e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2</blockquote><blockquote>[libx264 @ 0x7fc268008e00] profile High, level 4.0</blockquote><blockquote>Output #0, h264, to ‘tractor_1080p25_encoded_100kbps.h264’:</blockquote><blockquote>Metadata:</blockquote><blockquote>encoder : Lavf58.29.100</blockquote><blockquote>Stream #0:0: Video: h264 (libx264), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1–1, 100 kb/s, 25 fps, 25 tbn, 25 tbc</blockquote><blockquote>Metadata:</blockquote><blockquote>encoder : Lavc58.54.100 libx264</blockquote><blockquote>Side data:</blockquote><blockquote>cpb: bitrate max/min/avg: 0/0/100000 buffer size: 0 vbv_delay: -1</blockquote><blockquote>frame= 300 fps= 82 q=-1.0 Lsize= 175kB time=00:00:11.92 bitrate= 120.0kbits/s speed=3.27x</blockquote><blockquote>video:175kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] frame I:2 Avg QP:50.99 size: 5304</blockquote><blockquote>[libx264 @ 0x7fc268008e00] frame P:95 Avg QP:51.00 size: 1608</blockquote><blockquote>[libx264 @ 0x7fc268008e00] frame B:203 Avg QP:51.00 size: 76</blockquote><blockquote>[libx264 @ 0x7fc268008e00] consecutive B-frames: 1.3% 15.3% 30.0% 53.3%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] mb I I16..4: 65.9% 34.1% 0.0%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] mb P I16..4: 6.1% 0.2% 0.0% P16..4: 7.6% 0.2% 3.0% 0.0% 0.0% skip:82.9%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.1% 0.0% 0.0% direct: 0.0% skip:99.9% L0: 8.0% L1:92.0% BI: 0.0%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] final ratefactor: 64.30</blockquote><blockquote>[libx264 @ 0x7fc268008e00] 8x8 transform intra:10.7% inter:100.0%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] coded y,uvDC,uvAC intra: 1.0% 6.5% 0.0% inter: 0.0% 0.0% 0.0%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] i16 v,h,dc,p: 89% 9% 1% 0%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 12% 68% 1% 2% 1% 2% 1% 1%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] i8c dc,h,v,p: 100% 0% 0% 0%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] Weighted P-Frames: Y:1.1% UV:1.1%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] ref P L0: 72.9% 0.4% 17.5% 9.2% 0.1%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] ref B L0: 71.9% 3.8% 24.4%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] ref B L1: 89.3% 10.7%</blockquote><blockquote>[libx264 @ 0x7fc268008e00] kb/s:119.19</blockquote><p>If you see something very similar to this in your terminal then congratulations — you’ve just successfully encoded a file!</p><p>As a result we have the newly created file <em>tractor_1080p25_encoded_100kbps.h264</em>. Save it for the future. We will come back to it later.</p><h3>Case 2: trying a much higher bitrate — 1000 kbps (or 1 Mbps) this time</h3><blockquote>ffmpeg -i ~/streams/raw/tractor_1080p25.y4m -c:v libx264 -b:v 1000k -frames 300 tractor_1080p25_encoded_1000kbps_300frames.h264</blockquote><p>Again, save the output for later use.</p><h3>Case 3: the highest point in today’s cases — 10000 kbps (or 10 Mbps)</h3><blockquote>ffmpeg -i ~/streams/raw/tractor_1080p25.y4m -c:v libx264 -b:v 10000k -frames 300 tractor_1080p25_encoded_10000kbps_300frames.h264</blockquote><p>Well, now we have three encoded files with different bitrates:</p><p><em>tractor_1080p25_encoded_100kbps_300frames.h264</em></p><p><em>tractor_1080p25_encoded_1000kbps_300frames.h264</em></p><p><em>tractor_1080p25_encoded_10000kbps_300frames.h264</em></p><p><strong>3. compare the outputs</strong></p><p>Now, when all the encoded files are ready, let’s see how they look and what the difference between them is.</p><p>I recommend you to use <a href="https://vicuesoft.com/products/probe"><strong>VQ Probe</strong></a>, a comprehensive way to visually compare two video files.</p><p>Let’s start with the first two files. I will open them along with the initial uncompressed video file (which is called the <strong>reference video</strong> file).</p><blockquote><strong>Note:</strong> I will not describe usage of the tool in details here. Please follow my <a href="https://medium.com/vicuesoft-techblog/how-to-visualise-and-calculate-video-quality-c3aa43261923">another article</a> for detailed guide and tips.</blockquote><figure><img alt="Tractor movie in different video qualities" src="https://cdn-images-1.medium.com/max/1024/1*zGTs_TtAnha1W9G2_sdHVg.png" /><figcaption><em>tractor_1080p25_encoded_100kbps_300frames.h264 vs. tractor_1080p25_encoded_1000kbps_300frames.h264</em></figcaption></figure><figure><img alt="VQ Probe shows 2 tractor movies encoded with different bitrates" src="https://cdn-images-1.medium.com/max/1024/1*K8SKQ3fgO_K55cyWjMWJjg.png" /><figcaption><em>tractor_1080p25_encoded_100kbps_300frames.h264 vs. tractor_1080p25_encoded_1000kbps_300frames.h264, frame #46</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Q0M_JwXucT-g1gCCyfk5A.png" /><figcaption><em>tractor_1080p25_encoded_100kbps_300frames.h264 vs. tractor_1080p25_encoded_1000kbps_300frames.h264, frame #123</em></figcaption></figure><p>It’s obvious that the right part of the application’s window (that represents the file encoded with 1000 kbps) is much better that the left one (100 kbps). We can easily realize that just by visually looking at images and by playing back the two files simultaneously in <a href="https://vicuesoft.com/products/probe"><strong>VQ Probe</strong></a>.</p><p>Such visual comparison of video files is subjective when done by a human eye. There are several formalized methods and approaches to calculate video quality that use this kind of comparison. They are called <strong>subjective video quality metrics</strong>.</p><p>On the other hand, there is a set of <strong>objective quality metrics</strong>. Such metrics are based on mathematical algorithms and don’t require input from a human eye.</p><p>So, I invite you to take a look at PSNR metric as one of the most used objective video quality metrics. I will use <a href="https://vicuesoft.com/products/probe"><strong>VQ Probe</strong></a> again as a convenient tool to get different kinds of such metrics.</p><p>Here is the result for 100 kbps vs. 1000 kbps in terms of PSNR metric:</p><figure><img alt="PSNR metrics for tractor movie" src="https://cdn-images-1.medium.com/max/1024/1*qUJXMTooEr1hFBRJ7KtXRw.png" /><figcaption>PSNR: Y metric for the file encoded with 100 kbps and the file encoded with 1000 kbps</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sG3GZsOCgXlYoEmdWPY5Qg.png" /><figcaption>VMAF metric for the file encoded with 100 kbps and the file encoded with 1000 kbps</figcaption></figure><p>We see the blue line that represents our 100 kbps video. The green line shows the 1000 kbps file. You may notice a big difference between them. We will come back to it later. Now, let’s refer to the numbers.</p><p>Numbers start with 25.19 dB and 34.8 dB for blue and green curves, respectively.</p><blockquote><strong>Note:</strong> subjective video quality is measured in dB (decibels) and may vary from 0 (the worst quality ever) to 100 (the videos are the same). From here on out, I may skip writing dB after a quality metric value.</blockquote><p>25.19 dB is very low level and unsuitable for real life usage. The number confirms our initial impression of the visual quality.</p><p>34.8 dB usually means quite acceptable quality. Again, we’ve seen the same when we look at the resulting video for the first time.</p><p>Here I should clarify why I said <em>usually</em>. This is because the numbers corresponding to good quality may vary depending on different factors, such as video resolution, content of the video, specific encoding parameters, etc. We will cover all these cases later in our series.</p><p>So, returning back to our PSNR numbers. We see that PSNR values vary during the videos: they go up and down, then up again and so on. The average numbers are about 22 dB and 30 dB for 100 kpbs file and 1000 kbps file, respectively.</p><p>As for the difference between green and blue lines. Let’s refer to the tab called <em>L/R Quality Diff</em>:</p><figure><img alt="PSNR difference of 2 video files with different bitrates" src="https://cdn-images-1.medium.com/max/1024/1*idKjj-aYBAwIdH3ChYWcRQ.png" /><figcaption>The difference of PSNR: Y between the file encoded with 100 kbps and the file encoded with 1000 kbps</figcaption></figure><p>Here we can see the exact difference in PSNR values on every single frame. We can spot the minimal difference at frame number 19, which is 3.14 dB, while the maximum is placed at frame number 250 and the value equals 13.85 dB.</p><p>We can say that on average our encoded file with the bitrate of 1000 kbps is better than the encoded file with 100 kbps for about 8 dB. Which is, in fact, a very good result for the file encoded with 1000 kbps.</p><p>Let’s do the same comparison of the next two pairs: 1 Mbps and 10 Mbps. This comparison will contain fewer of my comments, since you already know enough to understand the things happening behind the scenes.</p><p>I will show you the results with just short comments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rv1VuD2RLKaKHY0F_1ZHsQ.png" /><figcaption><em>tractor_1080p25_encoded_1000kbps_300frames.h264 vs. tractor_1080p25_encoded_10000kbps_300frames.h264</em></figcaption></figure><figure><img alt="Zoomed in green tractor cabin" src="https://cdn-images-1.medium.com/max/1024/1*qsZocoueVP9gk4z5F-l6Nw.png" /><figcaption><em>tractor_1080p25_encoded_1000kbps_300frames.h264 vs. tractor_1080p25_encoded_10000kbps_300frames.h264, frame #88</em></figcaption></figure><p>As for the PSNR value, here they are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvuaWHCb5doNjsLTa7n_4w.png" /><figcaption>PSNR: Y metric for the file encoded with 1000 kbps and the file encoded with 10000 kbps</figcaption></figure><p>VMAF values are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1WzzkFJtbIj1_rgbVkunw.png" /><figcaption>VMAF metric for the file encoded with 1000 kbps and the file encoded with 10000 kbps</figcaption></figure><p>As you may see, it’s about 30 dB for 1000 kbps as we noticed before, and 40 dB for the file with the highest bitrate in our examples.</p><p>A quick look at difference of PSNR values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VvApix-f_RF3UxqfAUBq6A.png" /><figcaption>The difference of PSNR: Y between the file encoded with 1000 kbps and the file encoded with 10000 kbps</figcaption></figure><p>It’s around 10 dB difference between the 1 Mbps and the 10 Mbps file, which is a huge difference in fact.</p><p>The visual difference between 1 Mbps and 10 Mbps exists for sure, but it’s not so huge as we’ve seen for 100 kbps vs. 1 Mbps before.</p><p>Here is, by the way, the visual difference between 100 kbps and 10000 kbps (100 times difference!):</p><figure><img alt="Green tractor cabin encoded with very bad and normal qualities" src="https://cdn-images-1.medium.com/max/1024/1*2sSfFwPGqzrz1dqHIF9zdQ.png" /><figcaption><em>tractor_1080p25_encoded_100kbps_300frames.h264 vs. tractor_1080p25_encoded_10000kbps_300frames.h264</em></figcaption></figure><p><strong>4. summarize the results</strong></p><p>I will put everything into one table to cover all the results at once:</p><figure><img alt="A table showing bitrate-quality correlation" src="https://cdn-images-1.medium.com/max/659/1*uit_TtVVIWKxt40LnE1BeQ.png" /><figcaption>Summarized results</figcaption></figure><p>Nice. We have well-formed results. Let’s summarize.</p><p>1. The visual subjective quality of the 3 encoded files is as follows: the first file was encoded with 100 kbps and looked to be of a very bad quality. Objective quality confirms that with the value of 22 dB, which is very low. The next encoded file, with 1 Mbps bitrate, is of acceptable quality, not great. 30 dB of measured quality echoes the result we’ve seen visually. And the last encoded file, as expected, demonstrates the best quality: both the subjective and objective metrics say the same.</p><p>2. Ten times higher bitrate gives only about 35% of quality improvements. That looks insane, doesn’t it? Is it bad? Is it normal? Keep calm. We’ll review encoding in much more detail in upcoming articles.</p><p>Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1ba1c398af8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vicuesoft-techblog/3-cases-from-a-video-expert-encoding-basics-b1ba1c398af8">3 Cases from a Video Expert: Encoding Basics</a> was originally published in <a href="https://medium.com/vicuesoft-techblog">vicuesoft-techblog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HOW TO Visualise and Calculate Video Quality]]></title>
            <link>https://medium.com/vicuesoft-techblog/how-to-visualise-and-calculate-video-quality-c3aa43261923?source=rss-72d42ebbbf20------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3aa43261923</guid>
            <category><![CDATA[psnr]]></category>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[vmaf]]></category>
            <category><![CDATA[video-quality]]></category>
            <category><![CDATA[yuv]]></category>
            <dc:creator><![CDATA[Pavel Dittenbier]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 16:49:59 GMT</pubDate>
            <atom:updated>2020-06-03T16:49:59.872Z</atom:updated>
            <content:encoded><![CDATA[<p>I hope you are doing well nowadays, and staying safe at home 😷</p><p>Today I’m going to talk about video. Nope, not about Game of Thrones :) or any of these funny cat videos that we all love so much. We will be talking today about video quality in simple words, to make it easier for everyone to understand.</p><p>The first part of the article could be interesting for everyone and it will explain to you the basics of video quality and bitrate.</p><p>The second part is more specific, and more for people who are involved in the video industry. But I guess that could be interesting for other people, too.</p><p>It’s really difficult to talk about video without any kind of images. So, the <a href="https://vicuesoft.com/products/probe"><strong>VQ Probe</strong></a><strong> </strong>will be assisting me in this article. This is a brand-new product made by <a href="https://vicuesoft.com/">ViCue Soft</a> that allows you to analyze video quality, and provides a convenient way to compare two videos side-by-side in a split window and to compare source and encoded videos, as well as displaying video quality metrics.</p><p>So, first of all, I have to say the obvious thing: not all videos have the same quality. It can vary so much depending on many factors, such as:</p><ul><li>source quality: such as when you upload your old 90&#39;s VHS-based videos on YouTube</li><li>encoding quality: when you choose the wrong settings in OBS while streaming a video game to Twitch</li><li>slow network connection: when you’re on a streaming platform and you’re watching the latest episode of your favourite series, watching with as low a quality as your connection can pump through, just to make sure you’re able to watch the video at all in the first place.</li></ul><p>First things first, let’s prepare test samples that will be used in the article. We will do it by using <strong>FFmpeg</strong>. I will attach all the command lines here, so you’ll be able to do the same on your own. We will create a few sample video encoded files from the same source video, but in different bitrates. If you already have video files to get metrics for, just take them without creating any of the new ones.</p><p>So here is how I’m gonna create the first file:</p><blockquote>$ ffmpeg -i tractor_1080p25_300frames.y4m -c:v libx264 -b:v 500k -frames 300 tractor_1080p25_300frames_encoded_500kbps.h264</blockquote><p>Here we encode the input source uncompressed video file <em>tractor_1080p25.y4m</em> to the <em>output tractor_1080p25_encoded_100kbps.h264</em> using H.264/AVC codec with the bitrate 500 kbps.</p><p>Next, we will do the same for the second one:</p><blockquote>$ ffmpeg -i tractor_1080p25_300frames.y4m -c:v libx264 -b:v 5000k -frames 300 tractor_1080p25_300frames_encoded_5000kbps.h264</blockquote><p>As you may guess, we have just encoded the same source file with 5 Mbps using the same H.264/AVC codec.</p><p>Now we have 3 files. Let’s take a look on their sizes:</p><p>tractor_1080p25_300frames.y4m — 933&#39;121&#39;860 bytes</p><p>tractor_1080p25_300frames_encoded_500kbps.h264–779&#39;142 bytes</p><p>tractor_1080p25_300frames_encoded_5000kbps.h264–7&#39;281&#39;894 bytes</p><p>In other words, we have compressed the source file in 1198 times and in 128 times for 500 kbps and 5 Mbps, respectively.</p><p>Looks good. But what about quality? Let’s take a look.</p><p>As I already mentioned, we will use the <strong>VQ Probe</strong> for the purpose of video quality metrics calculation, as well as to visualise these metrics.</p><p>You can download the appropriate version for your operating system from the official site — <a href="https://vicuesoft.com/products/probe">https://vicuesoft.com/products/probe</a>. The tool is available for Windows, MacOS, and Linux. It’s absolutely free and does not require installation. So you can get it working very quickly by repeating the steps from the article.</p><p>I’m launching the tool and I see the main screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vxWyXoqRkttr_18X.png" /><figcaption>VQ Probe: the Main Window</figcaption></figure><p>It’s pretty simple yet powerful, and does exactly what we need in the scope of this article.</p><p>At the next step we will add files. We can easily drag &amp; drop them on the main area as a text on the main window mentions, but we will do the same via the main menu to make it clearer to show here.</p><p>By opening the <strong>File</strong> menu we can see the following options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/0*xv3tmxTzsY6elWyn.png" /><figcaption>File menu options</figcaption></figure><p>You may see a lot of convenient options here depending on the user’s needs. What we currently need is the 4th one — <strong>Open Pair… </strong>Click on it, and then choose the two encoded files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*6892epdL0feWQpDj.png" /><figcaption>Choosing files dialog</figcaption></figure><p>Please make sure you choose the appropriate filter to display files of required types. I’m using the <strong>All Supported Video Files</strong> option.</p><p>Click <strong>Open,</strong> and voila:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X37g88NheXpOm3r2.png" /><figcaption>The two files split by a vertical line</figcaption></figure><p>Now we can compare the two files in convenient way by moving the vertical split-line and using different zoom options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/0*-nKcWrtMZdBaiFJM.png" /><figcaption>View menu options</figcaption></figure><p>Now, I’m going to highlight the visual differences of the two encoded files. To do so, let’s press the <strong>Play</strong> button. Both files are playing back. Then we wait until the difference is distinct, and press the <strong>Space</strong> button (to pause the playback). Here is what we’ve got:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMU1Cr73N3PMQMfrsOJ4KA.png" /><figcaption>The quality difference on frame #35</figcaption></figure><p>Let’s use <strong>Cmd + left mouse key</strong> to zoom in on a specific area and the difference becomes even more obvious:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eNQ6WfR_xfmFb7B6.png" /><figcaption>Zoom at x3.37</figcaption></figure><p>The difference is so visible, isn’t it? As a reminder: the left video is 500 kbps and the right one is 5 Mbps.</p><p>Everything we were talking about before is called subjective quality metrics. In other words, it can vary depending on a person, monitor settings and so on. There are another group of metrics, called objective quality metrics. They are based on mathematical calculation of the difference between one video and another (in most cases this is a source video and an encoded video).</p><p>So, let’s check how objective metrics correspond to subjective metrics. To do so, we need to add a <strong>reference file</strong>, a file we have created encoded files from. In our case it is <em>tractor_1080p25_300frames.y4m</em>.</p><blockquote>Note: generally, a reference file is a YUV file, or uncompressed video files. But the <strong>VQ Probe</strong> allows you to choose any supported video files, e.g. another encoded video. For example, if you want to compare H.264/AVC and H.265/HEVC quality, you can choose an AVC file as a reference, and an HEVC file as a target.</blockquote><p>We will open the reference file via the <strong>File</strong> menu again, but will choose the <strong>Open Reference…</strong> option for now. In the case of Y4M files, the file will be automatically opened as long as such files contain all the required information about an uncompressed video. Otherwise, in the case of YUV files, you will be asked to set width, height, and pixel format for the file in a specific dialog box. Finally, you’ll see that the reference files are opened by seeing information about the file, such as filename, and its characteristics placed on the top of the window. You can always show the reference file in the main window by pressing the <strong>Shift</strong> button. This is a useful feature when comparing an encoded video with the reference video.</p><p>So, we have 3 opened files, therefore the <strong>Run</strong> button in <strong>Metrics View</strong> (at the bottom of the window) becomes enabled. Clicking on it will launch the metrics calculation process. Once it’s done, the metrics are available in <strong>Metrics View</strong>. There are 3 metrics supported by the <strong>VQ Probe</strong>: PSNR, SSIM, and VMAF. Here is what we’ve got in our case:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yx3Oqq-HUYC1Hmaysq1ySw.png" /><figcaption>PSNR of Y component</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hoxR0QjY4hHkdoxjibTaVA.png" /><figcaption>SSIM for V component</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jsbc2UrXCp-yns7iuW2vlQ.png" /><figcaption>VMAF metric</figcaption></figure><p>The higher the value, the better the quality. It’s obvious from the graphs above that the video file on the right (encoded with 5 Mbps) has better quality than the one on the left side (encoded with 500 kbps). Let’s see the exact difference by choosing another tab, <strong>L/R Quality Diff</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*quQd7kh6k98zrqexfKVfUg.png" /><figcaption>PSNR difference for Y component</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NnBSnFk7b4TNV5h7PCgPvg.png" /><figcaption>SSIM difference for Y component</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rpVvw0EcvIBSNFmoCFsOEA.png" /><figcaption>VMAF difference for Y component</figcaption></figure><p>Well, it’s easy to see that the file encoded with 5 Mbps has much better quality than the file encoded with 500 kbps.</p><p>All the graphs confirm the conclusion we have made by visual evaluation earlier. Great! That’s exactly what we were looking for. 👍</p><p>That was a quick introduction to video quality metrics. We discovered how to check the both objective and subjective video quality of two video files by using the <a href="https://vicuesoft.com/products/probe"><strong>VQ Probe</strong></a> tool. I did not go into details here, but a related series of articles about video quality are coming soon. So,</p><p>stay tuned! ✌️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3aa43261923" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vicuesoft-techblog/how-to-visualise-and-calculate-video-quality-c3aa43261923">HOW TO Visualise and Calculate Video Quality</a> was originally published in <a href="https://medium.com/vicuesoft-techblog">vicuesoft-techblog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>