Search Unity

TakeThumbnail() creates new thumbnail of same frame

Discussion in 'Unity Everyplay' started by philstubbs, Apr 20, 2015.

  1. philstubbs

    philstubbs

    Joined:
    Apr 16, 2015
    Posts:
    6
    Toward the end of my level recording I try to call TakeThumbnail() manually so the thumbnail of my video is of the Highlight frame, not some random frame from the beginning.

    Upon calling TakeThumbnail(), a second file (thumbnail-1.jpg) is created, but it has the same exact frame as the randomly created (thumbnail-0.jpg), even though it was clearly taken over a minute later in gameplay.

    Anyone else have this problem / a solution?
     
  2. philstubbs

    philstubbs

    Joined:
    Apr 16, 2015
    Posts:
    6
    Some additional info:
    Everyplay SDK: 1950-1310
    Unity: 5.0.1f1
    Device: Nvidia SHIELD tablet
     
  3. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    245
    I tried to replicate this by creating a rotating cube and using the EveryplayTest.cs script to trigger the TakeThumbnail. I downloaded the captured thumbnails from the device and compared them - they were different. So at least for me this seems to be working correctly. Have you really compared the files? Maybe you just accidentally load the same file again or something.

    You could also try to use texture for the thumbnails instead files since they create less overhead for the cpu when the thumbnail is taken. Method to set texture target: SetThumbnailTargetTexture(Texture2D texture)
     
  4. philstubbs

    philstubbs

    Joined:
    Apr 16, 2015
    Posts:
    6
    I have now gotten hold of another Android device with 4.3 < Version < 5.0 and it works there (Samsung SM-T520).

    So this seems to be an Nvidia SHIELD specific problem.

    Both tablets are running Android 4.4.2.

    On the SHIELD I have compared the actual files and built a dedicated test project / scene with a frame counter and not much more.

    I have attached a zip of the temp folder everyplay creates. As you will be able to see, the thumbnails are identical, but were taken many seconds apart, as the video also shows.
     

    Attached Files:

  5. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    245
    Great! Need to start investigating this with Shield instead. Thanks!
     
  6. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    245
    I'm amazed that you got even one frame ok :) Since when I try the Shield tablet I get only black. Maybe it partly works on Android 4.4 but on Android 5.x which I used for testing it's totally broken. The device is problematic for us and the actual video recording was disabled until Everyplay 1.3 was released. Version 1.3 provided video recording support for it however we totally forgot to do a workaround for the thumbnail. So for now the file based thumbnail is broken for this device and I'm not sure if that can be fixed in the near future.

    If you are showing the texture on screen there is no need to use file target for the thumbnail. Using a Texture2D target is much faster, less cpu overhead and no need to load anything from a file. Texture2D based texture target should also work with Shield tablet. If you really need the file you can use EncodeToPNG/EncodeToJPG methods to get a file from Texture2D.

    Unfortunately the Texture2D related thumbnails methods are still missing from the Everyplay documentation however you basically use it like this:

    Code (CSharp):
    1.     public int thumbnailWidth = 256;
    2.     private Texture2D thumbnailTexture;
    3.  
    4.     void Awake()
    5.     {
    6.         // Thumbnails are always stored landscape in memory
    7.         float aspectRatio = (float)Mathf.Min(Screen.width, Screen.height) / (float)Mathf.Max(Screen.width, Screen.height);
    8.      
    9.         // Calculate height based on aspect ratio
    10.         int thumbnailHeight = (int)(thumbnailWidth * aspectRatio);
    11.      
    12.         // Create a texture for the thumbnail
    13.         thumbnailTexture = new Texture2D(thumbnailWidth, thumbnailHeight, TextureFormat.ARGB32, false);
    14.         thumbnailTexture.wrapMode = TextureWrapMode.Clamp;
    15.      
    16.         // Set thumbnail target to be a texture instead of the default file target
    17.         Everyplay.SetThumbnailTargetTexture(thumbnailTexture);
    18.      
    19.         // Add thumbnail ready callback
    20.         Everyplay.ThumbnailTextureReady += ThumbnailTextureReady;
    21.     }
    22.  
    23.     void ThumbnailTextureReady (Texture2D texture, bool portrait)
    24.     {
    25.         // Do something with the texture
    26.         // e.g. something.material.mainTexture = texture;
    27.     }
    Texture based thumbnails are never taken automatically so you need to trigger it with Everyplay.TakeThumbnail().
     
  7. philstubbs

    philstubbs

    Joined:
    Apr 16, 2015
    Posts:
    6
    Thank you!
    Seems like avoiding the file and going directly to the texture is the way to go in this case. I will try this soon.
     
  8. umair_hassan

    umair_hassan

    Joined:
    Aug 14, 2014
    Posts:
    6
    Well. I am searching for about 4 hours, but fail to sort out, how to and from where i can fetch that thumbnail screenshot .
    I couldn't able to make it. What i am doing is, calling TakeThumbnail() at some point while recording. but I cannot find out from where and how can i use this screenshot.please help me !!!
     
  9. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    245
    Please remember that thumbnail works only when recording is running. And since you can't record on editor, you can take thumbnails only on a real device, iOS or Android.