Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Hit a hardware limitation with java

  • 30-06-2015 2:39pm
    #1
    Closed Accounts Posts: 431 ✭✭


    Made a simple screen recording program and it only runs the loop as fast as it can process here the code: http://pastebin.com/S1k7j9mV
    Anyone help me out think i need to use more threads.


Comments

  • Registered Users, Registered Users 2 Posts: 7,498 ✭✭✭BrokenArrows


    You're plan is to write out a PNG image to the disk every 1 second and you have hardcoded a delay of 1 second.

    That is a very inefficent way of doing things. Even if you hadnt hardcoded the 1 second delay it would be very ineffecient.

    A quick google gave me this project. http://code.google.com/p/java-screen-recorder/ Maybe have a read through the code and it will give you some ideas.

    Png. If you want to stick to the PNG capture method you should be converting this PNG to a compressed video stream and saving the video to the disk. The conversion to video should be done on a separate thread so it doesnt slow down the capture loop.


  • Registered Users, Registered Users 2 Posts: 11,985 ✭✭✭✭Giblet


    File IO should be async or use a different thread if possible.
    I'm not sure about Java and IO Completion ports though to get "true" async, I'm sure there's a library somewhere. You should also have a buffer to store x frames and reduce writes to disk anyway.


  • Closed Accounts Posts: 431 ✭✭whats newxt


    I want the images to be in .png format as an image sequence not a video


  • Registered Users, Registered Users 2 Posts: 7,498 ✭✭✭BrokenArrows


    I want the images to be in .png format as an image sequence not a video

    Ok so your requirement is to have a image sequence.
    How many images do you want per second. ie. Your framerate?

    The overhead involved in writing that many files to the disk of that size is unavoidable. Its going to slow down your system.

    I just write a quick program in C# to take a screenshot and save to the disk. I managed to get about 24 images per second using 18% cpu but my disk access went a bit crazy.


  • Closed Accounts Posts: 431 ✭✭whats newxt


    Ok so your requirement is to have a image sequence.
    How many images do you want per second. ie. Your framerate?

    The overhead involved in writing that many files to the disk of that size is unavoidable. Its going to slow down your system.

    I just write a quick program in C# to take a screenshot and save to the disk. I managed to get about 24 images per second using 18% cpu but my disk access went a bit crazy.

    I need 15 frames a second, was thinking of rewriting it using python to be honest. I know little to nothing about threads


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 7,498 ✭✭✭BrokenArrows


    I need 15 frames a second, was thinking of rewriting it using python to be honest. I know little to nothing about threads

    Out of curiosity what are you planning to do with the images? Maybe someone can think of a better option for you.


  • Closed Accounts Posts: 431 ✭✭whats newxt


    So i redid it with python and still have the same problem, it's faster but not 15 FPS fast. Is it just my hardware or what. old i3 on a fairly rubbish laptop. Anyway here the code:
    import gtk.gdk
    import time
    
    i = 0
    
    print "  ________ _______    _____    "
    print " / ____/  |  \__  \  /     \   "
    print "< <_|  |  |  // __ \|  Y Y  \  "
    print " \__   |____/(____  /__|_|  /  "
    print "    |__|          \/      \/   "
    print "    |__|          \/      \/   "
    print "Screen recorder GNU - GPL V3"
    
    while True:
    
        
        i += 1
        w = gtk.gdk.get_default_root_window()
        sz = w.get_size()
        print "FRAME: %d OK!"%i 
        pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
        pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
        pb.save("Capture %d"%i,"png")
        
      
    
    


  • Closed Accounts Posts: 431 ✭✭whats newxt


    Oh, i see changing to jpeg gives me more that 15 frames a second approx 40/50. Thanks for your help though. I guess .png holds alot more data.


Advertisement