Is there a way to do a frame grab of a movie and store it as a jpg or png in the persistent storage ?

Hi All,

I was wondering if there is a way to do a frame grab of a particular scene while watching the movie and store that frame as a png or jpg in the persistent storage of the player Let's say I define a function for key "A" on the remote which does this when pressed. Any pointers would be appreciated.

Thanks




Answer this question

Is there a way to do a frame grab of a movie and store it as a jpg or png in the persistent storage ?

  • hrubesh

    In the example given, it is only saving to filecache (ie, memory). For a permanent copy, you would need to copy it from file:///filecache/whatever.cvi to file:///required/{your-guid}/whatever.cvi, then it would appear on C:\HDDVD\HD_DVD\{your-guid}\



  • TaYeB

    Peter Torr - MSFT wrote:

    All resources that you reference in markup MUST be in the filecache. Although you have copied it to pstore for permanent use, you must copy it back to filecache (or rather, just use the original one in filecache) when you reference it in markup.

    Thanks a lot Peter. This works perfectly now.



  • Biju S Melayil

    Sure (but not png or jpg). Player.video.main.capture will capture main video in in CVI format to the file cache. You can then use changeImageSize to scale it down, and use the resulting file in markup.

    Ideal for attaching a thumbnail to bookmarks.



  • Ģ&#174&#59;€ğ&#167&#59;QĻ

     Peter Torr - MSFT wrote:

    In the example given, it is only saving to filecache (ie, memory). For a permanent copy, you would need to copy it from file:///filecache/whatever.cvi to file:///required/{your-guid}/whatever.cvi, then it would appear on C:\HDDVD\HD_DVD\{your-guid}\

    Thanks Peter/Andy/Gunnar,

    This works. I was able to reduced the size using changeImageSize and copy "testimage.cvi" from filecache to the pstorage and  and I can see it appears on C:\HDDVD\HD_DVD\{my_guid}. Now when I am trying to access this image (basically I am trying to change the background image of a button to this "testimage.cvi"), the iHDSim gives me this error:

    "Required image not in resource cache" and on the emualtor it gives the error code 81000c03 error.

    My code looks like this

    var CONTENT_ID = PersistentStorageManager.contentId;

    var MYIMAGE_STORAGE = "file:///required/ " + CONTENT_ID + "/" + "testimage.cvi" ;

    On pressing let's say button B on the remote I call this line from my script:

    document.getElementById('Bookmark_Button').style.setProperty("backgroundImage", "url('" + MYIMAGE_STORAGE" +"')");

    However, as soon as this line is executed it gives me the above error. Any suggestions as to what am I doing wrong

    Thanks

     

     

     



  • MartySeed

    A modified example from one of Andy's previous posts for capturing cvi images:

    var VK_A = 0x70;

    function handleEvent(evt)
    {
    switch (evt.key)
    {
    case VK_A:
    CaptureFrame();
    stopEvent(evt);
    }
    }

    function stopEvent(evt)
    {
    evt.stopPropagation();
    evt.preventDefault();
    }

    function CaptureFrame()
    {
    Player.playlist.pause();
    try
    {
    Player.video.main.capture("file:///filecache/image.cvi", RemumePlayback);
    }
    catch (err) {}
    }

    function ResumePlayback(i, uri)
    {
    Player.playlist.play();
    }

    application.addEventListener("controller_key_up", stopEvent, false);
    application.addEventListener("controller_key_down", handleEvent, false);


  • Jo_

    can we test this on iHDSim I am trying to test this code on iHDSim and the video pauses for a second and then resumes, however I am not able to locate the "image.cvi" on my PC. Any suggestions Or this only works for testing on the emulator Am I doing something wrong

  • eldiener

    All resources that you reference in markup MUST be in the filecache. Although you have copied it to pstore for permanent use, you must copy it back to filecache (or rather, just use the original one in filecache) when you reference it in markup.



  • Suman Ghosh

    Andy Pennell MSFT wrote:

    Sure (but not png or jpg). Player.video.main.capture will capture main video in in CVI format to the file cache. You can then use changeImageSize to scale it down, and use the resulting file in markup.

    Ideal for attaching a thumbnail to bookmarks.

    Thanks a lot guys. Using the grabbed frame as a thumbnail to bookmarks was my idea, although I didn't know that we could not save it as png or jpg. I am going to try this and let you guys know if it worked for me.



  • Is there a way to do a frame grab of a movie and store it as a jpg or png in the persistent storage ?