View Full Version : How do I get Avisynth to treat a file as a full range?
rgr
24th August 2022, 12:15
I have a file encoded with UTVideo codec (lossless, YUV, full range colors).
I load it with the command:
ffms2("file.avi")
1. There is no color range information in the header and AviSynth treats it as a limited range. How can I make AviSynth treat this file as full range?
2. How can I make AviSynth generate the output file as full range color? MPC-HE assumes that the file is in the range 16-235 when played back.
FranceBB
24th August 2022, 13:27
To populate frame properties correctly inside Avisynth, you can use:
propSet("_ColorRange", 0)
this will set Full PC Range.
If you're encoding the output, make sure to flag it correctly.
For instance, if you're re-encoding to H.265 with x265 you can use --range full while if you're using x264 or x262 to encode in H.264 or MPEG-2 you can use --range pc.
If you're using FFMpeg to encode to something else (ProRes, DNX, AV1, VP9 etc) you can use -color_range 0
DTL
24th August 2022, 18:04
AVS do not treat or change the range itself. AVS moves the frames buffers between filters and in/out (using some caching). It is task for each internal filter or external plugin to treat incoming format as having some range mapping (using some hints or internal defaults or some metadata signalling like frame properties of direct user-provided fliter params). So user need to read documentation and understand expected result of each used filter. The range mapping conversion may be done with ConvertBits() with fulls,fulld params.
"How can I make AviSynth treat this file as full range?"
Read documentation on the sink filter (used to request data from ffms2() ).
"2. How can I make AviSynth generate the output file as full range color?"
Make sure final source filter in the script outputs full range. (or the filter to make source for 'return' command if it used). AVS typically not generate file - only serves as a frame source for some sink process. So it is a task of the sink process to treat provided 8 or 16 (or 32) bit samples as having some range mapping.
hello_hello
24th August 2022, 21:15
2. How can I make AviSynth generate the output file as full range color? MPC-HE assumes that the file is in the range 16-235 when played back.
YUV is normally limited range, so if you're re-encoding that's what you probably want it to be. If FFMS2 is decoding it as full range and the player is treating it as limited range, it probably looks too dark and/or with too much contrast. If FFMS is converting it to limited range it should look okay, but I assume it doesn't?
If it's full range you can use the V.U.I range argument in the encoder command line and cross your fingers the player pays attention to it. For x264 and full range it's --range pc, but I don't think there's a way to flag the output as full range when opening a script directly with a media player.
Levels adjusts the luma and chroma, so from memory the color saturation will change as a result. Sometimes that's a good thing.
http://avisynth.nl/index.php/Levels
Full to limited range conversion (values for 8 bit video).
Levels(0, 1.0, 255, 16, 235, coring=false)
Limited to full range.
Levels(16, 1.0, 235, 0, 255, coring=false)
Alternatively, YLevels only adjust the luma.
http://avisynth.nl/index.php/Ylevels
Full to limited range.
YLevels(0, 1.0, 255, 16, 235)
Limited to full range.
YLevels(16, 1.0, 235, 0, 255)
ColorYUV.
http://avisynth.nl/index.php/ColorYUV
ColorYUV(Levels="TV->PC")
ColorYUV(Levels="PC->TV")
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.