1 # SPDX-License-Identifier: GPL-3.0-or-later
2 # Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
4 Add-on preferences and interface in the Blender preferences window.
9 from bpy
.props
import BoolProperty
, StringProperty
12 def get_preferences(context
):
13 return context
.preferences
.addons
[__package__
].preferences
16 class PowerSequencerPreferences(bpy
.types
.AddonPreferences
):
17 bl_idname
= __package__
19 proxy_25
: bpy
.props
.BoolProperty(name
="25%", default
=False)
20 proxy_50
: bpy
.props
.BoolProperty(name
="50%", default
=False)
21 proxy_75
: bpy
.props
.BoolProperty(name
="75%", default
=False)
22 proxy_100
: bpy
.props
.BoolProperty(name
="100%", default
=False)
24 # Code adapted from Krzysztof TrzciĆski's work
25 ffmpeg_executable
: StringProperty(
26 name
="Path to ffmpeg executable",
28 update
=lambda self
, context
: self
.update_ffmpeg_executable(context
),
31 ffmpeg_status
: StringProperty(default
="")
32 ffmpeg_is_executable_valid
: BoolProperty(default
=False)
34 def update_ffmpeg_executable(self
, context
):
35 error_message
, info
= self
._try
_run
_ffmpeg
(self
.ffmpeg_executable
)
36 self
.ffmpeg_is_executable_valid
= error_message
== ""
37 self
.ffmpeg_status
= error_message
if error_message
!= "" else info
39 def _try_run_ffmpeg(self
, path
):
40 """Runs ffmpeg -version, and returns an error message if it failed"""
41 error_message
, info
= "", ""
43 info
: str = subprocess
.check_output([path
, "-version"]).decode("utf-8")
44 info
= info
[: info
.find("Copyright")]
46 except (OSError, subprocess
.CalledProcessError
):
47 error_message
= "Path `{}` is not a valid ffmpeg executable".format(path
)
48 return error_message
, info
50 def draw(self
, context
):
53 layout
.label(text
="Proxy")
56 row
.prop(self
, "proxy_25")
57 row
.prop(self
, "proxy_50")
58 row
.prop(self
, "proxy_75")
59 row
.prop(self
, "proxy_100")
62 "(Optional) FFMpeg executable to use for multithread renders and proxy generation. "
63 "Use this to render with a version of ffmpeg that's not on your system's PATH variable."
66 layout
.label(text
=line
)
67 layout
.prop(self
, "ffmpeg_executable")
68 icon
= "INFO" if self
.ffmpeg_is_executable_valid
else "ERROR"
69 layout
.label(text
=self
.ffmpeg_status
, icon
=icon
)
72 register_preferences
, unregister_preferences
= bpy
.utils
.register_classes_factory(
73 [PowerSequencerPreferences
]