Post subject: BT.2020 Colorspace and AVS+
Publisher
Joined: 4/23/2009
Posts: 1283
So I was doing some VHS captures and was suck back into colorspace hell, when I noticed that we are not using the correct colorspace for our 4K videos. That's BT.2020. https://en.wikipedia.org/wiki/Rec._2020. Unfortunately, or maybe fortunately, we would need to move to AVS+ to get this conversion. I think AVS+ is stable enough to move towards. It even comes with 64-bit support! 64-bit plugins are a problem, but most commonly used plugins are now available. Thoughts?
Joined: 10/14/2013
Posts: 335
Location: Australia
I've been wondering about this myself for quite some time. I didn't bring it up myself because I have a few questions, but if AVS+ can be a drop-in replacement for AVISynth, then at the very least I am all for that portion of the idea. Edit: To add to the above, yes, it works as a drop-in. I backed up my plugin directory, removed AVISynth, installed AVISynth+ and restored my plugin to the AVISynth+ directory and it looks like the scripts all still work properly. I'm yet to thoroughly test anything, but it looks promising. It definitely has a lot of advantages over traditional AVISynth and from this test, it looks like it won't hurt. Regarding color matrices, my knowledge is somewhat limited. Specifically, I'm unsure as to how Youtube handles the color matrices. If it displays them incorrectly then we should use whatever gives the most accurate color representation. I wasn't around when the decision to use Rec709 was made for Youtube, so there's a good chance that some of the testing has already been done, but I'd still be interested to know if this change impacts color accuracy and if not, I'd like to have these doubts put to rest. At the very least, AVISynth+ has simultaneous 64-bit and 32-bit, native G-Script support, multi-threading and a host of other improvements that make the switch seem like a very good idea to me. Edit #2: It also seems the AVISource limit is larger. I managed to chain together 75 clips before I had an issue, something which usually happens much sooner in AVISynth. This could also perhaps be a false positive as the result of using a simplified test clip.
I'm not as active as I once was, but I can be reached here if I should be needed.
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11486
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Wikipedia says this standard can use 10 (and even 12) bit 4:4:4 video. I wonder if youtube is capable. As for segment limit, for me it wasn't strictly 50 with avisynth either. Something like 75 as well. But GScript rocks!!! Hmmmmm... https://support.google.com/youtube/answer/7126552 https://forums.anandtech.com/threads/youtube-now-officially-supports-up-to-10-bit-hdr-8k-60fps.2491332/
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Joined: 10/14/2013
Posts: 335
Location: Australia
Here's a test, to see how things are handled. If there's a mistake in my processing or command lines, feel free to correct me. The video footage is taken from Tompa's 101% run of Donkey Kong Country. First up, here's the control video. The AVISynth portion was based on the encoding package, albeit modified to be shorter for testing purposes. The x264 command line is taken directly from the package, unmodified: Watch on Youtube
Language: avisynth

AVISource("input.avi") PointResize(2880,2160) ConvertToYV24(chromaresample="point", matrix="Rec709") ConvertToYV12(chromaresample="lanczos", matrix="Rec709")
Language: batch

"./programs/avs2pipemod" -wav encode.avs | "./programs/venc" -q10 - "./temp/audio.ogg" "./programs/avs2pipemod" -y4mp encode.avs | "./programs/x264_x64" --qp 5 -b 0 --keyint infinite --output "./temp/video_youtube_control.mkv" --demuxer y4m - "./programs/mkvmerge" -o "./output/encode_youtube_control.mkv" --compression -1:none "./temp/video_youtube_control.mkv" "./temp/audio.ogg"
Next, the new test video. Modifications have been made to both the script and command lines accordingly: Watch on Youtube
Language: avisynth

AVISource("input.avi") PointResize(2880,2160) ConvertToYV24(chromaresample="point", matrix="Rec2020")
Language: batch

