frame-rate

Setting a fixed FPS in Pygame, Python 3

陌路散爱 提交于 2019-12-05 20:18:52
I'm currently making a game using PyGame (Python 3), and I'm looking for a way to make the game run at a fixed FPS. Most of the game is located inside a giant while loop, where the user input is taken, sprites are rendered, etc. every tick. My goal is to be able to set a fixed FPS that will make the game run at the same speed on a fast or slow computer. I can, of course, use the clock module in pygame: clock = pygame.time.Clock() and then call this every loop: clock.tick(30) but that will keep the game CAPPED at 30 FPS. So if I set it to 500 FPS it might still run as fast as it did before. My

Am I calculating my FPS correctly?

给你一囗甜甜゛ 提交于 2019-12-05 18:34:44
So I was wondering if I'm calculating my FPS correctly: Uint32 delayFrom(float startTime, float endTime){ return(endTime - startTime ); } int main(){ int numFrames = 0; Uint32 startTime = SDL_GetTicks(); while(!done){ frameTime = 0; float fps = ( numFrames/(float)(SDL_GetTicks() - startTime) )*1000; cout << fps << endl; SDL_Delay(delayFrom(frameTime, 1/60)); ++numFrames; } } int main() { int numFrames = 0; Uint32 startTime = SDL_GetTicks(); while (!done) { ++numFrames; Uint32 elapsedMS = SDL_GetTicks() - startTime; // Time since start of loop if (elapsedMS) { // Skip this the first frame

Game Development: How to limit FPS?

谁说胖子不能爱 提交于 2019-12-05 17:36:40
问题 I'm writing a game, and I saw the FPS algorithm doesn't work correctly (when he have to calculate more, he sleeps longer...) So, the question is very simple: how to calculate the sleeptime for having correct FPS? I know how long it took to update the game one frame in microseconds and of course the FPS I want to reach. I'm searching crazy for a simple example, but I can't find one.... The code may be in Java, C++ or pseudo.... 回答1: The number of microseconds per frame is 1000000 / frames_per

Low FPS with android SurfaceView

不想你离开。 提交于 2019-12-05 17:03:14
I have some trubles with my framerate using a SurfaceView. Im doing the tipical stuff i found in some tutorials (all of them said the same), but i cant reach a decent framerate on my samsung galaxy S (the old one, i9000). Here's the code i have for the loop thread. FPS is initialized at 30. @Override public void run() { long ticksPS = 1000/FPS; long startTime; long sleepTime; //fps checker long contms=0; long lasttimecheck = System.currentTimeMillis(); int fps=0; while (running) { long time = System.currentTimeMillis(); if(contms>1000) { Log.v("FPS",String.valueOf(fps)); contms=time

Change Frames Per Second for VLC Stream

可紊 提交于 2019-12-05 15:59:56
We are currently experimenting with streaming a webcam attached to one of our Linux servers (Ubuntu 12.04) using VLC, and although we are able to successfully stream the video and view it remotely, we need to change the number of frames per second (which is defaulting to 24). We are currently using the following command to create the stream: vlc v4l2:// :v4l2-dev=/dev/video0 \ :v4l2-width=640 \ :v4l2-height=480 -- \ sout="#transcode{vcodec=theo,vb=256}:standard{access=http,mux=ogg,dst=:8090}" \ -I dummy Would someone be able to show us how to modify this to change the number of frames per

Pydub - How to change frame rate without changing playback speed

…衆ロ難τιáo~ 提交于 2019-12-05 13:41:31
I have a couple audio files that I open in Pydub with AudioSegment . I want to decrease the audio quality from frame rate 22050 to 16000 Hz. (One channel files) If I simply change the frame rate of AudioSegment, what I get is the exact same wave played in slower speed. Well, fair enough. But how do I actually change the waves to fit a lower quality, same speed playback? (Manual interpolation is the only thing I can think of, but I don't want to get into that trouble) You can use: sound = AudioSegment.from_file(…) sound = sound.set_frame_rate(16000) 来源: https://stackoverflow.com/questions

lower fps when using ffmpeg to convert mp4 to gif

只谈情不闲聊 提交于 2019-12-05 10:44:49
I am using ffmpeg to convert high quality videos to gif, most of the videos are 60fps and over 720p , but when I use the code below, to convert the video to gif, I get very low fps for the gif output, #!/usr/bin/env palette=/tmp/pallete.png filter="fps=50,scale=480:-1:flags=lanczos" ffmpeg -y -i test.mov -vf $filter,palettegen=stats_mode=diff $palette ffmpeg -y -i test.mov -i $palette -lavfi "$filter [x]; [x][1:v] paletteuse" test.gif another issue I have noted is - as the width increases e.g 720 instead of 480 I get even lower fps. here is output log example, the output fps is lower than the

change frame rate in opencv 3.4.2

痴心易碎 提交于 2019-12-05 07:26:58
I want to reduce the number of frames acquired per second in a webcam, this is the code that I'm using #!/usr/bin/env python import cv2 cap = cv2.VideoCapture(0) cap.set(cv2.CAP_PROP_FPS, 10) fps = int(cap.get(5)) print("fps:", fps) while(cap.isOpened()): ret,frame = cap.read() if not ret: break cv2.imshow('frame', frame) k = cv2.waitKey(1) if k == 27: break But it doesn't take effect, I still have 30 fps by default instead of 10 set up by cap.set(cv2.CAP_PROP_FPS, 10) . I want to reduce the frame rate because I have a hand detector which take quite a lot of time to process each frame, I can

How to create a FPS game? [closed]

元气小坏坏 提交于 2019-12-05 02:24:15
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I would like to know How to create a fps-game with SDL lib? Are there any books that explain with examples? 回答1: this wins for most

Display FPS on iOS onscreen (without Instruments)

我只是一个虾纸丫 提交于 2019-12-05 02:21:34
In WWDC 2012 Session 506, they display the frames per second on a UILabel in the application, without having to use the Core Animation profiler attached to instruments. I would like to do this for convenience as well as to let other members of my team monitor FPS as they use the app in real-world scenarios. Unfortunately, session 506 isn't included the the WWDC '12 sample code. Does anyone know how to do this? I know that Cocos2D has this capability in their CCDirector , but their approach seems specific to how Cocos2D rendering works. It is not necessary for it to be public API because I will