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 18th July 2023, 06:19   #1  |  Link
SilSinn9801
Chiptuner & VapourSynther
 
SilSinn9801's Avatar
 
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
FFMS2 changing RGB values when importing palette-indexed BMP/PNG files

I don’t know if this is a bug in VapourSynth R63 or in FFMS2 3.0.1.0 1325+16 6ad7738, but basically when importing (via core.ffms2.Source) indexed BMP or PNG images (that is, images whose pixels don’t store RGB color values but rather indices to a color palette stored in the files’ metadata), some of their pixels’ RGB color values get changed to slightly-different values, even when they’re imported in RGB24 mode (rather than a YUV or YCbCr mode). (This problem does not happen at all with regular RGB24 BMP/PNG files where RGB values are stored directly in the pixels themselves instead of in a palette.)
Attached to this thread is a ZIP with two visually-identical 16×16-pixel BMP files where each pixel is a different shade of gray (out of the 256 values allowed in GRAY8). Y8_index.bmp is the indexed or palettized version (8-bit grayscale palette, 256 indices), while Y8_rgb.bmp is the RGB24-mode version. This is the VPY script I am running to test VapourSynth & FFMS2’s behavior when handling indexed images vs. RGB24 images:
Code:
import vapoursynth as vs
from vapoursynth import core

Y8_index = core.ffms2.Source(r'Y8_index.bmp',fpsnum=60,fpsden=1)
Y8_rgb = core.ffms2.Source(r'Y8_rgb.bmp',fpsnum=60,fpsden=1)

FinalVideo = Y8_index*60+Y8_rgb*60
FinalVideo.set_output()
Using VirtualDub2 build 44282 as the VapourSynth visualizer (& Python 3.11), I see that the following 36 RGB values from Y8_index get changed to the following (darker or lighter) values at the output:
  • #040404 → #030303 (darker)
  • #0b0b0b → #0a0a0a ("")
  • #121212 → #111111
  • #191919 → #181818
  • #202020 → #1f1f1f
  • #272727 → #262626
  • #2e2e2e → #2f2f2f (lighter)
  • #353535 → #363636 ("")
  • #3c3c3c → #3d3d3d
  • #434343 → #444444
  • #4a4a4a → #4b4b4b
  • #515151 → #525252
  • #595959 → #585858 (darker)
  • #606060 → #5f5f5f ("")
  • #676767 → #666666
  • #6e6e6e → #6d6d6d
  • #757575 → #747474
  • #7c7c7c → #7b7b7b
  • #838383 → #848484 (lighter)
  • #8a8a8a → #8b8b8b ("")
  • #919191 → #929292
  • #989898 → #999999
  • #9f9f9f → #a0a0a0
  • #a6a6a6 → #a7a7a7
  • #aeaeae → #adadad (darker)
  • #b5b5b5 → #b4b4b4 ("")
  • #bcbcbc → #bbbbbb
  • #c3c3c3 → #c2c2c2
  • #cacaca → #c9c9c9
  • #d1d1d1 → #d0d0d0
  • #d8d8d8 → #d7d7d7
  • #dfdfdf → #e0e0e0 (lighter)
  • #e6e6e6 → #e7e7e7 ("")
  • #ededed → #eeeeee
  • #f4f4f4 → #f5f5f5
  • #fbfbfb → #fcfcfc
Attached Files
File Type: zip Y8_bmp.zip (2.0 KB, 33 views)
__________________
SilSinn9801 a.k.a. Silent Sinner in Scarlet
Discord: silsinn9801
Matrix: silsinn9821:matrix.org
YouTube: https://youtube.com/SilentSinnerInScarlet
ニコニコ動画: https://nicovideo.jp/user/68029427
SilSinn9801 is offline   Reply With Quote
Old 19th July 2023, 01:05   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,416
Attachments can take a while to get approved, consider using a 3rd party hosting site like mediafire, google drive , etc..

Did you test any other source filters ? LSmash, ImageMagick ?
poisondeathray is offline   Reply With Quote
Old 19th July 2023, 07:12   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,981
How to upload pictures
https://forum.doom9.org/showthread.php?p=1959414
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 19th July 2023, 14:25   #4  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,575
Or just create issues on github and attach it there. I have vowed to ignore all other types of bug reports.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 1st August 2023, 07:12   #5  |  Link
SilSinn9801
Chiptuner & VapourSynther
 
SilSinn9801's Avatar
 
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
Sorry for late reply (real-life issues + my daily work). Here is the attachment but in Google Drive: https://drive.google.com/file/d/1DcH...usp=drive_link
__________________
SilSinn9801 a.k.a. Silent Sinner in Scarlet
Discord: silsinn9801
Matrix: silsinn9821:matrix.org
YouTube: https://youtube.com/SilentSinnerInScarlet
ニコニコ動画: https://nicovideo.jp/user/68029427
SilSinn9801 is offline   Reply With Quote
Old 1st August 2023, 07:14   #6  |  Link
SilSinn9801
Chiptuner & VapourSynther
 
SilSinn9801's Avatar
 
Join Date: Mar 2019
Location: Scarlet Devil Mansion, Gensōkyō
Posts: 52
I haven’t had time either to test this using a newer version of FFMS2 & see if the issue is a VapourSynth problem or a FFMS2 problem, hence why I specified in my original post the FFMS2 version I used.
__________________
SilSinn9801 a.k.a. Silent Sinner in Scarlet
Discord: silsinn9801
Matrix: silsinn9821:matrix.org
YouTube: https://youtube.com/SilentSinnerInScarlet
ニコニコ動画: https://nicovideo.jp/user/68029427
SilSinn9801 is offline   Reply With Quote
Reply

Tags
ffms2, indexed palette, rgb24, vapoursynth

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 07:51.


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