If I run an AVS script using FFMPEG, there will' be a slight change to the overall colour of the video. This does not happening using VirtualDub(2), with default settings and x264 8 bit encoder.
This is the ffmpeg command:
ffmpeg.exe -i test.avs -crf 16 "%%~F.mp4"
Does anybody know how to fix this? I had this issue before with hybrid and it ended up being VUI settings, idk if that's even a thing with FFMPEG though (only reason I'm using FFMPEG is I have about 100 AVS files to process so need something automatic).
(I didn't post the AVS script as it works fine in virtualdub, so presumably it has nothing to do with the script, but rather the encoder. If seeing the script would be useful I can post it though)
+ Reply to Thread
Results 1 to 6 of 6
-
-
Code:
LWLibavVideoSource("C:\Users\ME\Documents\Video Processing\test.mkv") #ConvertToYV24() nnedi3_rpow2(2, cshift="LanczosResize", fwidth=720, fheight=404) aWarpSharp2(depth=3) Sharpen(0.3) nnedi3_rpow2(2, cshift="LanczosResize", fwidth=1280, fheight=718) aWarpSharp2(depth=5) Sharpen(0.5) #ConvertToYV12()
Input Video:
Code:General Unique ID : 152948037013579271062902687678894660881 (0x7310B86EE28BA6AA2B942790AC3B5D11) Complete name : C:\Users\bradw\Documents\Video Processing\test.mkv Format : Matroska Format version : Version 4 File size : 514 KiB Duration : 6 s 465 ms Overall bit rate : 651 kb/s Writing application : Lavf58.29.100 Writing library : Lavf58.29.100 ErrorDetectionType : Per level 1 Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : High@L3 Format settings : CABAC / 5 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 5 frames Codec ID : V_MPEG4/ISO/AVC Duration : 6 s 465 ms Width : 720 pixels Height : 404 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 23.976 (23976/1000) FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Writing library : x264 core 125 r2200 999b753 Encoding settings : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=8 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=crf / mbtree=1 / crf=26.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Default : Yes Forced : No
Code:General Unique ID : 222650574584730242227513090272354369807 (0xA780F0DD09C8BCB89E12964A1850010F) Complete name : C:\Users\bradw\Documents\Video Processing\Z20 no yv.mkv Format : Matroska Format version : Version 4 File size : 1.78 MiB Duration : 6 s 465 ms Overall bit rate : 2 310 kb/s Writing application : Lavf59.3.100 Writing library : Lavf59.3.100 ErrorDetectionType : Per level 1 Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : High@L3.1 Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Codec ID : V_MPEG4/ISO/AVC Duration : 6 s 465 ms Bit rate : 2 264 kb/s Width : 1 280 pixels Height : 718 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 23.976 (23976/1000) FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.103 Stream size : 1.74 MiB (98%) Writing library : x264 core 164 r3065 ae03d92 Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=9 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=20.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Default : Yes Forced : No
Code:General Unique ID : 244083759067673380596137552171647956075 (0xB7A0D2720BC3B0AC461BC8978C78F46B) Complete name : C:\Users\bradw\Documents\Video Processing\dub.mkv Format : Matroska Format version : Version 4 File size : 1.72 MiB Duration : 6 s 548 ms Overall bit rate : 2 208 kb/s Writing application : Lavf57.79.100 Writing library : Lavf57.79.100 ErrorDetectionType : Per level 1 Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : High@L3.1 Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Codec ID : V_MPEG4/ISO/AVC Duration : 6 s 465 ms Bit rate : 2 164 kb/s Width : 1 280 pixels Height : 718 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 23.976 (23976/1000) FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.098 Stream size : 1.67 MiB (97%) Writing library : x264 core 157 r2935M 545de2f Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=9 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=20.3 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Default : Yes Forced : No Color range : Limited Matrix coefficients : BT.470 System B/G
-
1) If you use 2 instances of software players, often they might be using different renders. eg. One might be EVR, one might be using MadVR or Overlay or etc.... This can result in vastly different brightness and colors.
2) Usually when you upscale, you perform a 601=>709 matrix conversion, and flag it as 709 because:
2a) many players and devices ignore flags and determine color by height. For "SD" they use 601, for "HD" they use 709
2b) but some pay attention to flags in order of priority, then by height, otherwise 601.
So doing both covers practically all cases. Also, by convention "HD" uses 709. 99.9% of commercial and consumer HD sources use 709, so it's the "right" thing to do and expected
In the script
Code:ColorMatrix(mode="rec.601->rec.709", clamp=0)
Code:-x264opts colormatrix=bt709
Note the vdub case is flagged as BT.470, so that's technically correct - it's the "wrong" color for HD, but your source wasn't changed to 709 color (ie the flag is correct for the video). Some players will ignore the flag and play it as 709 and the colors will look incorrect. But some will pay attention to the flag, and the colors will look correct. (I'd rather have it correct in both cases, not just some of the time) -
Thanks, adding those to the file and command line worked! Where is the best place to add the line to the AVS script? I will have to uncomment the "convert to yvXX" lines as they are needed for some of the files (some of them don't have "mod 4" dimensions or something. Would it be best to add the colourmatrix command at the very end after all other lines?
-
Try HDRMatrix. https://www.videoartifact.com/hdr/
I'm pretty sure it supports all YUV formats except for YUY2.
Matrix(From=601, To=709)
It seems to be better in respect to not causing any color banding, compared to ColorMatrix (not that ColorMatrix is bad).
I tend to convert the colors before resizing (when upscaling) as I guess it should be faster than doing it after upscaling, but in practice I don't think it matters.
As a side note, this might save you having to do convert to YV24 and back.
Code:function CropMod4Width(clip Source) { ModFourWidth = \ (((FindStr(LCase(VersionString()), "avisynth+") > 0) || (FindStr(LCase(VersionString()), "avisynth neo") > 0)) && \ (Is420(Source) || Is422(Source))) || IsYV12(Source) || IsYV16(Source) || IsYUY2(Source) || IsYV411(Source) return !ModFourWidth ? Source : (width(Source) % 4 == 0) ? Source : Source.Crop(2,0,0,0) }
CropMod4Width()
nnedi3_rpow2(2, cshift="LanczosResize", fwidth=720, fheight=404)Last edited by hello_hello; 3rd Jul 2021 at 06:16.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview)
Similar Threads
-
FFMPEG 10bit output video colour difference
By iKron in forum Video ConversionReplies: 11Last Post: 12th May 2021, 17:53 -
AVFS serves garbled/slanted video even when AVS script plays fine
By Jellybit in forum Video ConversionReplies: 2Last Post: 2nd Aug 2020, 10:37 -
Creating AVS script in MeGui
By Manxsee in forum Video ConversionReplies: 2Last Post: 12th Jun 2018, 12:24 -
Creating AVS script in MeGui . .
By Manxsee in forum Newbie / General discussionsReplies: 1Last Post: 12th Jun 2018, 11:31 -
Importing Avs script in premiere
By Digital85 in forum Newbie / General discussionsReplies: 30Last Post: 2nd Mar 2018, 00:04