Skip to content
Snippets Groups Projects
Commit 2cdc71e2 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Fix supported vs available format descriptions

parent 3ea39232
No related branches found
No related tags found
No related merge requests found
......@@ -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");
......
......@@ -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()
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment