Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
OP-2860 - extracted get_fps function to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
kalisp committed Mar 8, 2022
1 parent 5de5a8b commit 6502603
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
20 changes: 20 additions & 0 deletions openpype/lib/vendor_bin_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,23 @@ def is_oiio_supported():
))
return False
return True


def get_fps(str_value):
"""Returns (str) value of fps from ffprobe frame format (120/1)"""
if str_value == "0/0":
print("WARNING: Source has \"r_frame_rate\" value set to \"0/0\".")
return "Unknown"

items = str_value.split("/")
if len(items) == 1:
fps = float(items[0])

elif len(items) == 2:
fps = float(items[0]) / float(items[1])

# Check if fps is integer or float number
if int(fps) == fps:
fps = int(fps)

return str(fps)
20 changes: 1 addition & 19 deletions openpype/scripts/otio_burnin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import opentimelineio_contrib.adapters.ffmpeg_burnins as ffmpeg_burnins
import openpype.lib
from openpype.lib.vendor_bin_utils import get_fps


ffmpeg_path = openpype.lib.get_ffmpeg_tool_path("ffmpeg")
Expand Down Expand Up @@ -50,25 +51,6 @@ def _get_ffprobe_data(source):
return json.loads(out)


def get_fps(str_value):
if str_value == "0/0":
print("WARNING: Source has \"r_frame_rate\" value set to \"0/0\".")
return "Unknown"

items = str_value.split("/")
if len(items) == 1:
fps = float(items[0])

elif len(items) == 2:
fps = float(items[0]) / float(items[1])

# Check if fps is integer or float number
if int(fps) == fps:
fps = int(fps)

return str(fps)


def _prores_codec_args(stream_data, source_ffmpeg_cmd):
output = []

Expand Down

0 comments on commit 6502603

Please sign in to comment.