diff --git a/xbob/io/externals.cpp b/xbob/io/externals.cpp index 0f71821de70bcd7e6fc025ac1bef7bfb803406b4..73fb7ceccc78081d368a9bd87bb50c35ea071277 100644 --- a/xbob/io/externals.cpp +++ b/xbob/io/externals.cpp @@ -677,10 +677,11 @@ built-in input formats for videos that are available, but **not\n\ necessarily supported** by this library.\n\ "); -static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputFormat*>&)) { +static PyObject* get_video_oformats(bool supported) { std::map<std::string, AVOutputFormat*> m; - f(m); + if (supported) bob::io::detail::ffmpeg::oformats_supported(m); + else bob::io::detail::ffmpeg::oformats_installed(m); PyObject* retval = PyDict_New(); if (!retval) return 0; @@ -723,6 +724,7 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm } for (auto ext=exts.begin(); ext!=exts.end(); ++ext) { + if (!list_append(ext_list, ext->c_str())) { Py_DECREF(ext_list); Py_DECREF(property); @@ -763,30 +765,39 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm } /** get supported codec list **/ - std::vector<const AVCodec*> codecs; - bob::io::detail::ffmpeg::oformat_supported_codecs(k->second->name, codecs); - PyObject* supported_codecs = PyDict_New(); - for (auto c=codecs.begin(); c!=codecs.end(); ++c) { - PyObject* codec_descr = describe_codec(*c); - if (!codec_descr) { - Py_DECREF(supported_codecs); + if (supported) { + std::vector<const AVCodec*> codecs; + bob::io::detail::ffmpeg::oformat_supported_codecs(k->second->name, codecs); + + PyObject* supported_codecs = PyDict_New(); + if (!supported_codecs) { Py_DECREF(property); Py_DECREF(retval); return 0; } - if (!dict_steal(supported_codecs, (*c)->name, codec_descr)) { + + for (auto c=codecs.begin(); c!=codecs.end(); ++c) { + PyObject* codec_descr = describe_codec(*c); + if (!codec_descr) { + Py_DECREF(supported_codecs); + Py_DECREF(property); + Py_DECREF(retval); + return 0; + } + if (!dict_steal(supported_codecs, (*c)->name, codec_descr)) { + Py_DECREF(property); + Py_DECREF(retval); + return 0; + } + } + + if (!dict_steal(property, "supported_codecs", supported_codecs)) { Py_DECREF(property); Py_DECREF(retval); return 0; } } - if (!dict_steal(property, "supported_codecs", supported_codecs)) { - Py_DECREF(property); - Py_DECREF(retval); - return 0; - } - if (!dict_steal(retval, k->first.c_str(), property)) { Py_DECREF(retval); return 0; @@ -799,11 +810,11 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm } static PyObject* PyBobIo_SupportedOutputFormats(PyObject*) { - return get_video_oformats(&bob::io::detail::ffmpeg::oformats_supported); + return get_video_oformats(true); } static PyObject* PyBobIo_AvailableOutputFormats(PyObject*) { - return get_video_oformats(&bob::io::detail::ffmpeg::oformats_installed); + return get_video_oformats(false); } PyDoc_STRVAR(s_supported_oformats_str, "supported_videowriter_formats"); diff --git a/xbob/io/script/video_test.py b/xbob/io/script/video_test.py index b2f1008426b6f6d2ec908be9e9998940718f7701..f90bdebc56ea3c7fc7906fc9956537868a1f3349 100644 --- a/xbob/io/script/video_test.py +++ b/xbob/io/script/video_test.py @@ -44,6 +44,8 @@ def list_codecs(*args, **kwargs): def list_all_codecs(*args, **kwargs): + from .._externals import supported_video_codecs, available_video_codecs + CODECS = supported_video_codecs() ALL_CODECS = available_video_codecs() diff --git a/xbob/io/utils.py b/xbob/io/utils.py index 09fc46182f5af9b7ea3e2d3e8bf1c3df29ac6984..9e3d67b7f83120050dab2bf357cc72489bd4b5c7 100644 --- a/xbob/io/utils.py +++ b/xbob/io/utils.py @@ -61,7 +61,7 @@ def print_numbers(frame, counter, format, fontsize): img = Image.fromstring('RGB', (frame.shape[1], frame.shape[2]), frame.transpose(1,2,0).tostring()) draw = ImageDraw.Draw(img) draw.text((x_pos, y_pos), text, font=font, fill=(255,255,255)) - return numpy.asarray(img).transpose(2,0,1).copy() + return numpy.asarray(img).transpose(2,0,1) def generate_colors(height, width, shift): """Generates an image that serves as a test pattern for encoding/decoding and