diff options
author | Richard Antalik <richardantalik@gmail.com> | 2019-06-19 20:49:37 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2019-06-19 20:49:37 +0300 |
commit | da83f70754b6e5eb6d96b94b0d1d554bdb9120fd (patch) | |
tree | 8bdca28ee2af167a323c81fe4b85644bed1fa55a /release/scripts/modules/bpy | |
parent | f47c9ad96fdd84d71d3d43a43621b358cf1273de (diff) |
Fix T65398 - Fix frame rate base use in Python SMPTE functions
Differential Revision: https://developer.blender.org/D5064
Reviewed By: brecht
Diffstat (limited to 'release/scripts/modules/bpy')
-rw-r--r-- | release/scripts/modules/bpy/utils/__init__.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py index c96b0b88c6b..e6424de0742 100644 --- a/release/scripts/modules/bpy/utils/__init__.py +++ b/release/scripts/modules/bpy/utils/__init__.py @@ -450,12 +450,12 @@ def preset_paths(subdir): return dirs -def smpte_from_seconds(time, fps=None): +def smpte_from_seconds(time, fps=None, fps_base=None): """ Returns an SMPTE formatted string from the *time*: ``HH:MM:SS:FF``. - If the *fps* is not given the current scene is used. + If *fps* and *fps_base* are not given the current scene is used. :arg time: time in seconds. :type time: int, float or ``datetime.timedelta``. @@ -463,7 +463,11 @@ def smpte_from_seconds(time, fps=None): :rtype: string """ - return smpte_from_frame(time_to_frame(time, fps=fps), fps) + return smpte_from_frame( + time_to_frame(time, fps=fps, fps_base=fps_base), + fps=fps, + fps_base=fps_base + ) def smpte_from_frame(frame, fps=None, fps_base=None): @@ -485,8 +489,9 @@ def smpte_from_frame(frame, fps=None, fps_base=None): if fps_base is None: fps_base = _bpy.context.scene.render.fps_base + fps = fps / fps_base sign = "-" if frame < 0 else "" - frame = abs(frame * fps_base) + frame = abs(frame) return ( "%s%02d:%02d:%02d:%02d" % ( @@ -516,9 +521,11 @@ def time_from_frame(frame, fps=None, fps_base=None): if fps_base is None: fps_base = _bpy.context.scene.render.fps_base + fps = fps / fps_base + from datetime import timedelta - return timedelta(0, (frame * fps_base) / fps) + return timedelta(0, frame / fps) def time_to_frame(time, fps=None, fps_base=None): @@ -540,12 +547,14 @@ def time_to_frame(time, fps=None, fps_base=None): if fps_base is None: fps_base = _bpy.context.scene.render.fps_base + fps = fps / fps_base + from datetime import timedelta if isinstance(time, timedelta): time = time.total_seconds() - return (time / fps_base) * fps + return time * fps def preset_find(name, preset_path, display_name=False, ext=".py"): |