<p>It's easier to notice details in still objects compared to moving ones, so modern codecs save bandwidth by reducing detail during movement. However, this optimization seems far too pronounced to me with the codecs and settings I've tried. The following are cropped screenshots from viewing in VLC, and the person is in the midst of turning their head from screen left to screen right.</p>

<p>Here's the original DVD, MPEG2, 9000 kbps (for the video), 720x480. There's some noise, but the facial expression is clear, even though it's in motion.</p>

<p><img src="https://i.sstatic.net/xptU7.png" alt="original DVD"></p>

<p>The following was encoded from the original with DivX 3.11a low-motion, 2-pass, averaging 1705 kbps (for the video), 432x320. It's a bit fuzzier than the original due to the reduced resolution, but it's faithfully reproducing everything in the frame.</p>

<p><img src="https://i.sstatic.net/8CJr8.png" alt="DivX 3.11a"></p>

<p>The following was encoded from the original with AVC in ffmpeg, averaging 962 kbps (for the video), 720x480. I'm using a CRF of 22 to be a bit higher quality than the AVC default of 23.</p>

<pre><code>ffmpeg -i        in.vob
       -filter:v yadif
       -c:v      libx264
       -crf      22
       -c:a      libopus
       -b:a      64k
       -strict   -2
                 out.mp4
</code></pre>

<p>Static areas are almost as crisp as the original, but areas in motion have been optimized into blocky smudges.</p>

<p><img src="https://i.sstatic.net/cL5LU.png" alt="AVC"></p>

<p>And finally, the following was encoded from the original with HEVC in ffmpeg, averaging 372 kbps (for the video), 720x480. I'm using a CRF of 25 to be a bit higher quality than the HEVC default of 28.</p>

<pre><code>ffmpeg -i        .\in.vob
       -filter:v yadif
       -c:v      libx265
       -crf      25
       -c:a      libopus
       -b:a      64k
       -strict   -2
                 out.mp4
</code></pre>

<p>Faces have been turned into blobs, and this isn't even the worst one in the frame.</p>

<p><img src="https://i.sstatic.net/vSP5N.png" alt="HEVC"></p>

<p>When the encoder tosses out information on certain areas due to the very thing that makes them interesting - motion - the optimization becomes really noticeable. However, I've seen videos encoded in AVC and HEVC that don't suffer from this, maintaining good detail even at ~1000 kbps for 1920x1080. What am I doing wrong, and how do I improve the quality with these modern codecs while still benefiting from reduced file sizes?</p>

CC BY-SA 4.0
2021-09-06T05:15:56.450Z
I've settled on the AVC settings above plus `-tune film` and rescaling to 640x480, and it's pretty okay, but still loses a good deal of detail with motion.
TigerhawkT3
CC BY-SA 4.0
2022-01-06T11:17:15.617Z
Forgot to mention that it needs `-vsync vfr -enc_time_base -1` to preserve the correct duration of each frame, otherwise it'll duplicate some frames and drop others in an attempt to make it match the average frame rate which results in choppiness.
TigerhawkT3
<ffmpeg><libx264><hevc>
How do I compress a video and preserve quality in moving areas?
TigerhawkT3
# How do I compress a video and preserve quality in moving areas?

(Asked by: username_0 on 2019-11-29)

It's easier to notice details in still objects compared to moving ones, so modern codecs save bandwidth by reducing detail during movement. However, this optimization seems far too pronounced to me with the codecs and settings I've tried. The following are cropped screenshots from viewing in VLC, and the person is in the midst of turning their head from screen left to screen right.
Here's the original DVD, MPEG2, 9000 kbps (for the video), 720x480. There's some noise, but the facial expression is clear, even though it's in motion.

The following was encoded from the original with DivX 3.11a low-motion, 2-pass, averaging 1705 kbps (for the video), 432x320. It's a bit fuzzier than the original due to the reduced resolution, but it's faithfully reproducing everything in the frame.

The following was encoded from the original with AVC in ffmpeg, averaging 962 kbps (for the video), 720x480. I'm using a CRF of 22 to be a bit higher quality than the AVC default of 23.
ffmpeg -i        in.vob
       -filter:v yadif
       -c:v      libx264
       -crf      22
       -c:a      libopus
       -b:a      64k
       -strict   -2
                 out.mp4

Static areas are almost as crisp as the original, but areas in motion have been optimized into blocky smudges.

And finally, the following was encoded from the original with HEVC in ffmpeg, averaging 372 kbps (for the video), 720x480. I'm using a CRF of 25 to be a bit higher quality than the HEVC default of 28.
ffmpeg -i        .\in.vob
       -filter:v yadif
       -c:v      libx265
       -crf      25
       -c:a      libopus
       -b:a      64k
       -strict   -2
                 out.mp4

Faces have been turned into blobs, and this isn't even the worst one in the frame.

When the encoder tosses out information on certain areas due to the very thing that makes them interesting - motion - the optimization becomes really noticeable. However, I've seen videos encoded in AVC and HEVC that don't suffer from this, maintaining good detail even at ~1000 kbps for 1920x1080. What am I doing wrong, and how do I improve the quality with these modern codecs while still benefiting from reduced file sizes?

**Tags:** ffmpeg, libx264, hevc

> **Comments:**
> **username_0**: I've settled on the AVC settings above plus `-tune film` and rescaling to 640x480, and it's pretty okay, but still loses a good deal of detail with motion.  
> **username_0**: Forgot to mention that it needs `-vsync vfr -enc_time_base -1` to preserve the correct duration of each frame, otherwise it'll duplicate some frames and drop others in an attempt to make it match the average frame rate which results in choppiness.  

---

## 0 answers

