Renpy forcibly plays the video in the bt601 color space.

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Art4D
Newbie
Posts: 9
Joined: Fri Oct 08, 2021 3:33 pm
itch: launcher
Contact:

Renpy forcibly plays the video in the bt601 color space.

#1 Post by Art4D »

Hi. Renpy always plays videos in the bt601 color space, which is why videos in the bt709 color space distort colors.

Initially, I render the video in mp4 (x264) with the standard settings. Next I will convert it to Webm(vp8) using ffmpeg.

If I convert it with bt709 color space, then the video is displayed correctly everywhere, different browsers, different media players, but in Renpy the video gets color distortion.

Code: Select all

ffmpeg -i video.mp4 -c:v vp8 -crf 4 -b:v 30M -colorspace bt709 -color_primaries bt709 -color_trc bt709 -color_range pc -y video_709.webm

Code: Select all

METADATA: Video: vp8, yuv420p(pc, bt709, progressive), 2560x1440, SAR 1:1 DAR 16:9, 60 fps, 60 tbr, 1k tbn, 1k tbc (default)

If I convert it with the bt601 color space, then I need to additionally assign a filter -vf "colormatrix=bt709:smpte170m" so that the color matches the video with bt709. After conversion, the video will be displayed correctly in media players and renpy (without color distortion), but browsers will distort the color.

Code: Select all

ffmpeg -i video.mp4 -c:v vp8 -crf 4 -b:v 30M -colorspace smpte170m -color_primaries smpte170m -color_trc smpte170m -color_range pc -vf "colormatrix=bt709:smpte170m" -y video_601.webm

Code: Select all

METADATA: Video: vp8, yuv420p(pc, smpte170m, progressive), 2560x1440, SAR 1:1 DAR 16:9, 60 fps, 60 tbr, 1k tbn, 1k tbc (default)
*Smpte170m is BT.601 NTSC

Now I have to create two files in bt601 for renpy and bt709 for everything else.
I would like renpy to read the metadata and show the video in the color space that is specified in them. This will help to avoid distortion of colors.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Renpy forcibly plays the video in the bt601 color space.

#2 Post by PyTom »

I don't think color spaces is a direction that I want to take Ren'Py in, at least not any time soon. Most notably, because I don't completely understand them myself, and also because it seems like a way to lose information and quality, compared to dedicated tools. I'd suggest converting them into the RGB colorspace, like you are above, at which point Ren'Py will play them back properly.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Art4D
Newbie
Posts: 9
Joined: Fri Oct 08, 2021 3:33 pm
itch: launcher
Contact:

Re: Renpy forcibly plays the video in the bt601 color space.

#3 Post by Art4D »

PyTom wrote: Sat Oct 09, 2021 11:54 am I don't think color spaces is a direction that I want to take Ren'Py in, at least not any time soon. Most notably, because I don't completely understand them myself, and also because it seems like a way to lose information and quality, compared to dedicated tools. I'd suggest converting them into the RGB colorspace, like you are above, at which point Ren'Py will play them back properly.
The fact is that bt601 is already an outdated color space created for TV. For PC, bt709 is used almost everywhere.
It would be more logical to use bt709 by default, since most PC videos have this color space.

It definitely does not affect the quality of the video, only the color.
If the bt601 video is converted to bt709, it will have a yellowish tint.
If bt709 is converted to bt601, it will have a reddish tint. (as it is happening now in renpy).

But you're partly right, even browsers still can't display color spaces properly, for some reason, my Google Chrome converts my videos from bt601 to bt709 (a yellowish tint is added).

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Renpy forcibly plays the video in the bt601 color space.

#4 Post by Imperf3kt »

For some context, bt601 is SD colorspace, while bt709 is HD colorspace.
The difference is barely noticeable on anything less than a 10bit display (most monitors and TVs are 6bit) so it's not a huge issue in my opinion.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Art4D
Newbie
Posts: 9
Joined: Fri Oct 08, 2021 3:33 pm
itch: launcher
Contact:

Re: Renpy forcibly plays the video in the bt601 color space.

#5 Post by Art4D »

Imperf3kt wrote: Sat Oct 09, 2021 5:27 pm The difference is barely noticeable on anything less than a 10bit display
The difference is noticeable. I have an 8-bit monitor and I can clearly see this difference. I don't like that renpy puts a "red filter" on my videos.
Here is another user gave examples, you can take a look.
Imperf3kt wrote: Sat Oct 09, 2021 5:27 pm it's not a huge issue in my opinion.
Yes, this problem does not require an urgent solution.

tapanojum
Regular
Posts: 28
Joined: Tue Feb 27, 2018 4:33 am
Contact:

Re: Renpy forcibly plays the video in the bt601 color space.

#6 Post by tapanojum »

Sorry for resurrecting an old thread but I just found this after searching about this same issue. I find this to be a pretty noticeable issue when using Movie(play='movie.webm', start_image = 'image1.webp', image = 'image100.webp'). You can see at the exact point that the playback switches from video to image as the colors look noticeably different.

Does anyone have a good workflow for this? Any good open source software that can convert the renders to BT601 so that the playback matches? FFmpeg should handle single renders, right?

Thanks

edit: Nvm, I used Shutter Encoder to encode the video as OP did.

Post Reply

Who is online

Users browsing this forum: Google [Bot]