question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible to save frames from videos with a high FPS?

See original GitHub issue
from time import time
import mss
import mss.tools

start = time()
count = 1

while True:
	with mss.mss() as sct:
	    # The screen part to capture
	    monitor = {'top': 144, 'left': 80, 'width': 1397, 'height': 782}
	    output = 'frames/sct-{}.png'.format(count)
	    count += 1
	    # Grab the data
	    sct_img = sct.grab(monitor)

	    # Save to the picture file
	    mss.tools.to_png(sct_img.rgb, sct_img.size, output)
	    # print(output)
	    now = time()
	    if (now - start) % 60 >= 10: break

This seems to save only around 100 frames for 10 seconds. Can this be improved?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
eruffaldicommented, Mar 15, 2018

I have reached 37 FPS on macOS by two changes:

  • introduce a Grabber object with specified monitor size that allocates OS resources once. Edited for both darwin.py and windows – Under OSX this is not providing enough advantage (1us) so not worth probably, but it is in my branch
  • use BGRA encoding because RGB one in class Snapshot perform for loop over points. BGRA is not fully supported by pillow but then it can be loaded in pillow and converted to RGB using pillow function. Other uses as numpy or OpenCV are fine

Pull Request in preparation

1reaction
BoboTiGcommented, Jan 19, 2018

OK, added the option in the “impvements” branch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

4 Easy Ways to Extract Frames from Video with High Quality
Navigate to the Filters in the Advanced Preferences tree, click but don't expand it, tick the box before the option of Scene video...
Read more >
5 Ways to Extract Video Frames and Save to Images
4. Go to Video > Frame rate (Ctrl+R) and select Decimate by, then enter a number to save an image every xx number...
Read more >
How To Extract Frames From Video With High Quality for Free ...
While there are many screenshot tools that help you extract frames from video, most screenshot tools don't offer good quality.
Read more >
How can I extract frames from a video at a certain FPS?
FFMPEG has the ability to extract all frames from a video and save them as images, it also can extract frames at a...
Read more >
Everything You Need To Know About FPS in Video Editing
This frame rate is usually used for sporting events or other high-speed actions, so the video has less motion blur. It will help...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found