-
Notifications
You must be signed in to change notification settings - Fork 20
[WIP] "Preparation" and "Writing the script" for Basics and Workflow #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
4fd66fb
10dcfee
d97372b
7c96009
8fe35e2
a57527a
76f9d41
f091c6a
3625196
90728e9
ce1e619
262a859
6b6cd58
e25873a
06c55f5
947fac7
3b60e39
71c5889
e88ef98
0c2da86
cc752bc
c85bcc0
669589a
66349bb
78fee3d
c23eee6
628b201
3cfe498
44ca844
c43f03d
9af616e
83ccede
063303c
56f785e
0821b6b
bde20b0
03f6667
c769596
b4ab07a
7badaa3
c968f40
93b43b9
f96f737
94d31da
001a5dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,15 +2,245 @@ | |||||
|
||||||
## Preparation | ||||||
|
||||||
downloading a source, looking at the video, some decisions | ||||||
(resolution(s) for the release, audio codec, group-specific | ||||||
requirements) | ||||||
It is important to have a good idea | ||||||
of what you want the result of the encode | ||||||
to be like. | ||||||
What will your video source be? | ||||||
What resolution should you encode it to? | ||||||
Do you use AAC or FLAC? | ||||||
8bit colors or 10bit colors? | ||||||
All of these are things | ||||||
that have to be accounted for | ||||||
and decided early on. | ||||||
|
||||||
Some groups have set standards. | ||||||
For example, you may have a group | ||||||
that always encodes their audio in AAC. | ||||||
Others will always release their videos in 1080p. | ||||||
Some may even mix it up | ||||||
and use FLAC audio for 1080p releases, | ||||||
but AAC for 720p. | ||||||
They might even only go for | ||||||
8bit colors in the latter case! | ||||||
If you're unsure what standards a group has, | ||||||
contact your group leader. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to have a sentence that reiterates how this guide focuses on best practices and should generally be preferred over sticking to some weird standards (scene releases any1?). |
||||||
|
||||||
There are various sources | ||||||
that are often used for the video. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "often" in this sentence makes it seem pretentious.
Suggested change
|
||||||
You will most commonly work with websources | ||||||
like Crunchyroll, | ||||||
as those are easy to acquire, | ||||||
or Blu-rays, for the improved quality and fixes. | ||||||
As a beginner, you might not | ||||||
have access to private trackers with BDMVs yet. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sentence seems out of context because you didn't explain beforehand that BDMVs are frequently uploaded to private trackers. |
||||||
A good alternative until then | ||||||
is to use the raws provided by groups like Reinforce: | ||||||
those that have not been filtered, | ||||||
just re-encoded from the BDMV. | ||||||
|
||||||
## Writing the Script | ||||||
|
||||||
imports, source filter (mention lsmash, ffms2), examples for resizing, | ||||||
debanding, AA. with images if possible | ||||||
In order to start filtering, | ||||||
first you must learn how to write a VapourSynth script. | ||||||
|
||||||
```Py | ||||||
import vapoursynth | ||||||
core = vs.core | ||||||
``` | ||||||
|
||||||
First, you must import the VapourSynth module. | ||||||
You can also import various other modules, | ||||||
like the many "funcs"[^1] that people have written. | ||||||
Here are some common examples: | ||||||
|
||||||
```Py | ||||||
import kagefunc as kgf | ||||||
import fvsfunc as fvf | ||||||
import havsfunc as haf | ||||||
``` | ||||||
|
||||||
These will import various functions | ||||||
that may prove useful for filtering, | ||||||
like masks, descaling wrappers, anti-aliasing functions, etc. | ||||||
|
||||||
Now, to start filtering, | ||||||
we must first import a video clip. | ||||||
|
||||||
```Py | ||||||
src = core.ffms2.Source("source") | ||||||
``` | ||||||
```Py | ||||||
src = core.lsmas.LWLibavSource("source") | ||||||
``` | ||||||
|
||||||
There are two common import filters available. | ||||||
Those are L-SMASH and ffms2. | ||||||
L-SMASH is typically used for m2ts files | ||||||
(the kind you'll find in BMDVs), | ||||||
while ffms2 is used for everything else. | ||||||
The reason for this is that ffms2 | ||||||
can't accurately read m2ts files, | ||||||
which L-SMASH can. | ||||||
However, L-SMASH is slower than ffms2, | ||||||
and some people prefer to be able to | ||||||
index the source files faster. | ||||||
|
||||||
It is common practice to call the source clip `src`. | ||||||
This way it's easy to tell what the original video is, | ||||||
and it can be referenced for some masks or for comparisons. | ||||||
|
||||||
Let's now look at a couple of common filters | ||||||
that you will find yourself using often. | ||||||
|
||||||
```Py | ||||||
src16 = fvf.Depth(src, 16) | ||||||
``` | ||||||
|
||||||
The color depth of a clip | ||||||
indicates the number of bits used | ||||||
to give a pixel its color. | ||||||
A lot of filters work with high bitdepths, | ||||||
so this is typically set at the start of the script. | ||||||
Your average `src` will be 8bit, | ||||||
but you might occasionally run into 10bit sources as well. | ||||||
|
||||||
```Py | ||||||
trim = core.std.Trim(src, first=100, last=1000) | ||||||
``` | ||||||
```Py | ||||||
trim = src[100:1001] | ||||||
``` | ||||||
|
||||||
`Trim` is used for trimming the video. | ||||||
It's inclusive, | ||||||
which means that it also adds the `last` frame given. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "includes", not "adds". |
||||||
Another way to trim is by using Python Slices. | ||||||
These are exclusive however, | ||||||
so you need to take that into account. | ||||||
|
||||||
Inclusive and exclusive work like this: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Imo it should be enough to just claim that the above two trims are equivalent (and skipp the following paragraphs), or do people have problems with the two terms "inclusive" and "exclusive"? |
||||||
|
||||||
Let's say you have a number range. | ||||||
This is what they'd look like with both methods: | ||||||
``` | ||||||
Inclusive from 1 to 10: | ||||||
1 2 3 4 5 6 7 8 9 10 | ||||||
|
||||||
Exclusive from 1 to 10: | ||||||
1 2 3 4 5 6 7 8 9 | ||||||
``` | ||||||
|
||||||
Inclusive also **inclu**des | ||||||
the final number in the given range, | ||||||
whilst exclusive **exclu**des them. | ||||||
Both of these have their pros and cons, | ||||||
so it all comes down to preference. | ||||||
|
||||||
```Py | ||||||
scaled = core.resize.Spline36(src, width=1280, height=720) | ||||||
``` | ||||||
|
||||||
`resize` has multiple "kernels" | ||||||
that are used for [resampling](resampling.md#upsampling) the clip | ||||||
to the given resolution. | ||||||
Common resolutions are 1920x1080, 1600x900, 1280x720, 1024x576 and 848x480. | ||||||
Nowadays most sources will be available in 1080p, | ||||||
but there are advantages to downscaling, | ||||||
like smaller filesizes. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should mention the advantages of not downscaling. |
||||||
|
||||||
You will often find grain or noise on a lot of sources. | ||||||
You can get rid of that by denoising them. | ||||||
|
||||||
 | ||||||
|
||||||
Look at her hair. There is a lot of grain on there, but some people may prefer that to be smooth instead. | ||||||
|
||||||
```Py | ||||||
import mvsfunc as mvf | ||||||
|
||||||
denoise = mvf.BM3D(src, sigma=[4,2]) | ||||||
``` | ||||||
|
||||||
 | ||||||
|
||||||
There are many denoisers available to use, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would start by explaining what a denoiser is. |
||||||
and they all have their strong and weak points. | ||||||
Some will have better detail retention, | ||||||
whilst others are a lot faster. | ||||||
|
||||||
Just be aware that getting rid of grain | ||||||
will often result in more problems popping up, | ||||||
like the very obvious banding in this case. | ||||||
|
||||||
Banding is caused by gradients | ||||||
breaking up during compression. | ||||||
In this picture, | ||||||
you can see the gradient breaking up | ||||||
very clearly in her hair. | ||||||
To fix this, you use a debanding filter. | ||||||
|
||||||
```Py | ||||||
import mvsfunc as mvf | ||||||
import kagefunc as kgf | ||||||
|
||||||
denoise = mvf.BM3D(src, sigma=[4,2]) | ||||||
deband = core.f3kdb.Deband(denoise, range=18, y=40, cb=32, cr=32, grainy=12, grainc=0, output_depth=16) | ||||||
grain = kgf.adaptive_grain(deband, strength=0.1) | ||||||
``` | ||||||
 | ||||||
|
||||||
The banding is now less obvious, | ||||||
and has been further hidden by adding grain. | ||||||
|
||||||
Grain is something that some people like, | ||||||
and others hate with a passion. | ||||||
There are various ways that it can be used, | ||||||
ranging from adding a particular mood to a scene | ||||||
to preventing other artifacts from showing up. | ||||||
It's also common for encoders to | ||||||
add their own grain after denoising. | ||||||
|
||||||
 | ||||||
|
||||||
This frame looks fairly clean overall, | ||||||
but the encoding may introduce some banding | ||||||
in the darker areas of this frame. | ||||||
To combat this, we're adding grain | ||||||
to just the darker areas. | ||||||
|
||||||
```Py | ||||||
import kagefunc as kgf | ||||||
|
||||||
grain = kgf.adaptive_grain(deband, strength=0.3, luma_scaling=8) | ||||||
``` | ||||||
 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a blank line above (and has a few too many below). |
||||||
|
||||||
|
||||||
|
||||||
Another common issue is aliasing. | ||||||
Aliasing an artifact that is commonly caused | ||||||
by scaling or compression. | ||||||
|
||||||
 | ||||||
|
||||||
Note the windows to the left. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't you describe aliasing with a bit more detail? |
||||||
You'll want to use anti-aliasing filters | ||||||
to deal with this. | ||||||
|
||||||
```Py | ||||||
import vsTAAmbk as taa | ||||||
|
||||||
aa = taa.TAAmbk(src aatype='Eedi3', opencl=True) | ||||||
``` | ||||||
|
||||||
 | ||||||
|
||||||
There are a couple of different anti-aliasing filters, | ||||||
some faster than others. | ||||||
Try out lighter AA if you can first, | ||||||
like `Nnedi3`. | ||||||
|
||||||
|
||||||
|
||||||
## Encoding the Result | ||||||
|
||||||
|
@@ -35,3 +265,10 @@ examples for qaac, flac | |||||
## Muxing | ||||||
|
||||||
mkvtoolnix | ||||||
|
||||||
*** | ||||||
|
||||||
[^1]: "funcs" are a combination of wrappers written by people to perform different tasks. | ||||||
Most of these can be found in the [VapourSynth Database][vsdb] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Iirc you cannot use linebreaks in footnotes. @OrangeChannel? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, that's correct. |
||||||
|
||||||
[vsdb]: http://vsdb.top/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except in germany. Because in germany having a standard set by a group implies that there is a group to be a part of to begin with.