Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] How to convert QVideoFrame with Format_NV21 to QImage?

[SOLVED] How to convert QVideoFrame with Format_NV21 to QImage?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 5.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lygstate
    wrote on last edited by
    #1

    cause the default constructor of QImage didn't support for Format_NV21
    @
    QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format)
    {
    switch (format) {
    case Format_Invalid:
    return QImage::Format_Invalid;
    case Format_ARGB32:
    return QImage::Format_ARGB32;
    case Format_ARGB32_Premultiplied:
    return QImage::Format_ARGB32_Premultiplied;
    case Format_RGB32:
    return QImage::Format_RGB32;
    case Format_RGB24:
    return QImage::Format_RGB888;
    case Format_RGB565:
    return QImage::Format_RGB16;
    case Format_RGB555:
    return QImage::Format_RGB555;
    case Format_ARGB8565_Premultiplied:
    return QImage::Format_ARGB8565_Premultiplied;
    case Format_BGRA32:
    case Format_BGRA32_Premultiplied:
    case Format_BGR32:
    case Format_BGR24:
    return QImage::Format_Invalid;
    case Format_BGR565:
    case Format_BGR555:
    case Format_BGRA5658_Premultiplied:
    case Format_AYUV444:
    case Format_AYUV444_Premultiplied:
    case Format_YUV444:
    case Format_YUV420P:
    case Format_YV12:
    case Format_UYVY:
    case Format_YUYV:
    case Format_NV12:
    case Format_NV21:
    case Format_IMC1:
    case Format_IMC2:
    case Format_IMC3:
    case Format_IMC4:
    case Format_Y8:
    case Format_Y16:
    case Format_Jpeg:
    case Format_CameraRaw:
    case Format_AdobeDng:
    return QImage::Format_Invalid;
    case Format_User:
    return QImage::Format_Invalid;
    }
    return QImage::Format_Invalid;
    }
    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      apoi
      wrote on last edited by
      #2

      I was just now looking for the same thing, quite a coincidence.

      Quick googling revealed there's NV21 -> ARGB32 conversion algorithm available in Qt sources, in "qandroidmultimediautils"; see "https://qt.gitorious.org/qt/qtmultimedia/source/src/plugins/android/src/common/qandroidmultimediautils.cpp":https://qt.gitorious.org/qt/qtmultimedia/source/src/plugins/android/src/common/qandroidmultimediautils.cpp. I tried it and it works nicely, though a couple of points worth mentioning:

      • Nexus 5 took 30-50 ms to decode one frame (1280x960), so you may not be able to decode a video feed in real-time
      • It's LGPL if you copy the code directly to your own project. I think the header file isn't part of the public API.
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved