Я играю с QtGStreamer 0.10.0 , и я пытаюсь получить размер видео, но он возвращает ZERO для высота и ширина значения.
Однако, Я могу воспроизвести видео без проблем на QImage .
QGst::init();
pipeline = QGst::Pipeline::create();
filesrc = QGst::ElementFactory::make("filesrc");
filesrc->setProperty("location", "sample.avi");
pipeline->add(filesrc);
decodebin = QGst::ElementFactory::make("decodebin2").dynamicCast<QGst::Bin>();
pipeline->add(decodebin);
QGlib::connect(decodebin, "pad-added", this, &MyMultimedia::onNewDecodedPad);
QGlib::connect(decodebin, "pad-removed", this, &MyMultimedia::onRemoveDecodedPad);
filesrc->link(decodebin);
// more code ...
Код выше показывает начало настройки конвейера. Подключив мой метод MyMultimedia::onNewDecodedPad
по сигналу "pad-added"
, я получаю доступ к данным видео. По крайней мере, я так думаю.
void MyMultimedia::onNewDecodedPad(QGst::PadPtr pad)
{
QGst::CapsPtr caps = pad->caps();
QGst::StructurePtr structure = caps->internalStructure(0);
if (structure->name().contains("video/x-raw"))
{
// Trying to print width and height using a couple of different ways,
// but all of them returns 0 for width/height.
qDebug() << "#1 Size: " << structure->value("width").get<int>() << "x" << structure->value("height").get<int>();
qDebug() << "#2 Size: " << structure->value("width").toInt() << "x" << structure->value("height").toInt();
qDebug() << "#3 Size: " << structure.data()->value("width").get<int>() << "x" << structure.data()->value("height").get<int>();
// numberOfFields also returns 0, which is very wierd.
qDebug() << "numberOfFields:" << structure->numberOfFields();
}
// some other code
}
Интересно, что я могу делать не так? Какие-нибудь советы? Мне не удалось найти соответствующий пример в Интернете с помощью этого API.