File: sequencer_input_colorspace.py

package info (click to toggle)
blender 5.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 329,128 kB
  • sloc: cpp: 2,489,823; python: 349,859; ansic: 261,364; xml: 2,103; sh: 999; javascript: 317; makefile: 193
file content (63 lines) | stat: -rw-r--r-- 1,733 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# SPDX-FileCopyrightText: 2015-2025 Blender Authors
#
# SPDX-License-Identifier: Apache-2.0

# ./blender.bin --background --factory-startup \
#   --python tests/python/sequencer_input_colorspace.py -- --testdir tests/files/sequence_editing/

import bpy

import argparse
import sys
import unittest

from pathlib import Path

TEST_DIR: Path


class MovieInputTest(unittest.TestCase):
    def get_movie_colorspace(self, filepath: Path):
        scene = bpy.context.scene
        ed = scene.sequence_editor_create()
        strip = ed.strips.new_movie(name='input', filepath=str(filepath), channel=1, frame_start=1)
        colorspace = strip.colorspace_settings.name
        ed.strips.remove(strip)
        return colorspace


class FFmpegHDRColorspace(MovieInputTest):
    def test_pq(self):
        prefix = TEST_DIR / Path("ffmpeg") / "media"

        self.assertEqual(self.get_movie_colorspace(prefix / "hdr_simple_export_pq_12bit.mov"), "Rec.2100-PQ")

    def test_hlg(self):
        prefix = TEST_DIR / Path("ffmpeg") / "media"

        self.assertEqual(self.get_movie_colorspace(prefix / "hdr_simple_export_hlg_12bit.mov"), "Rec.2100-HLG")

    def test_p3(self):
        prefix = TEST_DIR / Path("ffmpeg") / "media"

        self.assertEqual(self.get_movie_colorspace(prefix / "sdr_simple_export_p3_aces_10bit.mov"), "Display P3")


def main():
    global TEST_DIR

    argv = [sys.argv[0]]
    if '--' in sys.argv:
        argv += sys.argv[sys.argv.index('--') + 1:]

    parser = argparse.ArgumentParser()
    parser.add_argument('--testdir', required=True, type=Path)

    args, remaining = parser.parse_known_args(argv)

    TEST_DIR = args.testdir
    unittest.main(argv=remaining)


if __name__ == "__main__":
    main()