mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
OP-2860 - extracted get_fps function to lib
This commit is contained in:
parent
5de5a8bd18
commit
650260309e
2 changed files with 21 additions and 19 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import platform
|
|||
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")
|
||||
|
|
@ -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 = []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue