Retrieving thumbnails using Video REST API

This post is a contribution from Vitaly Lyamin, an engineer with the SharePoint Developer Support team

The Video REST API provides an ability to discover and interact with videos. We’ve seen a number of issues retrieving thumbnails where the “ThumbnailURL” endpoint returns an endpoint (e.g. /pVid/video.mp4.PNG?VideoPreview=1) that is not suitable for use with an AAD app access token and is only accessible via cookie-based authentication (passive or active). Fortunately, there are a few solutions for this.

 

Solution 1

The Video REST API “ThumbnailStream” endpoint can be used with and without the width (in pixels) parameter.

Examples

https://tenant.sharepoint.com/portals/hub/\_api/VideoService/Channels('ac784366-a780-4e21-8bb6-5851c3288906')/Videos('4cafb0e8-8013-40d9-9d5f-370d90e5edc7')/ThumbnailStream
OR

https://tenant.sharepoint.com/portals/hub/\_api/VideoService/Channels('ac784366-a780-4e21-8bb6-5851c3288906')/Videos('4cafb0e8-8013-40d9-9d5f-370d90e5edc7')/ThumbnailStream('100')

Resources https://msdn.microsoft.com/en-us/office/office365/api/video-rest-operations https://techcommunity.microsoft.com/t5/Office-365-Video/Video-thumbnail-URL-broken-when-using-OAuth/td-p/7956

 

Solution 2

The “GetPreview.ashx” handler can also be used with several different inputs (simple example below).

Examples

https://tenant.sharepoint.com/portals/hub/\_layouts/15/getpreview.ashx?path=https%3A%2F%2Ftenant.sharepoint.com%2Fportals%2FChannel1%2FpVid%2Fmov\_bbb.mp4\&resolution=1

Resources https://blogs.msdn.microsoft.com/richard_dizeregas_blog/2014/09/15/developing-apps-against-the-office-graph-part-1/ https://blogs.msdn.microsoft.com/ocarpen/2015/01/09/office-graph-api-and-cortana-chapter-2-how-to-make-queries-by-code-to-the-office-graph/

 

Non-MS Resources: https://www.n8d.at/blog/image-renditions-available-in-modern-team-sites/ https://blog.beecomedigital.com/2015/07/27/generate-thumbnail-of-a-document-stored-in-sharepoint-from-its-url/