Results 1 to 9 of 9

Thread: How to play video using libavcodec frames using QLable Widget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Posts
    16
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default How to play video using libavcodec frames using QLable Widget

    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:

    Qt Code:
    1. /************************************/
    2. Working code: Frame by Frame display
    3. /************************************/
    4.  
    5. void MainWindow::image2Pixmap(QImage &img,QPixmap &pixmap)
    6. {
    7. // Convert the QImage to a QPixmap for display
    8. pixmap = QPixmap(img.size());
    9. QPainter painter;
    10. painter.begin(&pixmap);
    11. painter.drawImage(0,0,img);
    12. painter.end();
    13. }
    14.  
    15.  
    16. void MainWindow::displayFrame()
    17. {.
    18. .
    19. .
    20. .....
    21.  
    22. image2Pixmap(img,p);
    23. // Display the QPixmap
    24. ui->labelVideoFrame->setPixmap(p);
    25. ....
    26. ....
    27. }
    28.  
    29.  
    30. void MainWindow::on_pushButtonNextFrame_clicked()
    31. {
    32. if(!decoder.seekNextFrame())
    33. {
    34. QMessageBox::critical(this,"Error","seekNextFrame failed");
    35. }
    36.  
    37. decoder.decodeSeekFrame();
    38.  
    39. displayFrame();
    40. }
    41.  
    42. /*********************************/
    43. Not Working: play all frames in one shot (playing video)
    44. /*********************************/
    45. void MainWindow::on_pushButtonNextFrame_clicked()
    46. {
    47. while(decoder.seekNextFrame()) {
    48.  
    49. decoder.decodeSeekFrame();
    50.  
    51. displayFrame();
    52. }
    53. }
    To copy to clipboard, switch view to plain text mode 


    Thanks in advance
    Last edited by Lykurg; 15th May 2011 at 21:26. Reason: missing [code] tags

Similar Threads

  1. Replies: 19
    Last Post: 13th May 2013, 11:17
  2. play a video from youtube
    By graciano in forum Qt Programming
    Replies: 2
    Last Post: 13th July 2011, 07:17
  3. How to play video , by rotating at 90 degree?
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 21st April 2011, 12:11
  4. Video play issue
    By baluk in forum Newbie
    Replies: 3
    Last Post: 4th December 2010, 13:43
  5. Play video in QT4 application
    By carlosmele in forum Qt Programming
    Replies: 3
    Last Post: 14th April 2009, 22:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.