Is there a way to load video from azure media service at specific time via query params? - azure

I have a video and a list of timestamps. The timestamps are not defined as an asset filter in Azure Media Service itself.
Is there a way to load the video from Azure Media Service with a specific start time without defining asset filters? Maybe something similar with what you have in youtube when you have a link that starts at a specific second?

Not specifically supported in AMS to alter the URL without using filters, but you could very simply do that client side. Most client side libraries will let you seek.
Have you tried doing that in Javascript already? AMP may not be able to do it, but I have seen video.js and Shaka player implementations that take the t= value from the query string and just set the player.currentPosition.

Related

How to construct a streaming URL for Azure Media Services live stream event? Where is the streaming locator path on the rest api call?

In either the rest api service or the sdk it is not very explanatory in the documentation on how to come up with a stream url.
In the Azure portal it will create one when you create a live streaming event, a live output and a stream locator.
Again, the documentation doesn't address this.
To make videos in the output Asset available to clients for playback, you have to create a Streaming Locator and then build streaming URLs. To build a URL, you need to concatenate the Streaming Endpoint host name and the Streaming Locator path.
Using the rest api where is the streaming locator path? It's not in the response as such.
A lot of the Samples show how to do this as well, the Node.js/Typescript ones are a good place to start, as all of the SDK's mirror each other and the REST API entities.
One of the issues with the current Streaming locator API is that it does not give back the complete path... it's been a problem for a while for some customers and I would have preferred we built the whole path for folks. The reason we do not, is because we offer the flexibility of having multiple Streaming Endpoints (origin servers) in a single account. That allows some customers to build locators for live streams from one endpoint and VOD on-demand streams from a second endpoint that may have a different CDN configuration or caching setup, or CNAME, etc. Kind of our fault for providing too much flexibility - which leads to a complex API. I think we would not do that in a future simplified API.
See this basic streaming example - https://github.com/Azure-Samples/media-services-v3-node-tutorials/blob/main/Streaming/StreamFilesSample/index.ts
async function getStreamingUrls(locatorName: string) {
// Make sure the streaming endpoint is in the "Running" state on your account
let streamingEndpoint = await mediaServicesClient.streamingEndpoints.get(resourceGroup, accountName, "default");
let paths = await mediaServicesClient.streamingLocators.listPaths(resourceGroup, accountName, locatorName);
if (paths.streamingPaths) {
paths.streamingPaths.forEach(path => {
path.paths?.forEach(formatPath => {
let manifestPath = "https://" + streamingEndpoint.hostName + formatPath
console.log(manifestPath);
console.log(`Click to playback in AMP player: http://ampdemo.azureedge.net/?url=${manifestPath}`)
});
});
}
}
Note that you should try to avoid using the REST api directly and use the SDKs instead. Reason is that there is a lot of boilerplate retry logic that is required for Azure Resource Manager retries, etc. that is difficult to roll completely on your own unless you dig into that logic in the open source SDK of your choice and handle the Azure REST response objects and long running opertaion pattterns. I always encourage folks to avoid 'rolling their own language' SDK whenever possible. I've had big customer projects fail when they implemented it wrong or forgot to deal with certain retries.
I had this added to the docs a while back to deal with that issue:
Warning
It is not advised to attempt to wrap the REST API for Media Services directly into your own library code, as doing so properly for production purposes would require you to implement the full Azure Resource Management retry logic and understand how to manage long running operations in Azure Resource Management APIs. This is handled by the client SDKs for various languages - .NET, Java, TypeScript, Python, etc. - automatically and reduces the chances of you having issues with retry logic or failed API calls. The client SDKs all handle this for you already.
After creating the api from scratch and breaking down a produced URL here is what I found.
https://<stream-endpoint-url>/<stream-locator-id>/<manifestName>.ism/manifest(format=m3u8-cmaf)
First creating a livestream you will by default have a Streaming endpoint from Azure Media Services. That or a streaming endpoint you create will be your `<-stream-endpoint-url>
The streamLocatorId listed here unassumingly "properties.streamingLocatorId string The StreamingLocatorId of the Streaming Locator." is actually a 32 bit GUID. "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ***Note you can set this but in reality you should let this but probably should just let it randomly generate.
The manifestName comes from creating the live output and is a property string you can set. "properties.manifestName string The manifest file name. If not provided, the service will generate one automatically."
Lastly, /manifest(format for HLS or Dash) will complete the url.
Unfortunately I couldn't find this in the documentation but hopefully this will help someone.
Update:
What I did find in the docs is this Stream Paths api.
What's nice is about this is that it tells you what the paths are and you just need to concatenate the links together. However, this is a another call after the fact so interesting.

ESRI GPDataFile as input Parameter to GP Toolbox

Im working with a PHP script that POSTs to a GPService Toolbox (written in python), the first parameter is supposed to be a GPDataFile. From the documentation, it looks like I can set the value of this parameter to a json formatted string literal, {"url", "http://localhost/export/1234567890.kml"}, and the arcpy.GetParameter(0) should handle this object correctly.
Unfortunately I am receiving an error, saying 'Please check your parameters', there are two other parameters on the toolbox but they are just strings and are working correctly. I am working in ArcGIS 10.0.
The overall goal of this interaction is to send a KML file from our SWF/ActionScript to the PHP, which saves the KML to our database and subsequently sends it to the GPService to translate it into a GDB and then to individual shapefile objects that are stored in the database for rendering back to the SWF/Actionscript.
Any help our thoughts on how to get the Toolbox to accept the JSON structure would be greatly appreciated, I would like to avoid having to send the KML contents as a string object to the Toolbox.
Answer can be what maniksundaram wrote in ESRI forum (https://community.esri.com/thread/107738):
ArcGIS server will not support direct GPDataFile upload. You have to upload the file using upload task and give the item id for the GP service.
Here is the high level idea to get it work for any GP service which needs file upload,
-Publish the Geoprocessing service with upload option
Refer : ArcGIS Help (10.2, 10.2.1, and 10.2.2)
Operations allowed: Uploads: This capability controls whether a client can upload a file to your GIS server that the tasks within the geoprocessing service would eventually use. The upload operation is mainly used by web clients that need a way to send a file to the server for processing. The upload operation returns a unique ID for the file after the upload completes, which the web application could pass to the geoprocessing service. You may need to modify the maximum file size and timeouts depending on how large an upload you want your server to accept. Check the local REST SDK documentation installed on your ArcGIS Server machine for information on using an uploaded file with a geoprocessing service. This option is off by default. Allowing uploads to your service could possibly pose a security risk. Only turn this on if you need it.
-Upload the file using the upload url that is generated in the geoprocessing service . It will give you the itemID of the uploaded file in response.
http://<servername>:6080/arcgis/rest/services/GP/ConvertKMLToLayer/GPServer/uploads/upload
Response Json:
{"success":true,"item":{"itemID":"ie84b9b8a-5007-4337-8b6f-2477c79cde58","itemName":"SStation.csv","description":null,"date":1409942441508,"committed":true}}
-Invoke the geoprocessing service with the item id as the GPDataFile input ,
For Ex: KMLInput value would be {"itemID":"ie84b9b8a-5007-4337-8b6f-2477c79cde58"}
-The result will be added to map service with job id if you have configured the view the GP results in a map service. Or you can read the response as it returns.

How do I stream an uploaded video on Azure Media Services

I uploaded a video to Azure Media Services, and clicked the "publish" button. That gave me a publish URL.
I then used the Azure Media Player (http://amp.azure.net/libs/amp/latest/docs/samples.html) to embed my video content on a page.
The problem I'm having is that the video is choppy to start. Perhaps it's the encoding of the video, but I want to make sure, if I want to stream a video, using the media player or anything else, do I just use the "Publish URL"? OR is there a different way of requesting video content to "smooth stream"?
Yes. You use the publish URL for VOD and you have a few url parameters to change the type of streaming if needed. Default is smooth streaming.
Smooth Streaming
{streaming endpoint name-media services account name}.streaming.mediaservices.windows.net/{locator ID}/{filename}.ism/Manifest
HLS Streaming
{streaming endpoint name-media services account name}.streaming.mediaservices.windows.net/{locator ID}/{filename}.ism/Manifest(format=m3u8-aapl)
MPEG Dash Streaming
{streaming endpoint name-media services account name}.streaming.mediaservices.windows.net/{locator ID}/{filename}.ism/Manifest(format=mpd-time-csf)
See what works best for you
You can also test on this page and try the advanced settings
http://amsplayer.azurewebsites.net/azuremediaplayer.html
The Azure Media Services test page has changed since the last post. The new URL is:
https://ampdemo.azureedge.net/azuremediaplayer.html

streaming video by origin URL with azure media services

I'm trying to make an app with Smooth Streaming. So I'm doing my app with examples
like these.
In result I have many URLs. Some of them is URL for files that I encoded, they are like:
<mediaservicename>.blob.core.windows.net/asset-d66c43e8-a142-4618-8539-39a2bbb14300/BigBuckBunny_650.mp4?sv=2012-02-12&se=2013-06-23T15%3A21%3A16Z&sr=c&si=aff41a1d-6c8a-4387-8c2f-84272a776ff2&sig=8OPuwW6Kssn2EVQYwqUXkUocc7Qhf0xM62rS9aSPsMk%3D
And one of URL is like:
<mediaservicename>.origin.mediaservices.windows.net/6eca30d3-badd-4f45-bc29-264303ffe84a/BigBuckBunny_3400.ism/Manifest
When I try playing the first one on WindowsAzure portal - that's ok.
But when I'm trying to play the second one on WindowsAzure portal - there is an error "we are unable to connect to the content you've requested. We apologize for the inconvenience".
When I'm trying to play them both in my app with Silverlight they do not play as well as on smf.cloudapp.net / healthmonitor.
Maybe there are some errors in the examples on Windiws Azure site? Or what can it be?
The first url you copied cannot be used in a Smooth Streaming player, but the second one may be, if you have created a valid origin locator with a valid access policy.
Can you copy the code you have used to generate these URLs please ?
Hope this helps
Julien

Grab instagram photo based on hashtags

I am new to instagram and i am tasked to program an application to grab instagram photo uploads based on a certain hashtag. Meaning if the application is started and searching for the hashtag "#awesomeevent" any one that uploads a photo with that hashtags it will automatically be stored into our database.
The application should work something similar to http://statigr.am/tag/ but instead displaying the photos it should store the photos into the database.
What is the process of doing this. Any tutorials that has this from start to end. Even covering how to start creating a instagram app from scratch. any help would be greatly appreciated.
Thanks
Things we developers often overlook are the API Terms and Conditions. I've been there myself.
API TERMS OF USE
Before you start using the API, we have a few guidelines that we'd like to tell you about. Please make sure to read the full API Terms of Use
Terms of Use. Here's what you'll read about:
Instagram users own their images. It's your responsibility to make sure that you respect that right.
You cannot use the Instagram name in your application.
You cannot use the Instagram API to crawl or store users' images without their express consent.
You cannot replicate the core user experience of Instagram.com
Do not abuse the API. Too many requests too quickly will get your access turned off
However, a part in the terms also states that:
You shall not cache or store any Instagram user photos other than for reasonable periods in order to provide the service you are
providing to Instagram users.
Hope that's a start before you actually get coding and storing images.
API Terms of Use: http://instagram.com/about/legal/terms/api/
API: http://instagram.com/developer/
For starter, you should consult to instagram api.
As for the specific api you will need is:
/tags/tag-name/media/recent
For example, if you want to look for images from tag #awesomeevent, you will do an api query to:
https://api.instagram.com/v1/tags/awesomeevent/media/recent?access_token=ACCESS-TOKEN
I would have a look at the two libraries Instagram provides. The ruby library is at https://github.com/Instagram/instagram-ruby-gem and the python library is at https://github.com/Instagram/python-instagram
They both seem to have examples to get you started if you're programming with either libraries.
As far as the storing issue goes, could you instead store the URL address of the images instead of the actual images themselves? The API returns JSON information of which the URL of the images are returned.
Hope that helps.
You can use the below ruby script to retrieve the images and save them to a file. You can then either reference the file within the database or replace the last block with code for your particular database implementation. Without knowing your database type and schema, no one can tell you how to add something to it.
require "instagram"
require "restclient"
Instagram.configure do |config|
config.client_id = INSTAGRAM_CLIENT_ID
config.client_secret = INSTAGRAM_CLIENT_SECRET
end
instagram_client = Instagram.client(:access_token => INSTAGRAM_ACCESS_TOKEN)
tags = instagram_client.tag_search('cat')
urls = Array.new
for media_item in instagram_client.tag_recent_media(tags[0].name)
urls << media_item.images.standard_resolution.url
end
urls.each_with_index do |url, idx|
image = RestClient.get(url)
path = Dir.pwd + "/#{idx}.jpg"
File.open(path, 'w') {|f| f.write(image) }
end

Resources