Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 23rd January 2025, 23:18   #1  |  Link
Br4twurscht
Registered User
 
Join Date: Jul 2011
Posts: 10
Bad quality when hardcode pgs with core.sub.ImageFile

Hi,

because of issues with displaying some pgs and ass subtitles on my tv (with jellyfin), I want to change my encoding workflow and burn them directly into my encodes. I'm working very much years with StaxRip there it seems, that burn in pgs subs only works with VapourSynth. I also tried SupTitle by myself, but the result was very similar.

The crazy thing is, when I use the preview in StaxRip it look good, but after the encode, the text is not so smooth anymore, which is not nice on my screen, but definitely bad on my OLED TV.

The first picture is saved from inside the preview of StaxRip:


The second picture is saved from mpc-hc:


This is the resulting vs script:
Code:
  1: import os, sys
  2: import vapoursynth as vs
  3: core = vs.core
  4: 
  5: sys.path.append(r"E:\encoding\StaxRip-v2.44.2-x64\Apps\Plugins\VS\Scripts")
  6: core.std.LoadPlugin(r"E:\encoding\StaxRip-v2.44.2-x64\Apps\Plugins\VS\SubText\SubText.dll", altsearchpath=True)
  7: core.std.LoadPlugin(r"E:\encoding\StaxRip-v2.44.2-x64\Apps\Plugins\Dual\ffms2\ffms2.dll", altsearchpath=True)
  8: 
  9: tcFile = r"E:\encoding\test-movie_HardSubtest_neu\source_[No DV].mkv_temp\source_[No DV]_timestamps.txt" # timestamps file path
 10: clip = core.ffms2.Source(r"E:\encoding\test-movie_HardSubtest_neu\source_[No DV].mkv", cachefile=r"E:\encoding\test-movie_HardSubtest_neu\source_[No DV].mkv_temp\temp.ffindex", timecodes=tcFile) if os.path.exists(tcFile) else core.ffms2.Source(r"E:\encoding\test-movie_HardSubtest_neu\source_[No DV].mkv", cachefile=r"E:\encoding\test-movie_HardSubtest_neu\source_[No DV].mkv_temp\temp.ffindex")
 11: clip = core.sub.ImageFile(clip, file = r"E:\encoding\test-movie_HardSubtest_neu\source_[No DV].mkv_temp\ID1_[de] {FORCED [DIY]}_default_forced.sup")
 12: clip = core.std.Crop(clip, 0, 0, 276, 276)
 13: clip = core.resize.Bicubic(clip, 1920, 804)
 14: clip = clip[0:801]
 15: 
 16: clip.set_output()
And these are my x265 options (it's an hdr10):
Code:
--crf 18 --preset slow --output-depth 10 --ctu 32 --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)" --hdr10 --colorprim bt2020 --colormatrix bt2020nc --transfer smpte2084 --range limited --max-cll "763,218" --chromaloc 2 --repeat-headers --aud --hrd --selective-sao 2
Do you have an advice for me how to solve this?
If it's in avisynth, I would be happy, too. Currently, I'm still working with avisynth.

Edit: Some additional infos. If I play the original file and let the player show the pgs, then it looks pretty smooth regardless if on the pc with mpc-hc or on the tv with jellyfin.
I tried very much things to solve it by myself, but my knowledge gerading avs and vs is limited. Nevertheless, I tried some filters and also tried to blend it by myself regarding "Example with manual blending" on https://github.com/vapoursynth/subte...cs/subtext.rst

Maybe it's something with the color stuff, because of the 10bit HDR. But if there's a problem, then I'm lost. I'm very happy, that StaxRip does these configurations e.g. in x265 for me.

br
Br4twurscht
Attachments Pending Approval
File Type: png source_[No DV]_new_00200.png
File Type: png source_[No DV]_new_vapour_hardpgs_imageFile.mkv_snapshot_00.08.118.png

Last edited by Br4twurscht; 24th January 2025 at 12:28.
Br4twurscht is offline   Reply With Quote
Old 25th January 2025, 10:16   #2  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,564
Can't really help, since I never tried this, but you might want to upload the images somewhere else (i.e. imgbb.com, mediafire.com, google drive,..) and like to them, since attachments will require approval by a moderator, which can take ages,...)

