Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by int_32 · Jan 18, 2019 at 06:15 PM · screenshotscreencapture

ScreenCapture.CaptureScreenshot skips frames

I need to get series of screenshots with constant frame rate to create video from it with FFMPEG.

I use ScreenCapture.CaptureScreenshot() method to capture screenshots in every FixedUpdate():

 void FixedUpdate()
     {
         var delta = Time.deltaTime;
 
         if (Time.realtimeSinceStartup <= 180f)
         {
             CaptureScreenshot();
         }
         else
         {
             Debug.Log("Got " + currentFrame + " screenshots");
         }
     }
 
     private void CaptureScreenshot()
     {
         var fileName = currentFrame++.ToString("000000000") + ".png";
         var filePath = "/tmp/frames/" + fileName;
 
         ScreenCapture.CaptureScreenshot(filePath);
     }

But as I can see, it skips lots of screenshots:

 $ ls -lah . | head
 -rw-r--r--     1 user  wheel   139K Jan 18 21:05 000000001.png
 -rw-r--r--     1 user  wheel   139K Jan 18 21:05 000000006.png
 -rw-r--r--     1 user  wheel   139K Jan 18 21:05 000000009.png
 -rw-r--r--     1 user  wheel   139K Jan 18 21:05 000000013.png
 -rw-r--r--     1 user  wheel   139K Jan 18 21:05 000000016.png
 -rw-r--r--     1 user  wheel   139K Jan 18 21:05 000000019.png

Note: I use FixedUpdate() because I need constant frame rate. Some performance issues are OK, it's 2D scene that is not so complex.

So, what should I do to capture "screen" contents on every call or get constant frame rate?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KISP · Jan 18, 2019 at 09:23 PM

FixedUpdate doesn't usually run once a frame as it's based on the timestep of the physics engine. Try Update instead.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image int_32 · Jan 19, 2019 at 12:08 AM 0
Share

I know, but it runs every fixed amount of time. Update runs at "random" time since last update, so it can't provide fixed frame rate.

avatar image KISP int_32 · Jan 21, 2019 at 02:38 PM 0
Share

You can't have it both ways. Fps can change over time, so if you want to take a picture every x frames, there's no way to guarantee it's happening every x seconds. Likewise, if you take a picture every x seconds, an arbitrary amount of frames occur in-between.

avatar image int_32 KISP · Jan 21, 2019 at 02:40 PM 0
Share

Currently I'm going to use this solution: get every frame and save it every fixed amount of time, even if it was not updated.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

98 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Screenshot resolution using ScreenCapture 1 Answer

capture a screen shot and show in the album folder 1 Answer

Take screenshot and use it as texture using ScreenCapture 2 Answers

How to do screenshot and save it in phone as png(not texture)? 0 Answers

Failed to store screenshot in build 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges