I am building a video rendering engine and am stuck on a problem. I would like to determine the rate at which to take the screenshots.
Currently, I am setting the rate to be 25 fps. From that, I can determine the total screenshots, as an example, a 10-second video would be 250 screenshots.
for (let i = 0; i < 250; i++ {
//... i / 25 fps is what I set the HTML 5 video to be
//... this means every 0.04s or 40ms a screenshot is taken
}
The problem is that in my editor a user may combine a 25 fps video with a 30 fps video. I have found the 30 fps video will at times be choppy because the natual rate would be i / 30 which means it needs a screenshot every 0.033s or 33ms.
I am trying to come up with ways to combat this from being an issue. I would like to inform myself more around solving this problem.
As for solutions with my existing knowledge I can only think of two.
make sure every video that gets added to the editor gets re-encoded with 25fps, this could still cause issues and be problematic, since removing frames could cause jank, and adding frames is impossible.
have a variable frame rate while taking the screenshots so that when the video in view is 30fps I can change the rate of the screenshot mechanism. This poses problems when layers on top use an animation frame rate of 25 fps, or if it's next to a video side by side with a frame rate of 25.
Both solutions I can think of arent the best. So I would like to ask the folks who understand this problem the most and would like to share some of that knowledge.
Lastly, it seems the browser does a good job of handling this which tells me it's possible. Here is a screen recording of the app https://share.getcloudapp.com/KouwpkwE the first run was a bit sluggish but the second one showcases the video in the background using a frame rate of 30, then the lottie animation on top using a frame rate of 25.
When trying to capture this frame by frame at a fixed 25 I run into issues. Any techniques to solve this?
Thanks
Related
I am going through tutorials and articles on how to achieve 60FPS for web animations. I am working on the web performance on a site and was wondering whether 60FPS is valid on the idle page too?
Eg:- While scrolling page I see theres some drop on the frame rate due to some long running script which was triggered on scroll events.
I might sound too noob here, but wanted to understand from others where all the 60FPS is expected.
So I wanted to understand more whether a good performing site should always achieve 60FPS even on idle state too?
I googled around and mostly found 60FPS was measured for Web Animations only.
From https://developers.google.com/web/fundamentals/performance/rendering (emphasis my own):
60fps and Device Refresh Rates
Most devices today refresh their screens 60 times a second. If there’s an animation or transition running, or the user is scrolling the pages, the browser needs to match the device’s refresh rate and put up 1 new picture, or frame, for each of those screen refreshes.
I use cocos2d-x 3.0 on Windows, but the game should be on Android and iOS.
I want to create coin collection sound. My player can collect for example 10 coins with 0.1 seconds delay. Now I want to play the same effect 10 times with the same delay, whereas my effect length is 1 second. SimpleAudioEngine does not play that. How I can achieve that?
In other words I want to play the same sound with multiple streams. Please help me.
Size matters. If the size of .wav file is "enough" small, then it can play multiple times.
I am making a project, that includes many videos. In short: let's say I want to put 20 videos that are on the screen (I won't put them all together - they would be 4 together each on 5 pages for example) and the user could hear 15 seconds of them and then decide if he/she wants to play the whole video.
this is the general code I use for import (just to understand how I import):
playlistVideoDisplay[i].movie = new FLVPlayback();
playlistVideoDisplay[i].movie.load("videos/somefile.flv");
To my understanding - It would be easier for flash to load 20 videos of 15 seconds each - and then when a user request a specific video - flash will load the full video of this specific short one.
BUT - I would much rather use the other way - loading full-length (let's say 10/7/5 minutes) and when the user can play the 15 second sample and, if he/she wishes, he will play the full video (without re-loading a new video - and not making a smooth transform between the short one and the long one).
My question is: Am I wrong by assuming that importing bigger movies would make everything hard and slow on flash?
First of: you'd probably do your users a great favor by NOT importing the full length FLV:s. In the case of 20 5-minute videos you'd be importing 100 minutes of moving pictures. That's a lot. For someone surfing with limited bandwidth (say a mobile broadband) that could easily eat a big chunk of the monthly allocated bandwidth.
For that reason alone, I'd say go with the small previews.
Having said that, I'd recommend you have a look at this class: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html
Streaming would definitively be a better idea than loading all of those videos. Unless there's a specific reason why you want to load them?
I am working on a Flash Video player and am implementing the ability to start a video at x time within the span of an FLV (served from FMS). I am able to start it x seconds into a stream without any issue using
netStream.play(source, startTime);
but as far as I can tell, it only supports seconds. I am looking to be able to give a start time (or even a seek time if that is supported) in milliseconds, or really anything more precise than whole seconds.
Anyone know of any way to achieve this even by monkey patching the fl classes?
Thanks,
Doug
Well the seek will allow you to seek by a number of frames, but the spec says that it only seeks to the closes I-Frame in the FLV. That will become a problem with any method you use, because the I-Frames are the only ones that actually contain the whole picture frame (here's the gist of that).
I want to animate MoviveClips/Sprite objects as smootly as possible. However so far the only method that works is placing the movement code into the EnterFrame event handler. There is one problem with this approach: when the framerate on a specific machine is below the desired framerate then the whole game slows down. I want to be able to do this in a time-independent manner.
There are two ways to do programmatic animation within the Flash player. The first you already pointed out by using a onEnterFrame. However, as you might already have noticed, to get a smooth animation you need to increase the overall frame rate of your movie. Doing this will also increase the CPU load for the entire period of time your SWF runs. This is not something you always want.
The other way of doing programmatic animation is by using a timer. Within a timer handler it is possible to call a function named updateAfterEvent which will update the screen independent from the FPS you'd set for your SWF. Therefore, using a timer leaves a gateway to do smooth animation within the Flash player without increasing the overall frame rate of your SWF.
Two years ago or so I set out to create my own tween libraries for Flash (because of my frustrations with the then existing tween libraries available). I released it under the name Coretween and this library lets you, among other things, choose what type of animation you prefer for every individual tween. On the documentation page I give an example of the difference between frame based and time based animation. The example SWF on that page runs at 12 fps but as you can see, the lower circle tweens much smoother because it's controlled by a timer that ticks at 60 fps and updates the screen in-depended from the SWF frame rate. Do keep in mind though that even the timer ticks at 60 fps in reality the Flash Player will never be able to achieve this frame rate. However, it will try to achieve this frame rate which results in a much smoother overall animation.
Unfortunately until now I've not been able to release a 1.0 version of my library but as far as I know it's pretty stable. You're more than welcome to use it in any way you see fit. I've used Coretween in many commercial productions including this one we did for StGeorge bank here in Australia.
Here are a few Actionscript based animation libraries:
TweenMax
Tweener
They both work well, and should help you with what you need.