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\ ...@@ -677,10 +677,11 @@ built-in input formats for videos that are available, but **not\n\
necessarily supported** by this library.\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; 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(); PyObject* retval = PyDict_New();
if (!retval) return 0; if (!retval) return 0;
...@@ -723,6 +724,7 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm ...@@ -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) { for (auto ext=exts.begin(); ext!=exts.end(); ++ext) {
if (!list_append(ext_list, ext->c_str())) { if (!list_append(ext_list, ext->c_str())) {
Py_DECREF(ext_list); Py_DECREF(ext_list);
Py_DECREF(property); Py_DECREF(property);
...@@ -763,9 +765,17 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm ...@@ -763,9 +765,17 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm
} }
/** get supported codec list **/ /** get supported codec list **/
if (supported) {
std::vector<const AVCodec*> codecs; std::vector<const AVCodec*> codecs;
bob::io::detail::ffmpeg::oformat_supported_codecs(k->second->name, codecs); bob::io::detail::ffmpeg::oformat_supported_codecs(k->second->name, codecs);
PyObject* supported_codecs = PyDict_New(); PyObject* supported_codecs = PyDict_New();
if (!supported_codecs) {
Py_DECREF(property);
Py_DECREF(retval);
return 0;
}
for (auto c=codecs.begin(); c!=codecs.end(); ++c) { for (auto c=codecs.begin(); c!=codecs.end(); ++c) {
PyObject* codec_descr = describe_codec(*c); PyObject* codec_descr = describe_codec(*c);
if (!codec_descr) { if (!codec_descr) {
...@@ -786,6 +796,7 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm ...@@ -786,6 +796,7 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm
Py_DECREF(retval); Py_DECREF(retval);
return 0; return 0;
} }
}
if (!dict_steal(retval, k->first.c_str(), property)) { if (!dict_steal(retval, k->first.c_str(), property)) {
Py_DECREF(retval); Py_DECREF(retval);
...@@ -799,11 +810,11 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm ...@@ -799,11 +810,11 @@ static PyObject* get_video_oformats(void (*f)(std::map<std::string, AVOutputForm
} }
static PyObject* PyBobIo_SupportedOutputFormats(PyObject*) { 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*) { 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"); PyDoc_STRVAR(s_supported_oformats_str, "supported_videowriter_formats");
......
...@@ -44,6 +44,8 @@ def list_codecs(*args, **kwargs): ...@@ -44,6 +44,8 @@ def list_codecs(*args, **kwargs):
def list_all_codecs(*args, **kwargs): def list_all_codecs(*args, **kwargs):
from .._externals import supported_video_codecs, available_video_codecs
CODECS = supported_video_codecs() CODECS = supported_video_codecs()
ALL_CODECS = available_video_codecs() ALL_CODECS = available_video_codecs()
......
...@@ -61,7 +61,7 @@ def print_numbers(frame, counter, format, fontsize): ...@@ -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()) img = Image.fromstring('RGB', (frame.shape[1], frame.shape[2]), frame.transpose(1,2,0).tostring())
draw = ImageDraw.Draw(img) draw = ImageDraw.Draw(img)
draw.text((x_pos, y_pos), text, font=font, fill=(255,255,255)) 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): def generate_colors(height, width, shift):
"""Generates an image that serves as a test pattern for encoding/decoding and """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.
Please register or to comment