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. QMediaPlayer and QAbstractVideoSurface video frames format
Forum Updated to NodeBB v4.3 + New Features

QMediaPlayer and QAbstractVideoSurface video frames format

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmediaplayerqtmultimediaqvideoframeqabstractvideof
3 Posts 2 Posters 2.8k Views 2 Watching
  • 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.
  • UndeadBlowU Offline
    UndeadBlowU Offline
    UndeadBlow
    wrote on last edited by UndeadBlow
    #1

    Hello. I have code with QMediaPlayer and class derived from QAbstractVideoSurface as video output. My system is Ubuntu 15.10, and seems that underlying under QMediaPlayer streamer is gstreamer.
    The problem is, frames I get in present method is in YUV420p format, but I need RGB very much. So direct cast to RGB is very expensive - in HD video that's very slow (about 40 ms on PC in release, that's even not 25 fps), and can't find solution to get RGB for a days...
    Please help me with that.

    CharbyC 1 Reply Last reply
    0
    • UndeadBlowU UndeadBlow

      Hello. I have code with QMediaPlayer and class derived from QAbstractVideoSurface as video output. My system is Ubuntu 15.10, and seems that underlying under QMediaPlayer streamer is gstreamer.
      The problem is, frames I get in present method is in YUV420p format, but I need RGB very much. So direct cast to RGB is very expensive - in HD video that's very slow (about 40 ms on PC in release, that's even not 25 fps), and can't find solution to get RGB for a days...
      Please help me with that.

      CharbyC Offline
      CharbyC Offline
      Charby
      wrote on last edited by
      #2

      @UndeadBlow Take a look at https://github.com/microsoft-mobile/mirrorhouse/blob/master/src/myvideosurface.cpp, its convertFrameData method at the end of the file might be helpful.

      Another one found from http://stackoverflow.com/questions/12469730/confusion-on-yuv-nv21-conversion-to-rgb is :

      public static void YUV_NV21_TO_RGB(int[] argb, byte[] yuv, int width, int height) {
          final int frameSize = width * height;
      
          final int ii = 0;
          final int ij = 0;
          final int di = +1;
          final int dj = +1;
      
          int a = 0;
          for (int i = 0, ci = ii; i < height; ++i, ci += di) {
              for (int j = 0, cj = ij; j < width; ++j, cj += dj) {
                  int y = (0xff & ((int) yuv[ci * width + cj]));
                  int v = (0xff & ((int) yuv[frameSize + (ci >> 1) * width + (cj & ~1) + 0]));
                  int u = (0xff & ((int) yuv[frameSize + (ci >> 1) * width + (cj & ~1) + 1]));
                  y = y < 16 ? 16 : y;
      
                  int r = (int) (1.164f * (y - 16) + 1.596f * (v - 128));
                  int g = (int) (1.164f * (y - 16) - 0.813f * (v - 128) - 0.391f * (u - 128));
                  int b = (int) (1.164f * (y - 16) + 2.018f * (u - 128));
      
                  r = r < 0 ? 0 : (r > 255 ? 255 : r);
                  g = g < 0 ? 0 : (g > 255 ? 255 : g);
                  b = b < 0 ? 0 : (b > 255 ? 255 : b);
      
                  argb[a++] = 0xff000000 | (r << 16) | (g << 8) | b;
              }
          }
      }
      
      1 Reply Last reply
      1
      • UndeadBlowU Offline
        UndeadBlowU Offline
        UndeadBlow
        wrote on last edited by
        #3

        Yep, thank you but that is what I've talking about, in release about 40 ms on full HD frame. Better to find a way to get RGB frames, not YUV, but I don't know how that all works exactly.

        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