Would that I could run Al's script.
I uninstalled Python, Vapoursynth and Vapoursynth Editor, cleaned the registry, reinstalled the programs, and still have the same errors in Vapoursynth editor. Apparently I'm not the only one:
https://forum.doom9.org/archive/index.php/t-170965.html
Is there a way to run Al's script without Vapoursynth editor in WINDOWS? The editor seems to be null and void.
For posterity, here is his script again. Is this the right one?
https://forum.videohelp.com/threads/395939-ffmpeg-Color-Range/page2#post2573810
Windows 10 does not know how to run your script "my_scrit.vpy".
I ran the first line of your code in command prompt and got an error message:
So far this is a bust. Nothing but errors.Code:"vspipe.exe" --y4m "C:\my_scrit.vpy" - | "x264.exe" --demuxer y4m --crf 18 --vbv-bufsize 30000 --vbv-maxrate 28000 --colorprim bt709 --transfer bt709 --colormatrix bt709 --output "C:\my_output.264" -
What gives, Al?
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 271 to 300 of 324
Thread
-
-
You can bypass Vapoursynth Editor if having problems with that.
Search for IDLE in Windows. IDLE is Python console, that is used to write and run python programs. There is others not just IDLE, I think IDLE installs with Python on Windows. Not sure now if there is a box during installation to select it or not.
To search for IDLE, type "IDLE" without quotes in Windows search box (bottom left). Windows should find that idle. Run it. You get something like image 1.
Then select File/New File , copy/paste this script Image2:
Code:import vapoursynth as vs from vapoursynth import core print(vs) print(core.version())
After pressing F5 it should print something like that below to IDLE console if installed for a user account, this gives me on Windows 7, but I use 2 your old version, you might get something else:
Code:<module 'vapoursynth' from 'C:\\Users\\.....your user account name here ....\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\vapoursynth\\vapoursynth.cp37-win_amd64.pyd'> VapourSynth Video Processing Library Copyright (c) 2012-2018 Fredrik Mellbin Core R45 API R3.5 Options: -
So this bypasses Vaporsynth Editor. You can try that. As soon you make it work then Vapoursynth Editor might be tried or tested.
We might try to make it work for a while. If it does not work. Portable versions work always (using it for freezing python apps using vapoursynth). But scripts needs to load some DLL's or modules, so only as a an emergency if installations fails or are not fixed.Last edited by _Al_; 18th Apr 2020 at 21:45.
-
if installing Python and vapoursythn for all users, you also might follow an advise from LordMulder while installing Python and then vapoursynth:
https://forum.doom9.org/showthread.php?p=1881927#post1881927 -
Pasting your code into IDLE and pressing F5 appears to do nothing. No messages.
Pasting the code and pressing ENTER results in the following message:
SyntaxError: multiple statements found while compiling a single statement -
If pasting into IDLE you'd need to do it line by line and using ENTER for each line, not the whole script, look at included image
If pasting whole code and running it with F5, you need to create new file for python script File/New/File and paste it into that , not into IDLE console. The whole code you paste into image I posted before, image on the right.
Take your time, you are running and working with Python here. There are tutorials all over web using IDLE.
So to work with Python/Vapoursynth, you have two choices, you can choose a console/terminal (similar like command prompt in Windows) and input line by line , but you cannot save it for later. This is just for testing/running or some quick calculations or in our case to find out if vapoursynth is installed correctly etc. Or second choice, pasting whole script (more practical if writing a program) saving it as *.py file. Using it for later. Open it again, edit it, running it again etc.Last edited by _Al_; 19th Apr 2020 at 00:17.
-
Python, VapourSynth and Vapoursynth editor are installed for all users.
I pasted all three lines of your code into IDLE and saved the file as C:/Users/chris/Documents/test.py, viz.:
Code:import vapoursynth as vs from vapoursynth import core print(vs) print(core.version())
Traceback (most recent call last):
File "C:/Users/chris/Documents/test.py", line 1, in <module>
import vapoursynth as vs
ModuleNotFoundError: No module named 'vapoursynth'
C:\>path
PATH=C:\Program Files (x86)\Python37-32\Scripts\;C:\Program Files (x86)\Python37-32\;C:\Windows\system32;C:\Windows;C:\Windows\Syst em32\Wbem;C:\Windows\System32\WindowsPowerShell\v1 .0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Users\chris\.dnx\bin;C:\ Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files\VapourSynth\core;C:\Program Files\VapourSynth\vsrepo;C:\Users\chris\AppData\Lo cal\Microsoft\WindowsApps;on the "Advanced Options" page, be sure to enable the "Install for all users" option.Last edited by chris319; 19th Apr 2020 at 02:37.
-
Did you try to restart PC?
There might be something off with installations lately.
Like here: https://forum.doom9.org/showthread.php?t=181303 that guy developed Vapoursytnth MultiViewer and having problem to install it now.
Try to reboot it as there is last advice in that thread, or monitor it, even there is problem with dll , you cannot found module.
Monitor that thread
Not sure if
pip install VapourSynth
https://pypi.org/project/VapourSynth/
would help, because it needs working installation beforehand and it is for specific Python environments as I understood,
http://www.vapoursynth.com/doc/installation.html#installation-via-pip-pypi and
to install thru pip, you navigate to: C:\Program Files (x86)\Python37-32\Scripts\
where pip should be, then right click in Windows explorer window with SHIFT pressed, and in the menu select "Open Command Window here" , type: pip install VapourSynth
this might be a stupid advice though -
I have modified my scope program to report the number of pixels that are out of the r103 range of 5 - 246.
Turns out I have a very small amount of error, specifically 0.0169% in a typical frame, a small fraction of the allowable 1%. Seems that these videos were within r103 spec all along. -
Just making sure. I noticed Python37-32 in those included links. Does that mean, 32bit Python installation?
Do not install Python 32bit if that is the case. Install Python 64bit, make sure of that.
https://www.python.org/downloads/release/python-382/
And Vapoursynth 64bit.
and also
you need latest Python 3.8 version, not 3.7.
https://github.com/vapoursynth/vapoursynth/releases
latest R49 build needs Python 3.8. If it was not changed on vapoursynth site, it needs to be changed. I suppose you have Latest Vapoursynth R49.
At the moment there is Python 3.8.2 version on Python site.
Using linux it is not important I think (could be wrong), but on Windows latest R49 use with Python 3.8Last edited by _Al_; 19th Apr 2020 at 09:06.
-
When I uninstalled and reinstalled Python, Vapoursynth and Vapoursynth editor yesterday, I downloaded all of the latest 64-bit versions and installed them for all users. Vapoursynth will issue a warning if it does not like your Python installation. I'm getting the same errors as when I originally installed all this stuff, i.e. it cannot find the (non-existent) library.
So what is this combination going to do for me if I ever get it to work? If we want to count the number of out-of-gamut pixels and come up with a percentage (less than 1% per r103) then that was easily done with PureBasic and it works just fine. The number of out-of-gamut pixels is actually quite small, much less than 1%. -
Sounds like a headache. Not sure what else to suggest...
So what is this combination going to do for me if I ever get it to work? If we want to count the number of out-of-gamut pixels and come up with a percentage (less than 1% per r103) then that was easily done with PureBasic and it works just fine. The number of out-of-gamut pixels is actually quite small, much less than 1%.
It doesn't offer that much more. You can set different limits, different clip values, and visualize where / what to do about it, apply other filters instead of clipping, in realtime. -
OK, about “Canon RGB” (16-255) legalization, Gyan (the FFMPEG maintainer) suggests the use of geq filter:
Code:-vf "geq=lum='(p(X,Y)-16)/(255-16)*(235-16)+16':cb='(p(X,Y)-16)/(255-16)*(240-16)+16'"
Source: https://video.stackexchange.com/a/29870/27889 -
You mentioned this already;
https://forum.videohelp.com/threads/395939-ffmpeg-Color-Range/page8#post2578528
I believe the Y scaling is correct , but there are issues with CbCr scaling, turning image green. There needs to be some additional logic to not shift color balance
eg.
before geq
[Attachment 58629 - Click to enlarge]
after geq
[Attachment 58630 - Click to enlarge] -
The geq parameters assume grey is half way between 16 and 255, 135, not the usual 128 (half way between 16 and 240). So with an image that already has grey at 128 those greys are moved down to 121. That is the cause of the color shift in the second image. I don't know if that is right or wrong (I suspect the latter) for intended purpose.
If you want to compress the chroma range but keep grey at 128 use:
Code:-vf "geq=lum='(p(X,Y)-16)/(255-16)*(235-16)+16':cb='(p(X,Y)-128)/(255-16)*(240-16)+128"
Last edited by jagabo; 29th Apr 2021 at 09:04.
-
Not "automatically" in a "good" way;
You can clip values but this can lead to poor results visually
Also when you re-encode and subsample chroma, you generate some new illegal values, such as out of gamut . Values might be in "legal" range (Y 16-235, CbCr 16-240), but the combination of YCbCr produces "illegal" out of gamut values -
-
Out of gamut - combinations of YCbCr that produce negative RGB values, or values > 255 in 8bit. Those are "illegal".
You're always going to get some % of illegal , and out of gamut pixels. Always. The question is what %, and how are you going to address the issue. Generally you're allowed <1% or some leeway. If you exceed some threshold, it generally gets flagged by the QC process
Tonemapping is irrelevant for what you want to do -
I have retired from my former job at a broadcast TV station and now have lots of time to deal with this stuff after a few months' break.
You can clip values but this can lead to poor results visually
I found that trying to legalize by clipping has problems. With the full-range test signal, ffmpeg was putting the 255 patch at 235 and the 235 patch was left at 235, causing the 255 and 235 patches to blend into each other, e.g.:
Code:format=rgb24,"lutrgb=r='clip(val,19,231)':g='clip(val,19,231)':b='clip(val,19,231)'"
Code:bin\ffmpeg -y -i C0015.mp4 -pix_fmt yuv420p -c:v libx265 -vf unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=0.66,eq=brightness=-0.03:contrast=0.77,scale=w=1280:h=720:flags=spline:out_color_matrix=bt709:out_range=full -color_primaries bt709 -color_trc bt709 -colorspace bt709 -c:a copy Test.mov
[Attachment 60022 - Click to enlarge] -
-
a normal range signal becomes range compressed.
-
Yes it does.
YCbCr levels are incorrect and range compressed. For example Y=235 "white" becomes Y=215 "grey".
CbCr are off +/-12 on some colors on standard HD color bars
e.g.
Y,Cb,Cr 145,147,44 "cyan" becomes 135,150,32
Y,Cb,Cr 51,109,212 "red" becomes 51,106,224
Ideally, a "legalization" script wouldn't touch legal colors, or adjust contrast at all in already legal range values (or by only an insignificant amount) -
Using "brightness" and "contrast" does introduce some non-trivial color drift, so that's out.
You can clip to a luminance range of 5 - 246 and be R 103 compliant. You will lose a little detail in the highlights and very lowlights. Enough to worry about?
Code:ffmpeg -y -i "Bars.mp4" -c:v libx264 -vf format=rgb24,"lutrgb=r='clip(val,17,236)':g='clip(val,17,236)':b='clip(val,17,236)'",scale=w=1280:h=720:flags=spline:out_color_matrix=bt709:out_range=full,format=yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -r 59.94 -c:a copy clipped.mov
Last edited by chris319; 25th Jul 2021 at 19:23.
-
Yes - contrast/color changes are too large for valid input colors and greyscale. Also you cannot tag a file "full range" for "legal" submissions
This was already discussed a few pages back, you should go back and refresh.
IIRC, one of the older attempts with the train clip was ok, if the input was roughly correct to begin with (there is no way you can get ffmpeg or any program - to auto grade first)
If you recall, R103 5-246 in the R,G,B check portion refers to studio range RGB (RGB 16-235 reference black to white), not computer range RGB (RGB 0-255 reference black to white), so if you were clipping you would normally use full range equations for YCbCr<=>RGB in both directions.
And you will almost always get some illegal values, unless you stay in RGB... but submission and end distribution formats are almost always YCbCr. The YCbCr conversion and especially the chroma supsampling step will create new illegal values. The question is what %, and is it under the allowable threshold (~1% usually) . _Al_ posted a vapoursynth script and you can see if you change min/max clip channel levels, what % is illegal pixels. It works well and corresponds to professional analyzers -
Same way - start with other programs to grade, then final step can use ffmpeg or vapoursynth . The benefit of vapuorsynth is you can display planestats and it's interactive (eg. clip min 6, max 247 results in "x" % illegal), and you an visualize where the illegal pixels are, and then do something about it. _Al_ posted some scripts earlier in the thread. But it cannot be done 100% in vapoursynth either. Ideally you need that 1st step, some rough grade, otherwise you risk clipping too much "good" data -
you cannot tag a file "full range" for "legal" submissions
The program I wrote to do this QC checking already gives the percentage of out-of-gamut pixels. For example, the window signal has 0.01% out-of-gamut pixels after processing and would most likely pass QC.
Here is the spec. Please cite any reference to file flagging.
https://tech.ebu.ch/docs/r/r103.pdfLast edited by chris319; 26th Jul 2021 at 10:51.
-
I modified my script to have ffmpeg output limited-range files and got color shifts, much the same as when using "brightness" and "contrast".
Specifying a full-range file eliminates the color shifts.Last edited by chris319; 26th Jul 2021 at 13:09.
-
vapoursynth is not interactive. You keep spreading misinformation. vapoursynth as such does not provide any gui tools, same as ffmpeg. There are gui tools for libavfilter and reporting pixel values are trivial.
Also ffmpeg have video filters datascope, pixscope, pseudocolor, all this can visualize illegal values in certain ways.
Similar Threads
-
ffmpeg 4.1.4 question regarding "limited color range" output file
By bokeron2020 in forum Newbie / General discussionsReplies: 12Last Post: 1st Aug 2019, 18:28 -
Can I convert color profile with FFMPEG?
By PabstBlueRibbon in forum Video ConversionReplies: 0Last Post: 9th Sep 2017, 14:41 -
Color Range Question
By Akai-Shuichi in forum RestorationReplies: 4Last Post: 14th Feb 2017, 16:53 -
Change in color while reencoding with ffmpeg
By Epaminaidos in forum Video ConversionReplies: 24Last Post: 30th Sep 2016, 12:09 -
Can I alter h264 file's color range flags?
By bergqvistjl in forum Newbie / General discussionsReplies: 1Last Post: 17th Dec 2015, 13:00