L
L
l4m3r2019-10-10 17:56:02
Video
l4m3r, 2019-10-10 17:56:02

Why does converting two similar files from mp4 to webm give very different results?

There are 2 similar mp4 files. The same video size, almost the same duration, fps, number of frames, codec. File size too: one 30 (bitrate 1.9M), the other 35 (bitrate 1.3M).
I convert them to webm (vp9). With some parameters - one is compressed, the other is repeatedly increased from 30 mb to 160. (The bitrate of the output file becomes from 1.3M to 9M, although I set b: v 1M). For others, it's the other way around. Why can this happen? How to get similar compression result for both?
On the screen, you can see what different results for 1 and 2 with the same conversion parameters:
sfDwLXm.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
@
@nidalee, 2019-10-10
@l4m3r

First, if your encoder is capable of CRF, CQP and other adaptive bitrates/encoder strategies, you should use them. You can read about encoder strategies (Encoder Strategy \ Rate Control \ and other names of the same) here .
You cannot know what bitrate each individual frame of the video needs, so your attempts to manually specify the bitrate are practically doomed to failure:
1) If the bitrate you specify is lower than what is actually needed, you will get image quality degradation and compression artifacts.
2) If the bitrate you specified is higher than what is actually needed, then the video quality will remain unchanged, but the file will "weigh" more than it could.
Moreover, you specify the bitrate for the entire video, while the variable bitrate may be higher at the beginning of the file (for example, where there is a lot of movement and more bitrate is required), and at the end of the file there may be long static plans - there the bitrate is needed much less .
So since you are using VP9 (WEBM) you should use CRF (Constant Quality):

To trigger this mode, you must use a combination of -crf and -b:v 0. Note that -b:v MUST be 0. Setting it to anything higher or omitting it entirely will instead invoke the Constrained Quality mode.
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 output.webm
The CRF value can be from 0–63. Lower values ​​mean better quality. Recommended values ​​range from 15–35, with 31 being recommended for 1080p HD video.

Since the task did not specify what file size you need, this is the most adequate approach. If you want to compress the file and are ready to put up with quality losses, you need to use Constrained Quality - it works in much the same way, but is additionally limited from above by the bitrate you specified:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 2000k output.webm
The quality is determined by the -crf, and the bitrate limit by the -b:v where the bitrate MUST be non- zero.

In addition, you have CRF - 20, immodest enough for VP9 - this is for 4K without visible quality losses. Are you sure you need this? Look at Google's VP9 guide - for 1080P they suggest setting CRF to 31.
The second file with CRF 30 without bitrate limit almost did not increase. What's in terms of quality? Has it sunk?
I don't know what codec is used in your MP4 source, but if it's HEVC\H.265, then you can conjure more efficient and high-quality compression there, especially if there is a lot of extra time for slow presets or manually tuning them. Such a file after converting to VP9 will inflate for sure.
If the source is H264, then it should almost always compress worse than VP9, ​​which means the problem is in your settings.
In general, other things being equal, files with minimal frame changes compress better than action scenes. That is, if you have 20 minutes of abstract video, 2/3 of which is a static image, it will be easier than 5 minutes of abstract action scene.
Describe or show both videos, and then the picture will surely become clearer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question