Probe hardware devices.
Probe hardware devices.
#include <iostream>
#include <string>
namespace {
const char* codecName(
const av::Codec& codec)
{
return codec.
raw() ? codec.
name() :
"none";
}
std::string pixelFormatName(AVPixelFormat format)
{
if (format == AV_PIX_FMT_NONE)
return "none";
std::error_code ec;
return ec ? "invalid" : name;
}
void printConfigs(
const av::Codec& codec,
const char* title)
{
std::cout << " " << title << " (" << codecName(codec) << "):";
std::cout << " none\n";
return;
}
bool first = true;
std::cout << (first ? " " : ", ")
<< '/'
<< pixelFormatName(config.pix_fmt);
if (config.methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)
std::cout << "+device";
if (config.methods & AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX)
std::cout << "+frames";
first = false;
}
if (first)
std::cout << " none";
std::cout << '\n';
}
{
}
}
int main(int argc, char** argv)
{
const char* device = argc > 1 ? argv[1] : nullptr;
std::cout << "Device types compiled into FFmpeg:";
std::cout << ' ' << type.name();
std::cout << "\n\n";
std::cout << probe.type.name() << ": ";
if (!probe.available) {
std::cout << "unavailable (" << probe.error.message() << ")\n";
continue;
}
std::cout << "available\n";
std::error_code ec;
std::cout << " device creation failed: " << ec.message() << '\n';
continue;
}
std::cout << " hardware formats:";
std::cout << ' ' << format.name();
std::cout << "\n software formats:";
std::cout << ' ' << format.name();
std::cout << "\n size: "
<< " .. "
<< '\n';
} else {
std::cout << " frame constraints: " << ec.message() << '\n';
}
printCodecs(probe.type);
}
return 0;
}
Codec descriptor.
Definition codec.h:32
const char * name() const
Short name of the codec, as FFmpeg knows it.
Owner of an AVHWDeviceContext.
Definition hwcontext.h:126
bool isValid() const noexcept
Whether the wrapper holds a device.
static DeviceContext create(DeviceType type, const char *device=nullptr, const Dictionary &options={}, OptionalErrorCode ec=throws())
Create and open a hardware device.
Wrapper for AVHWDeviceType.
Definition hwcontext.h:53
const char * name() const noexcept
FFmpeg name of the device type, or "none".
Owner of AVHWFramesConstraints.
Definition hwcontext.h:1087
int minWidth() const noexcept
Smallest supported width.
int maxWidth() const noexcept
Largest supported width.
PixelFormatRange hwFormats() const noexcept
Hardware surface formats the device supports.
static FrameConstraints query(const DeviceContext &device, OptionalErrorCode ec=throws())
Ask the device for its frame constraints.
PixelFormatRange swFormats() const noexcept
System-memory formats that can be transferred to the device.
bool isValid() const noexcept
Whether constraints were obtained.
Definition hwcontext.h:1113
int maxHeight() const noexcept
Largest supported height.
int minHeight() const noexcept
Smallest supported height.
Codec descriptors and lookup by name or id.
Hardware devices, hardware frames and hardware codec configuration.
DeviceTypeRange allDeviceTypes() noexcept
All hardware device types compiled into FFmpeg.
CodecConfigRange codecConfigs(const Codec &codec) noexcept
All hardware configurations of a codec.
Codec findEncoder(AVCodecID id, DeviceType type) noexcept
The first encoder for a codec identifier that supports a device type.
DeviceProbeRange probeDevices(const char *device=nullptr)
Probe every compiled device type with a borrowed selector.
Codec findDecoder(AVCodecID id, DeviceType type) noexcept
The first decoder for a codec identifier that supports a device type.
void init()
Initialize all subsystems the library needs.
const T * raw() const
Read access to the wrapped object.
Definition ffmpeg.h:56
Result of probing one device type: whether it could be created, and why not.
Definition hwcontext.h:552