Hi All,
I am new to Qt and am implementing video phone in my new company. For displaying video I choosed QLable Widget and I am able to play video frame by frame, But when I trying to
display all frames in one shot It's not displaying (I put nextFrame function in a loop to diplay continue frames). Only I am seeing last frame . Is this correct approach or am I doing anything wrong here.
Please help me to come out of this problem.
Here is my code:
/************************************/
Working code: Frame by Frame display
/************************************/
{
// Convert the QImage to a QPixmap for display
painter.begin(&pixmap);
painter.drawImage(0,0,img);
painter.end();
}
void MainWindow::displayFrame()
{.
.
.
.....
image2Pixmap(img,p);
// Display the QPixmap
ui->labelVideoFrame->setPixmap(p);
....
....
}
void MainWindow::on_pushButtonNextFrame_clicked()
{
if(!decoder.seekNextFrame())
{
QMessageBox::critical(this,
"Error",
"seekNextFrame failed");
}
decoder.decodeSeekFrame();
displayFrame();
}
/*********************************/
Not Working: play all frames in one shot (playing video)
/*********************************/
void MainWindow::on_pushButtonNextFrame_clicked()
{
while(decoder.seekNextFrame()) {
decoder.decodeSeekFrame();
displayFrame();
}
}
/************************************/
Working code: Frame by Frame display
/************************************/
void MainWindow::image2Pixmap(QImage &img,QPixmap &pixmap)
{
// Convert the QImage to a QPixmap for display
pixmap = QPixmap(img.size());
QPainter painter;
painter.begin(&pixmap);
painter.drawImage(0,0,img);
painter.end();
}
void MainWindow::displayFrame()
{.
.
.
.....
QPixmap p;
image2Pixmap(img,p);
// Display the QPixmap
ui->labelVideoFrame->setPixmap(p);
....
....
}
void MainWindow::on_pushButtonNextFrame_clicked()
{
if(!decoder.seekNextFrame())
{
QMessageBox::critical(this,"Error","seekNextFrame failed");
}
decoder.decodeSeekFrame();
displayFrame();
}
/*********************************/
Not Working: play all frames in one shot (playing video)
/*********************************/
void MainWindow::on_pushButtonNextFrame_clicked()
{
while(decoder.seekNextFrame()) {
decoder.decodeSeekFrame();
displayFrame();
}
}
To copy to clipboard, switch view to plain text mode
Thanks in advance
Bookmarks