VideoHelp Forum


Try StreamFab All-in-One and rip streaming video! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Page 10 of 11
FirstFirst ... 8 9 10 11 LastLast
Results 271 to 300 of 315
Thread
  1. 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:

    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" -
    So far this is a bust. Nothing but errors.

    What gives, Al?
    Quote Quote  
  2. 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())
    then press F5 to run it.

    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: -
    Right now it is important so Python and Vapoursynth are both installed on a user account or for all users. I think both has to be the same.

    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.
    Image Attached Thumbnails Click image for larger version

Name:	Capture.JPG
Views:	36
Size:	72.8 KB
ID:	52780  

    Last edited by _Al_; 18th Apr 2020 at 20:45.
    Quote Quote  
  3. 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
    Quote Quote  
  4. 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
    What's next?
    Quote Quote  
  5. 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.
    Image Attached Thumbnails Click image for larger version

Name:	Capture.JPG
Views:	33
Size:	54.6 KB
ID:	52782  

    Last edited by _Al_; 18th Apr 2020 at 23:17.
    Quote Quote  
  6. 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())
    Here is the result when the file was run:

    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'
    Here is the result of entering PATH:

    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.
    This is exactly what I did. I had to log off and log back in as Administrator, install Vapoursynth for all users, then log back in as Chris. Again, Python, Vapoursynth and Vapoursynth editor are installed for all users, so I don't think that's the issue.
    Last edited by chris319; 19th Apr 2020 at 01:37.
    Quote Quote  
  7. 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
    Quote Quote  
  8. 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.
    Quote Quote  
  9. 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.8
    Last edited by _Al_; 19th Apr 2020 at 08:06.
    Quote Quote  
  10. 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%.
    Quote Quote  
  11. Originally Posted by chris319 View Post
    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.
    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%.
    Then don't worry about it. You don't need it

    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.
    Quote Quote  
  12. 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'"
    It rescales the input luma from 16-255 to 16-235, and both the input chroma from 16-255 to 16-240, which is the legal range for broadcast 8-bit signals.

    Source: https://video.stackexchange.com/a/29870/27889
    Quote Quote  
  13. Originally Posted by forart.it View Post
    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'"
    It rescales the input luma from 16-255 to 16-235, and both the input chroma from 16-255 to 16-240, which is the legal range for broadcast 8-bit signals.

    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
    Image
    [Attachment 58629 - Click to enlarge]


    after geq
    Image
    [Attachment 58630 - Click to enlarge]
    Quote Quote  
  14. 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 08:04.
    Quote Quote  
  15. ...sorry for the doubled mention, but the question is: is there a way to "legalize" any source level to broadcast level ?
    In other words: can FFMPEG probe source file(s) level before remap to broadcast ?

    Thanks in advice to anyone can help.
    Quote Quote  
  16. Originally Posted by forart.it View Post
    ...sorry for the doubled mention, but the question is: is there a way to "legalize" any source level to broadcast level ?
    In other words: can FFMPEG probe source file(s) level before remap to broadcast ?

    Thanks in advice to anyone can help.


    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
    Quote Quote  
  17. Originally Posted by poisondeathray View Post
    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
    ...I barely understand, so I have another question: how about using tonemapping feature (known for HDRtoSDR) instead ?
    Quote Quote  
  18. Originally Posted by forart.it View Post
    Originally Posted by poisondeathray View Post
    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
    ...I barely understand, so I have another question: how about using tonemapping feature (known for HDRtoSDR) instead ?

    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
    Quote Quote  
  19. 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 use a test signal to check this stuff, attached.

    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)'"
    Here is how I "legalize" now:

    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
    Yes, I want a full-range file even though luma will be confined to 16 - 235, otherwise ffmpeg will alter the levels and do a poor job of it. Additionally, there could be highlights above 235 which I don't want ffmpeg to clip off. Remember, R 103 permits luma in the range 5 - 246.

    Image
    [Attachment 60022 - Click to enlarge]
    Quote Quote  
  20. Originally Posted by chris319 View Post

    Here is how I "legalize" now:

    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
    Yes, I want a full-range file even though luma will be confined to 16 - 235, otherwise ffmpeg will alter the levels and do a poor job of it. Additionally, there could be highlights above 235 which I don't want ffmpeg to clip off. Remember, R 103 permits luma in the range 5 - 246.

    Image
    [Attachment 60022 - Click to enlarge]


    This might work for your specific case, but a normal range signal becomes range compressed. This changes the contrast and colors. eg. Test on colorbars.
    Quote Quote  
  21. a normal range signal becomes range compressed.
    No, it doesn't. I tested that.
    Quote Quote  
  22. Originally Posted by chris319 View Post
    a normal range signal becomes range compressed.
    No, it doesn't. I tested that.


    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)
    Quote Quote  
  23. So how would you accomplish this legalization?
    Quote Quote  
  24. 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 18:23.
    Quote Quote  
  25. Member
    Join Date
    Apr 2018
    Location
    Croatia
    Search Comp PM
    How would vapoursynth deal with this issue?
    Quote Quote  
  26. Originally Posted by chris319 View Post
    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


    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
    Quote Quote  
  27. Originally Posted by richardpl View Post
    How would vapoursynth deal with this issue?

    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
    Quote Quote  
  28. you cannot tag a file "full range" for "legal" submissions
    Substantiation, please? Please cite any authoritative documentation that mandates limited-range flagging for submission.

    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.pdf
    Last edited by chris319; 26th Jul 2021 at 09:51.
    Quote Quote  
  29. 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 12:09.
    Quote Quote  
  30. Member
    Join Date
    Apr 2018
    Location
    Croatia
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Originally Posted by richardpl View Post
    How would vapoursynth deal with this issue?

    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
    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.
    Quote Quote  



Similar Threads