Hello,

I have a videocamera whose generated video to in h264. Picture to be drawn over the video. With this problem.
Я имею видеокамеру, которая генерирует видеопоток в h264. Картинка должна рисоваться поверх видео. С этим проблемма.

test.h
Qt Code:
  1. #ifndef TEST_H
  2. #define TEST_H
  3.  
  4. #include <QWidget>
  5. #include <QPainter>
  6. #include <QPicture>
  7. #include <QVideoWidget>
  8. #include <QImage>
  9.  
  10. namespace Ui {
  11. class Test;
  12. }
  13.  
  14. struct Graphics {
  15. QImage pixmapLogo;
  16. };
  17.  
  18. class Test : public QVideoWidget
  19. {
  20. Q_OBJECT
  21.  
  22. Ui::Test *ui;
  23. QPixmap mPixmap;
  24. QImage pixmapL;
  25. Graphics mGraphics;
  26.  
  27. protected:
  28. void paintEvent(QPaintEvent *);
  29.  
  30. public:
  31. Test(QWidget *parent = 0);
  32. ~Test();
  33. };
  34.  
  35. #endif // TEST_H
To copy to clipboard, switch view to plain text mode 


test.cpp

Qt Code:
  1. #include "test.h"
  2. #include "ui_test.h"
  3.  
  4. Test::Test(QWidget *parent) :
  5. QVideoWidget(parent), ui(new Ui::Test)
  6. {
  7. ui->setupUi(this);
  8.  
  9. QPixmap p("://logo.png");
  10. QLabel *label = new QLabel(parent);
  11. label -> resize(150,34);
  12. label -> setPixmap(p);
  13. label -> move(610,14);
  14. }
  15.  
  16. Test::~Test()
  17. {
  18. delete ui;
  19. }
To copy to clipboard, switch view to plain text mode 

mainwindow.h

Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5. #include <QMediaPlayer>
  6. #include <QVideoWidget>
  7. #include <QDataStream>
  8. #include "test.h"
  9.  
  10. namespace Ui {
  11. class MainWindow;
  12. }
  13.  
  14. class MainWindow : public QMainWindow
  15. {
  16. Q_OBJECT
  17.  
  18. public:
  19. MainWindow(QWidget *parent = 0);
  20. ~MainWindow();
  21.  
  22. private:
  23. Ui::MainWindow *ui;
  24. Test *pTest;
  25. QMediaPlayer *player;
  26.  
  27. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 


mainwindow.cpp

Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
  4. {
  5. ui->setupUi(this);
  6. player = new QMediaPlayer(this);//, QMediaPlayer::StreamPlayback);
  7. pTest = new Test(this);
  8. pTest -> setGeometry(5,35,1385,1040);
  9. pTest -> setOptWidget(mOptWidget);
  10. pTest -> hide();
  11. player -> setVideoOutput(pTest);
  12. }
To copy to clipboard, switch view to plain text mode 

Here the picture is displayed as it should
Картинка выводится поверх видео

if you write the following test.cpp
Если test.cpp написать следующим образом

test.cpp

Qt Code:
  1. #include "test.h"
  2. #include "ui_test.h"
  3.  
  4. Test::Test(QWidget *parent) :
  5. QVideoWidget(parent), ui(new Ui::Test)
  6. {
  7. ui->setupUi(this);
  8. mGraphicsBlack.pixmapLogo.load(":/logo.png");
  9. mGraphics = mGraphicsBlack;
  10. pixmapL = mGraphics.pixmapLogo;
  11. }
  12.  
  13. Test::~Test()
  14. {
  15. delete ui;
  16. }
  17.  
  18. void Test::paintEvent(QPaintEvent *event)
  19. {
  20. QVideoWidget::paintEvent(event);
  21. QPainter painter(this);
  22. painter.drawImage(1010, 14, pixmapL);
  23. painter.end();
  24. }
To copy to clipboard, switch view to plain text mode 

Pictures do not have top stream. Why QPixmap it displays picture, QPaint it not dispalys picture?
Картинка не рисуется поверх видео. Почему QPixmap рисует картинку поверх видео а QPaint нет?
Как сделать чтобы QPaint рисовал картинку поверх видео? Чтобы и видео, и картинка отображались .

Get out of line in mainwindow.cpp :
Qt Code:
  1. player -> setVideoOutput(pTest);
To copy to clipboard, switch view to plain text mode 
Here the picture is displays, with the help QPaint.


При убирании строчки в mainwindow.cpp:
Qt Code:
  1. player -> setVideoOutput(pTest);
To copy to clipboard, switch view to plain text mode 
Картинка рисуется при помощи QPaint.

Why is there so? How to make the output video image over using QPaint? How to make a video stream is excreted in the picture?
Почему так? Как сделать чтобы отображалось видео в h264 и рисовалась картинка через QPaint? Как сделать чтобы и видео и картинка рисовались?