View Full Version : Script Format Problem
jay123210599
14th October 2024, 00:32
I want to encode videos, but I want to make sure it has the same aspects as the original. For example, I have a YUV444 video, and I want the output to also be a YUV444 video, even though the quality will not be the same due to encoding. My problem is that whenever I insert a script into other tools, it doesn't start at the colorspace as my video, it just starts at YUV420 instead). All of the video frames where also keyframes when I don't want them to. How do I fix that?
poisondeathray
14th October 2024, 14:50
I want to encode videos, but I want to make sure it has the same aspects as the original. For example, I have a YUV444 video, and I want the output to also be a YUV444 video, even though the quality will not be the same due to encoding. My problem is that whenever I insert a script into other tools, it doesn't start at the colorspace as my video, it just starts at YUV420 instead).
Pixel format should be the same, unless your script, filters, or tools such as encoder changed it
Post your script, list your tools and steps used
All of the video frames where also keyframes when I don't want them to. How do I fix that?
When you use a script, video is decoded to uncompressed frames. The original keyframes are "gone" because video is uncompressed. Another way of saying this is now every frame is a keyframe in the script or uncompressed state. When you re-encode you can place new keyframes, or you can control where you put new keyframes. Placing keyframes is a function of the encoder, not the script
jay123210599
17th October 2024, 13:13
Pixel format should be the same, unless your script, filters, or tools such as encoder changed it
Post your script, list your tools and steps used
When you use a script, video is decoded to uncompressed frames. The original keyframes are "gone" because video is uncompressed. Another way of saying this is now every frame is a keyframe in the script or uncompressed state. When you re-encode you can place new keyframes, or you can control where you put new keyframes. Placing keyframes is a function of the encoder, not the script
Here's my script and the information of my video inside it:
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Format settings, Slice count : 4 slices per frame
Codec ID : V_MPEG4/ISO/AVC
Duration : 24 min 27 s
Bit rate mode : Variable
Bit rate : 21.6 Mb/s
Maximum bit rate : 39.0 Mb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.435
Time code of first frame : 00:59:59:00
Stream size : 3.70 GiB (85%)
Language : English
Default : No
Forced : No
Original source medium : Blu-ray
poisondeathray
17th October 2024, 14:15
Color space : YUV
Chroma subsampling : 4:2:0
The source is YUV420 , not YUV444
Whenever you post a script, post the text just like you did with the mediainfo report - not an attachment - because attachments can sometimes take a long time to get approved
jay123210599
17th October 2024, 16:43
The source is YUV420 , not YUV444
Whenever you post a script, post the text just like you did with the mediainfo report - not an attachment - because attachments can sometimes take a long time to get approved
Sorry, wrong video. Here's the correct information:
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Format Range@L4@Main
Codec ID : V_MPEGH/ISO/HEVC
Duration : 23 min 43 s
Bit rate : 10.1 Mb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:4:4
Bit depth : 10 bits
Bits/(Pixel*Frame) : 0.203
Stream size : 1.67 GiB (87%)
Writing library : x265 3.0_Au+22-feec4bdf9866:[DJATOM's Mod][Linux][GCC 6.3.0][64 bit] 10bit
Encoding settings : cpuid=1111039 / frame-threads=2 / numa-pools= / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / csv / csv-log-level=2 / input-csp=3 / input-res=1920x1080 / interlace=0 / total-frames=34120 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=4 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-hrd / info / hash=0 / no-temporal-layers / open-gop / min-keyint=23 / keyint=240 / gop-lookahead=0 / bframes=9 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=20 / lookahead-slices=6 / scenecut=40 / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=2 / tu-intra-depth=2 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=2 / limit-refs=3 / limit-modes / me=2 / subme=5 / merange=48 / temporal-mvp / weightp / weightb / no-analyze-src-pics / deblock=1:-1 / no-sao / no-sao-non-deblock / rd=4 / no-early-skip / no-rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=4.00 / no-rd-refine / no-lossless / cbqpoffs=4 / crqpoffs=4 / rc=crf / crf=15.0 / qcomp=0.72 / qpstep=4 / stats-write=0 / stats-read=0 / ipratio=1.40 / pbratio=1.30 / aq-mode=3 / aq-strength=0.85 / no-cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=1 / transfer=1 / colormatrix=1 / chromaloc=0 / display-window=0 / max-cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / no-hdr / no-hdr-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=5 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=0 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / hevc-aq / no-svt / qp-adaptation-range=2.00
Language : Japanese
Default : Yes
Forced : No
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
And here's the script for it:
DirectShowSource(video.mkv)
SupTitle(subtitle.sup)
poisondeathray
17th October 2024, 16:47
The filter SupTitle only supports YV12 (4:2:0)
http://avisynth.nl/index.php/SupTitle
Supported color formats: YV12
FranceBB
17th October 2024, 22:03
Also, even before that, I'm sure that whatever decoder DirectShowSource() is using is converting it down to yv12 8bit. If it actually preserved 4:4:4 10bit Avisynth would have errored out when you tried to apply the SupTitle() function because - as poisondeathray said - it's yv12 only.
I'd suggest to:
1) Use a better indexer like LWLibavVideoSource() and LWLibavAudioSource()
2) Convert your subtitles to .ass with SubtitleEdit
3) Hardsub with an high bit depth capable filter like AssRender() or TextSub()
jay123210599
18th October 2024, 01:08
The filter SupTitle only supports YV12 (4:2:0)
http://avisynth.nl/index.php/SupTitle
Well, I put my YUV420 video in the script, but when I put it in a tool, it was at YUV420 when it was supposed to be YUV420-709.
poisondeathray
18th October 2024, 02:47
Well, I put my YUV420 video in the script, but when I put it in a tool, it was at YUV420 when it was supposed to be YUV420-709.
YUV420 is the essentially same thing as YUV420-709 . 709 just denotes the colorimetry flags . The underlying pixel values are the same. Flags are hints or "labels" - they don't change the actual underlying pixel data. You can override it to say "709" if you want, or set the flags in the source if they are missing, or set it later in the encoder. You can set it in the script too with propset, but not all tools read props from avisynth scripts
It could be that your tool chain used did not automatically read the flags correctly, or your source did not have the flags. For example the mediainfo report for the source in post #3 is missing the 709 flags. Normally it would say something like this, or at least the matrix :
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
jay123210599
18th October 2024, 04:31
YUV420 is the essentially same thing as YUV420-709 . 709 just denotes the colorimetry flags . The underlying pixel values are the same. Flags are hints or "labels" - they don't change the actual underlying pixel data. You can override it to say "709" if you want, or set the flags in the source if they are missing, or set it later in the encoder. You can set it in the script too with propset, but not all tools read props from avisynth scripts
It could be that your tool chain used did not automatically read the flags correctly, or your source did not have the flags. For example the mediainfo report for the source in post #3 is missing the 709 flags. Normally it would say something like this, or at least the matrix :
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
How do I make sure the script includes the 709 part?
poisondeathray
18th October 2024, 04:39
How do I make sure the script includes the 709 part?
It's most reliable to add it to the encoder , at the encoding step. Works 100% of the time and what I would do
Not all software will read the prop in the script (least reliable) , and not all tools will pass or read it from the source if you adjust the metadata for the source (depends on how you use the tools)
But if you wanted to add it to the script you can use PropSet
http://avisynth.nl/index.php/Internal_functions#Property_set
For example, for matrix, use propSet("_Matrix",1) for 709
You can use PropShow to see if it's added
If you wanted to patch the source to set metadata flags you can use a bitstream filter and remux the source
https://www.ffmpeg.org/ffmpeg-bitstream-filters.html#h264_005fmetadata
jay123210599
18th October 2024, 07:28
It's most reliable to add it to the encoder , at the encoding step. Works 100% of the time and what I would do
Not all software will read the prop in the script (least reliable) , and not all tools will pass or read it from the source if you adjust the metadata for the source (depends on how you use the tools)
But if you wanted to add it to the script you can use PropSet
http://avisynth.nl/index.php/Internal_functions#Property_set
For example, for matrix, use propSet("_Matrix",1) for 709
You can use PropShow to see if it's added
If you wanted to patch the source to set metadata flags you can use a bitstream filter and remux the source
https://www.ffmpeg.org/ffmpeg-bitstream-filters.html#h264_005fmetadata
I use Avidemux and VirtualDub2.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.