My guess is the problem is that normally the subtitles are overlayed on the image after HDR is applied and not changed my the HDR data.
In the file you create, you integrate the subtitles into the desaturated version of your source (without HDR information) and then on playback the HDR information is applied to the whole frames which will also alter the colors of the subtitles.
My guess is one would need to add the subtitles to a blank clip, somehow (maybe some LUT) create a desaturated version of the subtitles and then combine them with the desaturated video, so that at playback the HDR info will adjust the color back to what they should look like.
=> best of luck

Cu Selur
__________________
Hybrid here in the forum, homepage, its own forum
Selur is offline   Reply With Quote
Old 25th January 2025, 22:40   #3  |  Link
Br4twurscht
Registered User
 
Join Date: Jul 2011
Posts: 10
The pictures

Preview in Stax-Rip:


After Encoding:


Thx for your guesses, but can I do this? When you see the images, do you still think it's the way you described?
Br4twurscht is offline   Reply With Quote
Old 26th January 2025, 07:28   #4  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,564
Quote:
but can I do this?
No clue what you can and can not do,..... ¯\_(ツ)_/¯
(like I said, I never tried that so no clue whether there is a known method to change this)

Quote:
hen you see the images, do you still think it's the way you described?
Hard to tell with white subtitles on black background. It seems like a difference in luma which could be caused by the above-mentioned (then the rest of the image would look correct) or just a difference in tv vs pc scale or using some wrong color matrix signaling (in these two cases the difference would be visible on the whole image). If the rest of the image looks correct, then what I described might be the issue.

Cu Selur
__________________
Hybrid here in the forum, homepage, its own forum
Selur is offline   Reply With Quote
Old 26th January 2025, 19:20   #5  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,834
Aliasing due to resizing after rendering ?
Code:
 11: clip = core.sub.ImageFile(clip, file = r"E:\encoding\test-movie_HardSubtest_neu\source_[No DV].mkv_temp\ID1_[de] {FORCED [DIY]}_default_forced.sup")
 12: clip = core.std.Crop(clip, 0, 0, 276, 276)
 13: clip = core.resize.Bicubic(clip, 1920, 804)
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."
Emulgator is offline   Reply With Quote
Old 29th January 2025, 09:37   #6  |  Link
Br4twurscht
Registered User
 
Join Date: Jul 2011
Posts: 10
Quote:
Originally Posted by Emulgator View Post
Aliasing due to resizing after rendering ?
Thx, but I think, that will not really help, because see next.


Quote:
Originally Posted by Selur View Post
My guess is the problem is that normally the subtitles are overlayed on the image after HDR is applied and not changed my the HDR data.
In the file you create, you integrate the subtitles into the desaturated version of your source (without HDR information) and then on playback the HDR information is applied to the whole frames which will also alter the colors of the subtitles.
I played a little bit with the display options of the mpc-hc regarding hdr an now I'm sure you're right, it's because of the hdr data applied afterwards on the subtitle.

So, firstly I want to understand better your proposal.

Quote:
Originally Posted by Selur View Post
My guess is one would need to add the subtitles to a blank clip, somehow (maybe some LUT) create a desaturated version of the subtitles and then combine them with the desaturated video, so that at playback the HDR info will adjust the color back to what they should look like.
I thought, that applying the desaturated version of the subtitles on the desaturated video is exactle what currently happens. And because of the hdr data, the subs are manipulated in the wrong way.

Or did you mean adding the (desaturaded) subs to the hdr saturated video? Is that even possible? And if yes, how?

Quote:
Originally Posted by Br4twurscht View Post
Thx for your guesses, but can I do this?
That was a typo . I wanted to ask (and still want to know ) how can I do this? Do you have a suggestion for a script?

Br and thx
Br4twurscht

Last edited by Br4twurscht; 29th January 2025 at 09:58.
Br4twurscht is offline   Reply With Quote
Old 29th January 2025, 18:14   #7  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,564
Quote:
I thought, that applying the desaturated version of the subtitles on the desaturated video is exactle what currently happens. And because of the hdr data, the subs are manipulated in the wrong way.

Or did you mean adding the (desaturaded) subs to the hdr saturated video? Is that even possible? And if yes, how?
atm. the subtitles that get to the desaturead video are the subtitle that normally get layed over the hdr video
My idea, no clue how to do it, would be to use some LUT on the subtitles clip which would do some destaturation which on playback would be nullified by the HDR metadata.

Cu Selur
__________________
Hybrid here in the forum, homepage, its own forum
Selur is offline   Reply With Quote
Old 30th January 2025, 12:17   #8  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 363
Use the matrix, primaries and transfer parameters of the subtitle filter?
Z2697 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 14:48.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.