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. Render QGraphicsView into video file problem
QtWS25 Last Chance

Render QGraphicsView into video file problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt3dqgraphicsqtimer
2 Posts 2 Posters 633 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.
  • H Offline
    H Offline
    hamed_ta
    wrote on 10 Mar 2020, 21:11 last edited by hamed_ta 3 Oct 2020, 21:13
    #1

    Hello,

    I'm developing a 2D/3D animation desginer program which user can design animated items on a graphic scene, after designing user needs to be able to convert the animation into a specific video file, for rendering I just run a QTimer with Qt::PreciseTimer key (when animation is playing on the QGraphicsView) and set its interval to 33ms to get 30 shots per second and in its timeout signal I just use GraphicsView->render to get an image of what is displaying on the scene then save it to the file, the problem is that the timer timeout interval isn't accurate especially if I move window or do something else during the conversion process!
    even I moved the timer in to another Thread but it didn't do the trick!

    Min Time: 33  Cur Time:  65 elapsed  64  Max Time: 65
    Min Time: 32  Cur Time:  32 elapsed  31  Max Time: 65
    Min Time: 32  Cur Time:  32 elapsed  32  Max Time: 65
    Min Time: 32  Cur Time:  33 elapsed  32  Max Time: 65
    Min Time: 32  Cur Time:  33 elapsed  33  Max Time: 65
    Min Time: 32  Cur Time:  32 elapsed  31  Max Time: 65
    Min Time: 32  Cur Time:  50 elapsed  49  Max Time: 65
    Min Time: 22  Cur Time:  22 elapsed  22  Max Time: 65
    Min Time: 22  Cur Time:  27 elapsed  27  Max Time: 65
    Min Time: 22  Cur Time:  33 elapsed  32  Max Time: 65
    Min Time: 22  Cur Time:  33 elapsed  32  Max Time: 65
    Min Time: 22  Cur Time:  33 elapsed  32  Max Time: 65
    Min Time: 22  Cur Time:  32 elapsed  32  Max Time: 65
    Min Time: 22  Cur Time:  34 elapsed  32  Max Time: 65
    

    for another method I used a QTimeLine which is set to the animation and by its FrameChanged singnal I supposed to find the exact end time of a frame to take picture, but again the framechange signal isn't accurate too!

    Min Time: 0  Cur Time:  50  Max Time: 50
    Min Time: 0  Cur Time:  32  Max Time: 50
    Min Time: 0  Cur Time:  32  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  34  Max Time: 50
    Min Time: 0  Cur Time:  32  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  25  Max Time: 50
    Min Time: 0  Cur Time:  40  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  35  Max Time: 50
    Min Time: 0  Cur Time:  31  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  35  Max Time: 50
    Min Time: 0  Cur Time:  31  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  32  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    Min Time: 0  Cur Time:  32  Max Time: 50
    Min Time: 0  Cur Time:  33  Max Time: 50
    

    with this problem, when I have a animated graphic item which is moving linearly from left to right of the scene, after converting it to a vide file, when I paly the file I can see that item moves 3 pixels in one frame and it moves 5 pixels in another frame while it should move equal pixels in every frames!!

    I'm using QElapsedTimer to fine elapsed time between every frames timeout,

    what do you think is the problem ? is there any better approch to render a QGraphicsView in a video ?

    and is there any other way to no showing anything on the screen when you just want to render animations into a file ? something like offscreen scene ?

    some piece of codes of the program

    void ZAnimator::onFrameChanged()
    {
       timeta = elapsedTimera->elapsed();
       elapsedTimera->restart();
    
       if (timeta > maxtimeta)
           maxtimeta = timeta;
    
       if (timeta < mintimeta)
           mintimeta = timeta;
    
       qDebug() << "Min Time:" << mintimeta <<" Cur Time: " << timeta << " Max Time:" << maxtimeta;
    
        screenPixmap->fill(Qt::black);
    
        m_curSB->getGV()->render(screenPainter, screenPixmap->rect(),bRect);
    
        *tempImage = screenPixmap->toImage();
    
        imageData.push_back(*tempImage);
    }
    
    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kent-Dorfman
      wrote on 11 Mar 2020, 00:58 last edited by
      #2

      opencv (extra characters to make response longer than 8 characters...lame!)

      1 Reply Last reply
      -1

      1/2

      10 Mar 2020, 21:11

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved