ges: Output otio formatter loading issues in debug logs

Instead of spamming the terminal with a python traceback

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/issues/107

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/173>
This commit is contained in:
Thibault Saunier 2020-05-04 10:35:25 -04:00 committed by GStreamer Merge Bot
parent 5c05b4942e
commit 154816365f
2 changed files with 42 additions and 28 deletions

View file

@ -617,7 +617,26 @@ load_python_formatters (void)
Py_XDECREF (code);
Py_XDECREF (res);
if (PyErr_Occurred ()) {
PyErr_Print ();
PyObject *exception_backtrace;
PyObject *exception_type;
PyObject *exception_value, *exception_value_repr, *exception_value_str;
PyErr_Fetch (&exception_type, &exception_value, &exception_backtrace);
PyErr_NormalizeException (&exception_type, &exception_value,
&exception_backtrace);
exception_value_repr = PyObject_Repr (exception_value);
exception_value_str =
PyUnicode_AsEncodedString (exception_value_repr, "utf-8", "Error ~");
GST_INFO ("Could not load OpenTimelineIO formatter: %s",
PyBytes_AS_STRING (exception_value_str));
Py_XDECREF (exception_type);
Py_XDECREF (exception_value);
Py_XDECREF (exception_backtrace);
Py_XDECREF (exception_value_repr);
Py_XDECREF (exception_value_str);
PyErr_Clear ();
}

View file

@ -21,12 +21,8 @@ from gi.repository import GES
from gi.repository import GLib
from collections import OrderedDict
try:
import opentimelineio as otio
otio.adapters.from_name('xges')
except Exception as e:
Gst.info("Could not load OpenTimelineIO: %s" % e)
otio = None
import opentimelineio as otio
otio.adapters.from_name('xges')
class GESOtioFormatter(GES.Formatter):
def do_save_to_uri(self, timeline, uri, overwrite):
@ -81,27 +77,26 @@ class GESOtioFormatter(GES.Formatter):
timeline.get_asset().add_formatter(formatter)
return formatter.load_from_uri(timeline, "file://" + tmpxges.name)
if otio is not None:
GObject.type_register(GESOtioFormatter)
known_extensions_mimetype_map = [
("otio", "xml", "fcpxml"),
("application/vnd.pixar.opentimelineio+json", "application/vnd.apple-xmeml+xml", "application/vnd.apple-fcp+xml")
]
GObject.type_register(GESOtioFormatter)
known_extensions_mimetype_map = [
("otio", "xml", "fcpxml"),
("application/vnd.pixar.opentimelineio+json", "application/vnd.apple-xmeml+xml", "application/vnd.apple-fcp+xml")
]
extensions = []
for adapter in otio.plugins.ActiveManifest().adapters:
if adapter.name != 'xges':
extensions.extend(adapter.suffixes)
extensions = []
for adapter in otio.plugins.ActiveManifest().adapters:
if adapter.name != 'xges':
extensions.extend(adapter.suffixes)
extensions_mimetype_map = [[], []]
for i, ext in enumerate(known_extensions_mimetype_map[0]):
if ext in extensions:
extensions_mimetype_map[0].append(ext)
extensions_mimetype_map[1].append(known_extensions_mimetype_map[1][i])
extensions.remove(ext)
extensions_mimetype_map[0].extend(extensions)
extensions_mimetype_map = [[], []]
for i, ext in enumerate(known_extensions_mimetype_map[0]):
if ext in extensions:
extensions_mimetype_map[0].append(ext)
extensions_mimetype_map[1].append(known_extensions_mimetype_map[1][i])
extensions.remove(ext)
extensions_mimetype_map[0].extend(extensions)
GES.FormatterClass.register_metas(GESOtioFormatter, "otioformatter",
"GES Formatter using OpenTimelineIO",
','.join(extensions_mimetype_map[0]),
';'.join(extensions_mimetype_map[1]), 0.1, Gst.Rank.SECONDARY)
GES.FormatterClass.register_metas(GESOtioFormatter, "otioformatter",
"GES Formatter using OpenTimelineIO",
','.join(extensions_mimetype_map[0]),
';'.join(extensions_mimetype_map[1]), 0.1, Gst.Rank.SECONDARY)