"./programs/avs2pipemod" -wav encode.avs | "./programs/venc" -q10 - "./temp/audio.ogg" "./programs/avs2pipemod" -y4mp encode.avs | "./programs/x264-10_x64" --qp 5 -b 0 --keyint infinite --output "./temp/video_youtube_test.mkv" --colormatrix bt2020nc --output-csp i444 --demuxer y4m - "./programs/mkvmerge" -o "./output/encode_youtube_test.mkv" --compression -1:none "./temp/video_youtube_test.mkv" "./temp/audio.ogg"
Next, we have the same file, remuxed using Youtube's HDR metadata tool (which is just a modified mkvmerge). All the following settings may not be necessary, nor may they accurately represent our video data, but for testing's sake I followed their example as it was written: Watch on Youtube
mkvmerge -o encode_youtube_metadata.mkv --colour-matrix 0:9 --colour-range 0:1 --colour-transfer-characteristics 0:16 --colour-primaries 0:9 --max-content-light 0:1000 --max-frame-light 0:300 --max-luminance 0:1000 --min-luminance 0:0.01 --chromaticity-coordinates 0:0.68,0.32,0.265,0.690,0.15,0.06 --white-colour-coordinates 0:0.3127,0.3290 encode_youtube_test.mkv
Finally, we have the input video for reference: Download via Mediafire I'm not sure if the metadata carried over correctly in to Youtube's processing, so if there are any discrepancies it could be related to that. I'm also not sure if we should have been specifying Rec709 in the metadata for HD this whole time. Edit: It looks like (as feos pointed out to me in IRC) that it has only detected Rec709 in all cases. This could be an issue with processing that resolves over time, but likely I did something wrong or perhaps it doesn't support this particular method. Edit 2: On the chance it's Youtube's processing, here's an alternate version.
I'm not as active as I once was, but I can be reached here if I should be needed.
Publisher
Joined: 4/23/2009
Posts: 1283
Nice work! I was going to say we need to test what colorspace YT goes to anyway, but you kind of beat me to it. I'll take a closer look at the results in a bit. Edit: After reading more on it, you may need to change the color bit to 10-bit in AVS+. After all BT.2020 color range is greater than BT.709 and needs higher bit, which is 10-bit or 12-bit. Edit 2: Doing a ton more reading (this is interesting after all), I found out there is no need for us to go to BT.2020 as sRGB (RGB) has the same color primaries as BT.709 but slightly different transfer (gamma) functions while converting the BT.2020 is very different and difficult. I also found out that UHD can use BT.709 anyway, so it's fine. I guess the focus of this thread is now more towards if we should move to AVS+.
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11486
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
I have a point. I discovered that freesub treats alignment of 8 properly, while regular avisynth subtitle doesn't. Let's say you have 2 subtitle entries, with similar Y pos and similar 8 alignment, but with different amount of lines.
Language: lol

freesub ------------------------- ------------------------- | | | | | | | | | | | | | | | subtitle 2 line 1 | | subtitle 1 line 1 | | subtitle 2 line 2 | | subtitle 1 line 2 | | subtitle 2 line 3 | ------------------------- ------------------------- subtitle (and bihhalo) ------------------------- ------------------------- | | | | | | | | | | | | | | | | | subtitle 1 line 1 | | subtitle 2 line 1 | | subtitle 1 line 2 | | subtitle 2 line 2 | ------------------------- ------------------------- subtitle 2 line 3 (out of bounds)
I thought, why don't we fix it in avisynth? Then I thought, wait a minute, what's also the problem with adding variable halo size to avisynth? And killing fucking antialiasing that breaks low-res subtitles? I googled for a little bit, and I think this is what we need to switch to, fork, add our features, and pull request them to! https://github.com/pinterf/AviSynthPlus/releases (MT branch) AVS+ has been tested and it seems to allow seamless replacement. But it also supports lots of awesome things out of the box. And is being developed as we talk!
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Editor, Emulator Coder, Site Developer
Joined: 5/11/2011
Posts: 1108
Location: Murka
feos wrote:
And killing fucking antialiasing that breaks low-res subtitles?
I was doing non-AA subs on all low res encodes many years ago, have we gotten worse tools since then?
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11486
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
natt, I mean native avisynth subtitles. I defaulted the scripts to your freesub thing years ago, but it's not the best option for HD. Also, right now the script is dying to the absurdly overblown amount of all sorts of options. Having several subtitles with incompatible logic isn't helping with this.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Editor, Emulator Coder, Site Developer
Joined: 5/11/2011
Posts: 1108
Location: Murka
I have a feeling you'll still need some sort of option or different codepath. For rendering on things like GB/GBA, you really need very small pixel perfect fonts with no AA, but on hi res you do want AA and vector fonts. But good luck on getting them both under one umbrella.
Publisher
Joined: 4/23/2009
Posts: 1283
So we're moving to AVS+ 64-bit? =D
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11486
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Yup! I also wonder, does any of our encoders prefer linux? Because http://avisynth.nl/index.php/HOWTO:_AviSynth_video_processing_with_WINE
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Publisher
Joined: 4/23/2009
Posts: 1283
Well the other option is move to VapourSynth which has native support for Linux
Site Admin, Skilled player (1255)
Joined: 4/17/2010
Posts: 11486
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.