<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="arial, helvetica, sans-serif" color="#000000" style="background-color:rgb(255,255,255)">Hi.</font><div><font face="arial, helvetica, sans-serif" color="#000000" style="background-color:rgb(255,255,255)"><br></font><div><font face="arial, helvetica, sans-serif" color="#000000" style="background-color:rgb(255,255,255)">The different devices ffmpeg supports have different options, I am interested in the 'list_formats' of the decklink devices. Using the ffmpeg.exe tool the following command:</font></div><div><font face="arial, helvetica, sans-serif" color="#000000" style="background-color:rgb(255,255,255)"><br></font></div><div><font face="arial, helvetica, sans-serif" color="#000000" style="background-color:rgb(255,255,255)">    <span style="font-size:13px;text-align:justify">ffmpeg -f decklink -list_formats 1 -i 'Intensity Pro'</span></font></div><div><br></div><div>prints the formats that can be used with the device.</div><div><br></div><div>I want to recover this information from my program which uses the libav libraries. My current solution looks like this.</div><div><br></div><div><br></div><div>std::string formatListing;<br></div><div><br></div><div>int main(int argc, char* argv[]) {</div><div>    av_log_set_level(AV_LOG_VERBOSE);<br></div><div>    av_log_set_callback(my_log_callback);</div><div><br></div><div>    AVInputFormat* inpF = av_find_input_format("decklink");</div><div><div>    AVFormatContext* ifmt_ctx = avformat_alloc_context();</div><div>    AVDictionary* options = NULL;<br></div><div>    av_dict_set(&options, "list_formats", "1", NULL);</div><div><br></div><div>    avformat_open_input(&ifmt_ctx, deviceName.c_str(), inpF, &options);<br></div></div><div><br></div><div>    ........... // Parse the string in formatListing.</div><div>}<br></div><div><br></div><div><div>void my_log_callback(void *ptr, int level, const char *fmt, va_list vl) {</div><div>    AVClass* avc = ptr ? *(AVClass **) ptr : NULL;</div><div>    std::string className = avc ? avc->item_name(ptr) : "";</div><div><br></div><div>    if (className == "decklink") {</div><div>        char buf[500];</div><div>        vsnprintf(buf, 500, fmt, vl);</div><div>        formatListing += buf;</div><div>    }</div><div><br></div><div>    if (avc != NULL)</div><div>        const char* aux = avc->item_name(ptr);</div><div><br></div><div>    av_log_default_callback(ptr, level, fmt, vl);</div><div>}</div></div></div><div><br></div><div><br></div><div>This code works fine, but I don't like it. Is there a more elegant solution to this which doesn't involve a log callback?</div><div><br></div><div>Thanks.</div></div></div></div></div></div></div></div></div>