[Libav-user] list all available formats of webcam
Hans, Sven
Sven.Hans at dermalog.com
Wed Apr 17 14:45:31 EEST 2019
Hi,
thank you for your support. Maybe you can help me a bit more:
I just tried the API, but without success.
The error is -40 (“function not implemented”) from
the function avdevice_capabilities_create. I use the libs/dlls released with ffmpeg 4.1.0 on Windows 10. My project is build with Visual Studio vc14_xp.
Maybe I did not initialize everything correctly or bad ordering of open input?
Please see my code:
const char* szUrl = "video=@device_pnp_\\?\usb#vid_046d&pid_082d&mi_00#7&1d276e35&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
// register all codecs and devices
av_register_all();
avcodec_register_all();
avdevice_register_all();
av_log_set_level(AV_LOG_ERROR); //turn off info and warning; only output error
AVFormatContext* m_pFormatCtxInCam = avformat_alloc_context();
AVInputFormat* m_pInFrmt = av_find_input_format("dshow");
AVDictionary *m_pInOptions = nullptr;
av_dict_set(&m_pInOptions, "video_size", "640x480", 0);
av_dict_set(&m_pInOptions, "framerate", "30", 0);
int ret = avformat_open_input(&m_pFormatCtxInCam, szUrl, m_pInFrmt, &m_pInOptions)
if(ret >= 0)
{
AVDeviceCapabilitiesQuery * pDevCap = nullptr;
AVOptionRanges * pPixFmtRange;
ret = avdevice_capabilities_create(&pDevCap, m_pFormatCtxInCam, nullptr);
if(ret >= 0)
{
if(av_opt_query_ranges(&pPixFmtRange, pDevCap, "pixel_format",
AV_OPT_MULTI_COMPONENT_RANGE) >= 0)
{
std::cout << "found some pixel formats" << std::endl;
}
av_opt_freep_ranges(&pPixFmtRange);
}
else
{
char szErrbuf[1024];
av_strerror(ret, szErrbuf, 1024);
}
avdevice_capabilities_free(&pDevCap, m_pFormatCtxInCam);
}
Mit freundlichen Grüßen / Best regards
Sven Hans
DERMALOG Identification Systems GmbH
Systems Engineer
Mittelweg 120 | 20148 Hamburg
Fon +49 40 413227 0
Fax +49-40-413227-40
Mail Sven.Hans at dermalog.com<mailto:Sven.Hans at dermalog.com>
Web www.dermalog.com<https://www.dermalog.com>
This e-mail may contain information that is confidential or proprietary to DERMALOG Identification Systems GmbH. Any unauthorized disclosure, distribution or other use is prohibited.
P Please consider the environment before printing this email
From: Libav-user <libav-user-bounces at ffmpeg.org> On Behalf Of Hristo Ivanov
Sent: Mittwoch, 17. April 2019 11:44
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. <libav-user at ffmpeg.org>
Subject: Re: [Libav-user] list all available formats of webcam
Hi.
Sorry, I think I got it wrong in my previous reply:
> I think there is no way to retrieve the information using the FFMPEG API.
There is this:
https://ffmpeg.org/doxygen/trunk/structAVDeviceCapabilitiesQuery.html
Quoting the docs:
> Following API allows user to probe device capabilities (supported codecs, pixel formats, sample formats, resolutions, channel counts, etc).
Give the above API a try.
> So the output in the console comes from the backend and not from ffmpeg?
Well, the output comes from ffmpeg, it gets printed with the av_log() function.
For the decklink '-listformats' flag, the output just gets printed and it is not stored in any structure(not even in the above API) from which it can be retrieved.
That is why I had to capture the log and then parse it.
> probably I have to implement this functionality directly with Dshow in Windows and v4l2 in Linux.
Doing this with the decklink API for my case would be a better solution than the one I currently have.
Regards.
________________________________
DERMALOG Identification Systems GmbH * Mittelweg 120, 20148 Hamburg, Germany
CEO/Managing Director: Günther Mull * Commercial Register: AG Hamburg HRB 69547
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190417/02b9088e/attachment.html>
More information about the Libav-user
mailing list