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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
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, 36 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
 

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 19:36.


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