Retrieving thumbnails using Video REST API

Published 05-01-2019 04:07 PM 468 Views
Microsoft
First published on TECHNET on Nov 17, 2017
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-5851c3...
OR

https://tenant.sharepoint.com/portals/hub/_api/VideoService/Channels('ac784366-a780-4e21-8bb6-5851c3...')

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-OA...


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.shar...

Resources

https://blogs.msdn.microsoft.com/richard_dizeregas_blog/2014/09/15/developing-apps-against-the-o...

https://blogs.msdn.microsoft.com/ocarpen/2015/01/09/office-graph-api-and-cortana-chapter-2-how-t...



Non-MS Resources:

http://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...

%3CLINGO-SUB%20id%3D%22lingo-sub-510017%22%20slang%3D%22en-US%22%3ERetrieving%20thumbnails%20using%20Video%20REST%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-510017%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20TECHNET%20on%20Nov%2017%2C%202017%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20This%20post%20is%20a%20contribution%20from%20Vitaly%20Lyamin%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20The%20Video%20REST%20API%20provides%20an%20ability%20to%20discover%20and%20interact%20with%20videos.%20We%E2%80%99ve%20seen%20a%20number%20of%20issues%20retrieving%20thumbnails%20where%20the%20%E2%80%9CThumbnailURL%E2%80%9D%20endpoint%20returns%20an%20endpoint%20(e.g.%20%2FpVid%2Fvideo.mp4.PNG%3FVideoPreview%3D1)%20that%20is%20not%20suitable%20for%20use%20with%20an%20AAD%20app%20access%20token%20and%20is%20only%20accessible%20via%20cookie-based%20authentication%20(passive%20or%20active).%20Fortunately%2C%20there%20are%20a%20few%20solutions%20for%20this.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3ESolution%201%20%3CBR%20%2F%3E%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20The%20Video%20REST%20API%20%E2%80%9CThumbnailStream%E2%80%9D%20endpoint%20can%20be%20used%20with%20and%20without%20the%20width%20(in%20pixels)%20parameter.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3EExamples%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Ftenant.sharepoint.com%2Fportals%2Fhub%2F_api%2FVideoService%2FChannels('ac784366-a780-4e21-8bb6-5851c3288906')%2FVideos('4cafb0e8-8013-40d9-9d5f-370d90e5edc7')%2FThumbnailStream%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftenant.sharepoint.com%2Fportals%2Fhub%2F_api%2FVideoService%2FChannels('ac784366-a780-4e21-8bb6-5851c3288906')%2FVideos('4cafb0e8-8013-40d9-9d5f-370d90e5edc7')%2FThumbnailStream%3C%2FA%3E%20%3CBR%20%2F%3E%20OR%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Ftenant.sharepoint.com%2Fportals%2Fhub%2F_api%2FVideoService%2FChannels('ac784366-a780-4e21-8bb6-5851c3288906')%2FVideos('4cafb0e8-8013-40d9-9d5f-370d90e5edc7')%2FThumbnailStream('100%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftenant.sharepoint.com%2Fportals%2Fhub%2F_api%2FVideoService%2FChannels('ac784366-a780-4e21-8bb6-5851c3288906')%2FVideos('4cafb0e8-8013-40d9-9d5f-370d90e5edc7')%2FThumbnailStream('100%3C%2FA%3E')%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3E%20Resources%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Foffice%2Foffice365%2Fapi%2Fvideo-rest-operations%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Foffice%2Foffice365%2Fapi%2Fvideo-rest-operations%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FOffice-365-Video%2FVideo-thumbnail-URL-broken-when-using-OAuth%2Ftd-p%2F7956%22%20target%3D%22_blank%22%3E%20https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FOffice-365-Video%2FVideo-thumbnail-URL-broken-when-using-OAuth%2Ftd-p%2F7956%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3E%20Solution%202%20%3CBR%20%2F%3E%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20The%20%E2%80%9CGetPreview.ashx%E2%80%9D%20handler%20can%20also%20be%20used%20with%20several%20different%20inputs%20(simple%20example%20below).%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3EExamples%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Ftenant.sharepoint.com%2Fportals%2Fhub%2F_layouts%2F15%2Fgetpreview.ashx%3Fpath%3Dhttps%253A%252F%252Ftenant.sharepoint.com%252Fportals%252FChannel1%252FpVid%252Fmov_bbb.mp4%26amp%3Bresolution%3D1%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftenant.sharepoint.com%2Fportals%2Fhub%2F_layouts%2F15%2Fgetpreview.ashx%3Fpath%3Dhttps%253A%252F%252Ftenant.sharepoint.com%252Fportals%252FChannel1%252FpVid%252Fmov_bbb.mp4%26amp%3Bresolution%3D1%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3E%20Resources%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Frichard_dizeregas_blog%2F2014%2F09%2F15%2Fdeveloping-apps-against-the-office-graph-part-1%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fblogs.msdn.microsoft.com%2Frichard_dizeregas_blog%2F2014%2F09%2F15%2Fdeveloping-apps-against-the-office-graph-part-1%2F%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Focarpen%2F2015%2F01%2F09%2Foffice-graph-api-and-cortana-chapter-2-how-to-make-queries-by-code-to-the-office-graph%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fblogs.msdn.microsoft.com%2Focarpen%2F2015%2F01%2F09%2Foffice-graph-api-and-cortana-chapter-2-how-to-make-queries-by-code-to-the-office-graph%2F%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3E%20Non-MS%20Resources%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22http%3A%2F%2Fwww.n8d.at%2Fblog%2Fimage-renditions-available-in-modern-team-sites%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20http%3A%2F%2Fwww.n8d.at%2Fblog%2Fimage-renditions-available-in-modern-team-sites%2F%20%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fblog.beecomedigital.com%2F2015%2F07%2F27%2Fgenerate-thumbnail-of-a-document-stored-in-sharepoint-from-its-url%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fblog.beecomedigital.com%2F2015%2F07%2F27%2Fgenerate-thumbnail-of-a-document-stored-in-sharepoint-from-its-url%2F%3C%2FA%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-510017%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TECHNET%20on%20Nov%2017%2C%202017%20This%20post%20is%20a%20contribution%20from%20Vitaly%20Lyamin%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20teamThe%20Video%20REST%20API%20provides%20an%20ability%20to%20discover%20and%20interact%20with%20videos.%3C%2FLINGO-TEASER%3E
Version history
Last update:
‎Aug 27 2020 03:37 PM
Updated by: