Skip to content

Commit 2821106

Browse files
authored
Vp8 (#97)
* Adding some vp8 tests, still a WIP. Signed-off-by: [email protected] <[email protected]> * We dont actually need the yml file for a still. Signed-off-by: [email protected] <[email protected]> * Remove irrevelant table. Signed-off-by: [email protected] <[email protected]> * Fix links Signed-off-by: [email protected] <[email protected]> * Updated VP9 section Signed-off-by: [email protected] <[email protected]> * Adding very basic rav1e test. Signed-off-by: [email protected] <[email protected]> * Minor update to rav1, in testing its not great. Signed-off-by: [email protected] <[email protected]> * Update with arnr-strength. Signed-off-by: [email protected] <[email protected]> * Minor tweaks to vp8 setup. Signed-off-by: Sam Richards <[email protected]> * -qscale 3 does not map to 90% compression. Signed-off-by: [email protected] <[email protected]> * Adding a graph for preset. Signed-off-by: [email protected] <[email protected]> * Added a codec web test page to test a variety of codecs. Signed-off-by: [email protected] <[email protected]> * Fixes to make it legal html. Signed-off-by: [email protected] <[email protected]> * Make sure the labels are right. Signed-off-by: [email protected] <[email protected]> * Adding more tests, that were used in the ASWF open source days presentation. Signed-off-by: [email protected] <[email protected]> * Add a note about alpha for vp9. Signed-off-by: [email protected] <[email protected]> * Add a crf value for the quickstart. Signed-off-by: [email protected] <[email protected]> * Adding VP8 Docs. Signed-off-by: [email protected] <[email protected]> * Changing the preset to 5 from 9, addresses some artifacts. Signed-off-by: [email protected] <[email protected]> * Defining the column ordering of the graphs. Signed-off-by: [email protected] <[email protected]> --------- Signed-off-by: [email protected] <[email protected]> Signed-off-by: Sam Richards <[email protected]> Co-authored-by: [email protected] <[email protected]>
1 parent 0e325f3 commit 2821106

File tree

82 files changed

+5645
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+5645
-59
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,5 @@ enctests/sources/enc_sources/chimera_wind
144144
enctests/results.old
145145
tmp
146146
enctests/wedge_results
147+
framerate/circle_grad/jpg
148+
framerate/circle_grad/png

EncodeAv1.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ It has a more limited support for pix-formats currently only supporting: yuv420p
3636

3737
Supported pixel formats: yuv420p yuv420p10le
3838

39-
Color modes -
40-
41-
| main | 8 or 10 bit | 4:2:0 |
42-
| high | 8 or 10 bit | 4:2:0 or 4:4:4 |
43-
| professional | 8 or 10 or 12 bit | 4:2:0 4:2:2 or 4:4:4 |
44-
4539
Example encoding:
4640

4741
<!---
@@ -59,15 +53,15 @@ comparisontest:
5953
-->
6054
```
6155
ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -frames:v 200 -c:v libsvtav1 \
62-
-pix_fmt yuv420p10le -crf 18 -preset 9 -svtav1-params tune=0 -sws_flags lanczos \
56+
-pix_fmt yuv420p10le -crf 18 -preset 5 -svtav1-params tune=0 -sws_flags lanczos \
6357
-vf "scale=in_range=full:in_color_matrix=bt709:out_range=tv:out_color_matrix=bt709" \
6458
-color_range tv -colorspace bt709 -color_primaries bt709 -color_trc iec61966-2-1\
6559
-y outputfile.mp4
6660
```
6761

6862
| --- | --- |
6963
| **-crf 18** | This is the constant rate factor, controlling the default quality in the range 0-63. By default this is set to 50, which is a little on the low side, using values closer to 18 is recommended, but this does come at the expense of file-size. For more on this see the [CRF comparison](#crf-comparison-for-libsvtav1) below. |
70-
| **-preset 9** | Help with a trade-off between encoding speed and compression efficiency. Supported preset range in the 0-13. See below for comparisons |
64+
| **-preset 5** | Help with a trade-off between encoding speed and compression efficiency. Supported preset range in the 0-13. See below for comparisons |
7165

7266
See also:
7367
* [SVT-AV1 ffmpeg](https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/Ffmpeg.md)
@@ -85,6 +79,14 @@ To help pick appropriate values with the CRF flag, we have run the [Test Framewo
8579

8680
### Preset values for libsvtav1
8781

82+
| ![](enctests/reference-results/av1-preset-test-encode_time.png) This is showing preset values against encoding time. |
83+
| ![](enctests/reference-results/av1-preset-test-filesize.png) This is showing preset values against file size. |
84+
| ![](enctests/reference-results/av1-preset-test-vmaf_harmonic_mean.png) This is showing preset values against VMAF harmonic mean |
85+
| ![](enctests/reference-results/av1-preset-test-psnr_y_harmonic_mean.png) This is showing preset values against PSNR harmonic mean |
86+
87+
These graphs are with a CRF of 15 for four different media clips, its showing that the preset values are affecting the amount of compression, but not affecting the quality of the result, at the expense of the encoding time (at least up to preset 9).
88+
89+
8890
See: [SVT-AV1 Common Questions](https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/CommonQuestions.md)
8991

9092

@@ -115,6 +117,10 @@ ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -frames:v 200 -c:v libaom-av1
115117
| -cpu-used 6 | This sets how efficient the compression will be. The default is 1, changing this will increase encoding speed at the expense of having some impact on quality and rate control accuracy. Values above 6 are reset to 6 unless real-time encoding is enabled. See below for comparison. |
116118
| -row-mt 1 | This enables row based multi-threading (see [here](https://trac.ffmpeg.org/wiki/Encode/VP9#rowmt)) which is not enabled by default. |
117119
| -usage allintra | Encodes for all intra-frames |
120+
| -arnr-strength | This decreases the amount of noise reduction you get, setting it to 1 helps preserve grain, and some noisy pictures |
121+
| -aom-params: tune-content=film | There is a tune parameter, but it just seems to make the picture grainy, and is not recommended |
122+
123+
Libaom has an aggressive denoiser, which can be pretty good for animated media, but can be a problem for live-action, particularly if there is noisy content, such as water or particles. CRF needs to be lowered to counter this, which does affect encoding speed.
118124

119125
### cpu-speed Comparison for libaom-av1
120126

@@ -129,13 +135,14 @@ To help pick appropriate values with the cpu-speed flag, we have run the [Test F
129135

130136
See Also - note these are all guides for AOMENC (the AOM encoder that is part of libaom), but many of the parameters map to ffmpeg:
131137
* [A 2nd generation guide to aomenc-av1](https://forum.doom9.org/showthread.php?t=183906)
132-
* [Making aomenc-AV1/libaom-AV1 the best it can be in a sea of uncertainty]((https://old.reddit.com/r/AV1/comments/lfheh9/encoder_tuning_part_2_making_aomencav1libaomav1/)
133-
* https://github.com/master-of-zen/Av1an/blob/master/docs/Encoders/aomenc.md
138+
* [Making aomenc-AV1/libaom-AV1 the best it can be in a sea of uncertainty](https://old.reddit.com/r/AV1/comments/lfheh9/encoder_tuning_part_2_making_aomencav1libaomav1/)
139+
* [Av1an](https://master-of-zen.github.io/Av1an/Encoders/aomenc.html)
140+
* [AV1 Codec Wiki](https://wiki.x266.mov/docs/encoders/aomenc)
134141

135142
## librav1e
136-
[librav1e](https://github.com/xiph/rav1e) is the Xiph encoder for AV1.
143+
[librav1e](https://github.com/xiph/rav1e) is the Xiph encoder for AV1, written in rust.
137144

138145
Supported pixel formats:
139146
yuv420p yuvj420p yuv420p10le yuv420p12le yuv422p yuvj422p yuv422p10le yuv422p12le yuv444p yuvj444p yuv444p10le yuv444p12le
140147

141-
There is no CRF flag, so we are ignoring this for now, but it could be promising down the road.
148+
There is no CRF flag, so you use the -gp flag, the recommended starting point is about 100. However, we have been unable to get an substantial speed improvement over AOM.

EncodeMJPEG.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ parent: Codec Comparisons
77

88
# MJPEG - Motion JPEG
99

10-
[Motion JPEG](https://en.wikipedia.org/wiki/Motion_JPEG) has historically been quite common in the VFX industry, and is part of the default quicktime codecs, so is well supported on players, although not typically supported in web browsers.
10+
[Motion JPEG](https://en.wikipedia.org/wiki/Motion_JPEG) has historically been quite common in the VFX industry, and is part of the default Quicktime codecs, so is well supported on players, although not typically supported in web browsers.
1111

1212
While it does compress quickly, and maintains its quality fairly well, we would recommend other codecs at higher bit-depths such as vp9, h264 or h265 (or even Prores or DNxHD), which will also compress better than mjpeg.
1313

14-
15-
1614
## MJPEG
1715

1816
mjpeg has a limited range of pixel formats:
@@ -35,15 +33,15 @@ comparisontest:
3533
-->
3634
```
3735
ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -frames:v 200 \
38-
-c:v mjpeg -qscale:v 4 outputfile.mov
36+
-c:v mjpeg -qscale:v 2 outputfile.mov
3937
4038
```
4139

4240

43-
## Recomended Flags
41+
## Recommended Flags
4442

4543
| --- | --- |
46-
| **-qscale:v 3** | This is the compression factor, which goes from 2 to 31 where 2 is the best quality. |
44+
| **-qscale:v 2** | This is the compression factor, which goes from 2 to 31 where 2 is the best quality. See alternative approach for better encoding. |
4745

4846

4947
### qscale:v Comparison
@@ -54,3 +52,21 @@ Below is a comparison of different Qscale rates
5452
| ![](enctests/reference-results/mjpeg-qscale-tests-filesize.png) This is showing qscale:v values against file size. |
5553
| ![](enctests/reference-results/mjpeg-qscale-tests-vmaf_harmonic_mean.png) This is showing qscale:v values against VMAF harmonic mean |
5654
| ![](enctests/reference-results/mjpeg-qscale-tests-psnr_y_harmonic_mean.png) This is showing qscale:v values against PSNR-Y harmonic mean |
55+
56+
## Alternative approach
57+
58+
You can generate the individual jpeg files using another tool, and then use ffmpeg to stitch them together. For example, to convert a series of png frames to jpeg, you can use oiiotool:
59+
```
60+
oiiotool -v --parallel-frames -i PNGFILES.%05d.png --compression jpeg:95 -o JPEGFILES.%05d.jpg
61+
```
62+
and then stitch them together with:
63+
```
64+
ffmpeg -f image2 -r 24 -i JPEGFILES.%05d.jpg -vcodec copy outputfile.mov
65+
```
66+
67+
This gives you more fine grain control over the quality setting, although it gives you less control over the jpeg compression, since it will always be YUV420, where you do get more control with ffmpeg.
68+
Its actually hard to get an exact mapping between the ffmpeg -qscale setting and the jpeg quality. The highest ffmpeg setting is 2, and that roughly maps to a jpeg quality setting of 86%.
69+
So if you require higher quality than 86% then use this approach. Settings below 95% do produce artifacts, so this is the recommended approach if you *have* to do this, a 10-bit encoder would be better though.
70+
71+
Below shows a comparison of jpeg compression to filesize for a HD sized image sequence of 200 frames.
72+
![](enctests/reference-results/mjpeg-compression-tests-filesize.png)

EncodeVP8.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
layout: default
3+
nav_order: 4.5
4+
title: VP8 Encoding
5+
parent: Codec Comparisons
6+
---
7+
8+
# VP8
9+
10+
VP8 is an open-source and royalty free codec developed by the [Alliance for Open Media](https://trac.ffmpeg.org/wiki/Encode/VP8) (AOMedia), a non-profit industry consortium. It will only encode to 8-bit 4:2:0 using the webm container. It is possible to get a similar quality to h264, but not typically at the same compression ratio. It is recommended that you consider [VP9](EncodeVP9.html) which is a considerably better codec. VP8 does support an alpha channel (via the yuva420p pixfmt).
11+
12+
General ffmpeg info on VP8 is [here](https://trac.ffmpeg.org/wiki/Encode/VP8), and on the encoder in general [https://www.webmproject.org/docs/encoder-parameters/](https://www.webmproject.org/docs/encoder-parameters/).
13+
14+
VP8 has browser support in:
15+
* Chrome.
16+
* Edge
17+
* Firefox
18+
* Opera
19+
20+
VP8 is supported by mkv and webm containers, no support exists for mov or mp4.
21+
22+
## libvpx
23+
24+
libvpx has a limited range of pixel formats:
25+
yuv420p yuva420p
26+
27+
28+
Example encoding:
29+
30+
<!---
31+
name: test_vp8
32+
sources:
33+
- sourceimages/chip-chart-1080-16bit-noicc.png.yml
34+
comparisontest:
35+
- testtype: idiff
36+
compare_image: ../sourceimages/chip-chart-1080-16bit-noicc-yuv420p10le.png
37+
- testtype: assertresults
38+
tests:
39+
- assert: less
40+
value: max_error
41+
less: 0.00195
42+
-->
43+
```
44+
ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -frames:v 200 \
45+
-c:v libvpx -crf 20 -b:v 200M -pix_fmt yuv420p \
46+
-qmin 0 -qmax 50 -quality good -speed 4 \
47+
-sws_flags spline+accurate_rnd+full_chroma_int \
48+
-vf "scale=in_range=full:in_color_matrix=bt709:out_range=tv:out_color_matrix=bt709" \
49+
-color_range tv -colorspace bt709 -color_primaries bt709 -color_trc iec61966-2-1 \
50+
-y outputfile.webm
51+
```
52+
53+
54+
55+
## Recommended Flags
56+
57+
```
58+
-crf 20 -quality good -b:v 200M -speed 4
59+
```
60+
61+
| --- | --- |
62+
| **-crf 20** | This is the constant quality rate factor, controlling the default quality, similar to h264. The range is a little different to h264, so you may need to test. |
63+
| *-quality good* | May require additional testing, but so far switching to *-quality best* increased the duration, but didn't increase the VMAF score (which is already pretty high with these values of crf). |
64+
| -b:v 200M | Unlike with h264, and vp9 you need to set the bit rate, but you can set it to a high number, and this is the max it would be. |
65+
| -speed 4 | It sets how efficient the compression will be. Unless you are using -quality best, this doesnt seem to have a setting for |
66+
67+
Its possible you might want to change the [GOP](https://aws.amazon.com/blogs/media/part-1-back-to-basics-gops-explained/#:~:text=Simply%20put%2C%20a%20GOP%20is,30%20frames%2C%20or%201%20second.) values (changed with the -g flag), since the default is 240 frames.
68+
69+
70+
### CRF Comparison
71+
72+
Below is a comparison of different CRF rates, with -b:v 200M and -quality good
73+
74+
75+
76+
| ![](enctests/reference-results/vp8-crf-test-encode_time.png) This is showing CRF values against encoding time. |
77+
| ![](enctests/reference-results/vp8-crf-test-filesize.png) This is showing CRF values against file size. |
78+
| ![](enctests/reference-results/vp8-crf-test-vmaf_harmonic_mean.png) This is showing CRF values against VMAF harmonic mean |
79+
| ![](enctests/reference-results/vp8-crf-test-psnr_y_harmonic_mean.png) This is showing CRF values against psnr y harmonic mean |
80+
81+
### Speed Comparison
82+
83+
Below is a comparison of different speed rates, -quality good vs. -quality best and with -crf 22, -b:v 200M.
84+
85+
This shows that with -quality good the filesize doesnt vary, but with increasing speed settings the encoding time goes down.
86+
87+
| ![](enctests/reference-results/vp8-speed-tests-encode_time.png) This is showing speed against encoding time. |
88+
| ![](enctests/reference-results/vp8-speed-tests-filesize.png) This is showing speed values against file size. |
89+
| ![](enctests/reference-results/vp8-speed-tests-vmaf_harmonic_mean.png) This is showing speed values against VMAF harmonic mean |
90+
| ![](enctests/reference-results/vp8-speed-tests-psnr_y_harmonic_mean.png) This is showing speed values against psnr y harmonic mean |

EncodeVP9.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ VP9 has browser support in:
1919
* Safari - works for 8-bit and 10-bit but fails on 10-bit 444 and 12-bit RGB.
2020

2121
VP9 is supported by mp4 and webm containers, no support exists for mov.
22+
VP9 does support an alpha channel (via the yuva420p pixfmt).
2223

23-
Outside of the web browser, VP9 support is pretty much limited to Davinci Resolve, Houdini, Blender, ffmpeg and VLC.
24+
Outside of the web browser, VP9 support is pretty much limited to Davinci Resolve (Mac R/W, windows Read-only), Houdini, Blender, ffmpeg and VLC.
2425

2526
The two codecs we will cover are:
2627
* [libvpx-vp9](#libvpx-vp9)
@@ -58,7 +59,7 @@ ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -frames:v 200 -c:v libvpx-vp9
5859

5960

6061

61-
## Recomended Flags
62+
## Recommended Flags
6263

6364
```
6465
-crf 22 -quality good -b:v 0 -speed 2 -row-mt 1

Quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ comparisontest:
3030
```console
3131
ffmpeg -r 24 -start_number 1 -i inputfile.%04d.png -pix_fmt yuv420p \
3232
-vf "scale=in_color_matrix=bt709:out_color_matrix=bt709" \
33-
-frames:v 100 -c:v libx264 -preset slower \
33+
-frames:v 100 -c:v libx264 -preset slower -crf 18 \
3434
-color_range tv -colorspace bt709 -color_primaries bt709 -color_trc iec61966-2-1 \
3535
-movflags faststart outputfile.mp4
3636
```

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The main wiki page for this for now is [here](https://wiki.aswf.io/pages/viewpag
2727
3. [AV1](EncodeAv1.html)
2828
4. [HEVC/H.265](EncodeHevc.html)
2929
5. [MJPEG](EncodeMJPEG.html)
30+
6. [VP8](EncodeVP8.html)
3031
6. [VP9](EncodeVP9.html)
3132
7. [DNxHD](EncodeDNXHD.html)
3233
7. [Metadata NCLC/NCLX](ColorPreservation.html#nclc)

compare.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
}} );
5757
</script>
5858
</head>
59-
<a href="/EncodingGuidelines">Testing Home</a>
59+
<a href="/">Testing Home</a>
6060
<body style="background-color:rgb(65 65 65); color:rgb(200,200,200); ">
6161
<div id="header_wrap" class="outer">
6262
<header class="inner main-content"">
46.7 KB
Loading
38.8 KB
Loading

0 commit comments

Comments
 (0)