Results 1 to 10 of 10

Thread: Load a sequence of frames

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2008
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Load a sequence of frames

    Yes... this code works, because I probe with sdl surfaces and i saw the video

    Qt Code:
    1. while ( (av_read_frame(pFormatCtx_l, &packet_l)>=0) && (av_read_frame(pFormatCtx_r, &packet_r)>=0) ) {
    2.  
    3. if ( (packet_l.stream_index == videoStream_l) && (packet_r.stream_index == videoStream_r) ) {
    4. // Decode video frame
    5. avcodec_decode_video(pCodecCtx_l, pFrame_l, &frameFinished_l, packet_l.data, packet_l.size);
    6. avcodec_decode_video(pCodecCtx_r, pFrame_r, &frameFinished_r, packet_r.data, packet_r.size);
    7. // Did we get a video frame?
    8. if ( (frameFinished_l) && (frameFinished_r) )
    9. {
    10. img_convert( (AVPicture *) pFrameRGB_l, PIX_FMT_BGR24, (AVPicture*)pFrame_l,
    11. pCodecCtx_l->pix_fmt, pCodecCtx_l->width, pCodecCtx_l->height);
    12. img_convert( (AVPicture *) pFrameRGB_r, PIX_FMT_BGR24, (AVPicture*)pFrame_r,
    13. pCodecCtx_r->pix_fmt, pCodecCtx_r->width, pCodecCtx_r->height);
    14.  
    15. // Write pixel data
    16. for(ay=0; ay<img_h; ay++)
    17. {
    18. memcpy(aux_l, pFrameRGB_l->data[0]+ay*pFrameRGB_l->linesize[0], ancho);
    19. memcpy(aux_r, pFrameRGB_r->data[0]+ay*pFrameRGB_r->linesize[0], ancho);
    20. // incrementar data_l, data_r para recorrer la imagen nueva e irla generando
    21. aux_l += ancho;
    22. aux_r += ancho;
    23. }
    24.  
    25. img_raw_set_data (img_l, data_l);
    26. img_raw_set_data (img_r, data_r);
    27.  
    28. data32_l = RGB24toARGB(img_l);
    29. data32_r = RGB24toARGB(img_r);
    30.  
    31. qimg_l = QImage(data32_l, img_w, img_h, QImage::Format_RGB32);
    32. qimg_r = QImage(data32_r, img_w, img_h, QImage::Format_RGB32);
    33.  
    34. leftLabel->setPixmap(QPixmap::fromImage(qimg_l));
    35. rightLabel->setPixmap(QPixmap::fromImage(qimg_r));
    36.  
    37. }
    38. aux_l = data_l;
    39. aux_r = data_r;
    40. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 1st April 2008 at 17:00. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Load a sequence of frames

    It's a busy loop, so it won't work. You have to process events somewhere in between like jpn suggested.

  3. #3
    Join Date
    Apr 2008
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Load a sequence of frames

    I tried to introduce one timer and now i have one problem when i run the program:

    Qt Code:
    1. private slots:
    2. void updateLabel(unsigned char *data32_l, unsigned char *data32_r);
    3.  
    4. ///////
    5. QTimer *timer = new QTimer(this);
    6. connect(timer, SIGNAL(timeout()), this, SLOT(updateLabel(data32_l,data32_r)));
    7. timer->start();
    8.  
    9. and the function updateLabel is:
    10.  
    11. void FormMain::updateLabel(unsigned char *data32_l, unsigned char *data32_r)
    12. {
    13. timer->stop();
    14. qimg_l = QImage(data32_l, img_w, img_h, QImage::Format_RGB32);
    15. qimg_r = QImage(data32_r, img_w, img_h, QImage::Format_RGB32);
    16.  
    17. leftLabel->setPixmap(QPixmap::fromImage(qimg_l));
    18. rightLabel->setPixmap(QPixmap::fromImage(qimg_r));
    19. }
    To copy to clipboard, switch view to plain text mode 
    When i run the program i have this:
    Object::connect: No such slot FormMain::updateLabel(data32_l,data32_r)
    Object::connect: (receiver name: 'FormMainInterf')
    I need help!

    Thanks!
    Last edited by jpn; 2nd April 2008 at 07:25. Reason: missing tags

  4. #4
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Load a sequence of frames

    Qt Code:
    1. connect(timer, SIGNAL(timeout()), this, SLOT(updateLabel(data32_l,data32_r)));
    To copy to clipboard, switch view to plain text mode 

    That code makes no sense. You're hooking up timeout() to a slot expecting arguments. Where do you think this data is going to come from? Also you have to give connect the types of the arguments, not the names. So unsigned char* instead of data32_l.

  5. #5
    Join Date
    Apr 2008
    Posts
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Load a sequence of frames

    Thank you very much to all, now my code works.
    I use one timer.

  6. #6
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Re: Load a sequence of frames

    I was able to load the sequence of frames into the label widget but having trouble with timing of the frames. It is displaying only the last frame of the file.

Similar Threads

  1. Program not compiling on Fresh install of Leopard
    By dvmorris in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:22

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
  •  
Qt is a trademark of The Qt Company.