2 # Copyright (C) 2016-2020 by Nathan Lovato, Daniel Oakey, Razvan Radulescu, and contributors
4 # This file is part of Power Sequencer.
6 # Power Sequencer is free software: you can redistribute it and/or modify it under the terms of the
7 # GNU General Public License as published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
10 # Power Sequencer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with Power Sequencer. If
15 # not, see <https://www.gnu.org/licenses/>.
18 Add-on preferences and interface in the Blender preferences window.
23 from bpy
.props
import BoolProperty
, StringProperty
26 def get_preferences(context
):
27 return context
.preferences
.addons
[__package__
].preferences
30 class PowerSequencerPreferences(bpy
.types
.AddonPreferences
):
31 bl_idname
= __package__
33 proxy_25
: bpy
.props
.BoolProperty(name
="25%", default
=False)
34 proxy_50
: bpy
.props
.BoolProperty(name
="50%", default
=False)
35 proxy_75
: bpy
.props
.BoolProperty(name
="75%", default
=False)
36 proxy_100
: bpy
.props
.BoolProperty(name
="100%", default
=False)
38 # Code adapted from Krzysztof TrzciĆski's work
39 ffmpeg_executable
: StringProperty(
40 name
="Path to ffmpeg executable",
42 update
=lambda self
, context
: self
.update_ffmpeg_executable(context
),
45 ffmpeg_status
: StringProperty(default
="")
46 ffmpeg_is_executable_valid
: BoolProperty(default
=False)
48 def update_ffmpeg_executable(self
, context
):
49 error_message
, info
= self
._try
_run
_ffmpeg
(self
.ffmpeg_executable
)
50 self
.ffmpeg_is_executable_valid
= error_message
== ""
51 self
.ffmpeg_status
= error_message
if error_message
!= "" else info
53 def _try_run_ffmpeg(self
, path
):
54 """Runs ffmpeg -version, and returns an error message if it failed"""
55 error_message
, info
= "", ""
57 info
: str = subprocess
.check_output([path
, "-version"]).decode("utf-8")
58 info
= info
[: info
.find("Copyright")]
60 except (OSError, subprocess
.CalledProcessError
):
61 error_message
= "Path `{}` is not a valid ffmpeg executable".format(path
)
62 return error_message
, info
64 def draw(self
, context
):
67 layout
.label(text
="Proxy")
70 row
.prop(self
, "proxy_25")
71 row
.prop(self
, "proxy_50")
72 row
.prop(self
, "proxy_75")
73 row
.prop(self
, "proxy_100")
76 "(Optional) FFMpeg executable to use for multithread renders and proxy generation. "
77 "Use this to render with a version of ffmpeg that's not on your system's PATH variable."
80 layout
.label(text
=line
)
81 layout
.prop(self
, "ffmpeg_executable")
82 icon
= "INFO" if self
.ffmpeg_is_executable_valid
else "ERROR"
83 layout
.label(text
=self
.ffmpeg_status
, icon
=icon
)
86 register_preferences
, unregister_preferences
= bpy
.utils
.register_classes_factory(
87 [PowerSequencerPreferences
]