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. Qt6.5 QCamera setting the cameraFormat was NV12 why output was UYVY?

Qt6.5 QCamera setting the cameraFormat was NV12 why output was UYVY?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 362 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.
  • Z Offline
    Z Offline
    zruibin
    wrote on last edited by
    #1

    I was setting the format(Format_NV12) on QCamera by setCameraFormat, but the output format was uyvy(Format_UYVY) from QVideoSink on apple m1 machine finally, why?

    It was NORMAL on apple intel machine(output was nv12).

    That's very strangely!

    Qt Version: 6.5

    And rollback to 6.4.3,no such problem!!!

    code:

    QCameraDevice cameraDevice;
    const QList<QCameraDevice> availableCameras = QMediaDevices::videoInputs();
    for (const QCameraDevice &availableCamera : availableCameras) {
        if (availableCamera == QMediaDevices::defaultVideoInput())
            cameraDevice = availableCamera;
    }
    camera_.reset(new QCamera(cameraDevice));
    if (camera_->cameraFormat().isNull()) {
        auto formats = cameraDevice.videoFormats();
        if (!formats.isEmpty()) {
            QCameraFormat bestFormat;
            for (const auto &fmt : formats) {
                if (fmt.pixelFormat() == QVideoFrameFormat::Format_NV12
                    && fmt.resolution().width() > fmt.resolution().height()
                    && bestFormat.resolution().width() < fmt.resolution().width()
                    && bestFormat.resolution().height() < fmt.resolution().height()) {
                    bestFormat = fmt;
                }
            }
    
            camera_->setCameraFormat(bestFormat);
        }
    }
    
    captureSession_.setCamera(camera_.data());
    captureSession_.setVideoSink(&videoSink_);
    
    connect(&videoSink_, &QVideoSink::videoFrameChanged, this, &VideoCaputer::OnFrameChanged);
    
    ...
    
    void VideoCaputer::OnFrameChanged(const QVideoFrame &frame) {
        // why? just on apple m1
       if (frame.pixelFormat() == QVideoFrameFormat::Format_UYVY) {
           qDebug()<< "pixelFormat error";
           return;
       }
    
    }
    
    B 1 Reply Last reply
    0
    • Z zruibin

      I was setting the format(Format_NV12) on QCamera by setCameraFormat, but the output format was uyvy(Format_UYVY) from QVideoSink on apple m1 machine finally, why?

      It was NORMAL on apple intel machine(output was nv12).

      That's very strangely!

      Qt Version: 6.5

      And rollback to 6.4.3,no such problem!!!

      code:

      QCameraDevice cameraDevice;
      const QList<QCameraDevice> availableCameras = QMediaDevices::videoInputs();
      for (const QCameraDevice &availableCamera : availableCameras) {
          if (availableCamera == QMediaDevices::defaultVideoInput())
              cameraDevice = availableCamera;
      }
      camera_.reset(new QCamera(cameraDevice));
      if (camera_->cameraFormat().isNull()) {
          auto formats = cameraDevice.videoFormats();
          if (!formats.isEmpty()) {
              QCameraFormat bestFormat;
              for (const auto &fmt : formats) {
                  if (fmt.pixelFormat() == QVideoFrameFormat::Format_NV12
                      && fmt.resolution().width() > fmt.resolution().height()
                      && bestFormat.resolution().width() < fmt.resolution().width()
                      && bestFormat.resolution().height() < fmt.resolution().height()) {
                      bestFormat = fmt;
                  }
              }
      
              camera_->setCameraFormat(bestFormat);
          }
      }
      
      captureSession_.setCamera(camera_.data());
      captureSession_.setVideoSink(&videoSink_);
      
      connect(&videoSink_, &QVideoSink::videoFrameChanged, this, &VideoCaputer::OnFrameChanged);
      
      ...
      
      void VideoCaputer::OnFrameChanged(const QVideoFrame &frame) {
          // why? just on apple m1
         if (frame.pixelFormat() == QVideoFrameFormat::Format_UYVY) {
             qDebug()<< "pixelFormat error";
             return;
         }
      
      }
      
      B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      @zruibin Did you check whether bestFormat is Format_NV12 or not?
      I just think maybe cameraDevice.videoFormats() doesn't support Format_NV12 on that machine/camera?

      Z 1 Reply Last reply
      1
      • B Bonnie

        @zruibin Did you check whether bestFormat is Format_NV12 or not?
        I just think maybe cameraDevice.videoFormats() doesn't support Format_NV12 on that machine/camera?

        Z Offline
        Z Offline
        zruibin
        wrote on last edited by zruibin
        #3

        @Bonnie I was confirm check the bestFormat was set Format_NV12 by qDebug output.

        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