How to get thumbnail of Videos in Azure media services via REST API - azure-media-services

I am using azure media services for mobile application.It works properly.I just Want to get the thumbnails of published assets via REST API.I need API endpoints for thumbnails.

I read sample code and try to start a job using the AMS RestAPI(V2).
Then,you can create a SASLocator to download thumbnail when the job is finished.
POST {{RESTAPIEndpoint}}/Jobs
{
"Name": "NewThumbnailJOB",
"InputMediaAssets": [{
"__metadata": {
"uri": "{{RESTAPIEndpoint}}/Assets('nb:cid:UUID:xxxxx')"
}
}],
"Tasks": [{
"Configuration":"{
\"Version\": 1.0,
\"Codecs\": [
{
\"PngLayers\": [
{
\"Type\": \"PngLayer\",
\"Width\": \"100%\",
\"Height\": \"100%\"
}
],
\"Start\": \"{Best}\",
\"Type\": \"PngImage\"
}
],
\"Outputs\": [
{
\"FileName\": \"{Basename}_{Index}{Extension}\",
\"Format\": {
\"Type\": \"PngFormat\"
}
}
]
}
",
"MediaProcessorId": "{{Media Encoder Standard ID}}",
"TaskBody": "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<taskBody>
<inputAsset>JobInputAsset(0)</inputAsset>
<outputAsset>JobOutputAsset(0)</outputAsset>
</taskBody>"
}]
}

Related

Kinesis Stream - API Gateway: Serialization Exception

I am integrating Kinesis Stream with API Gateway following this tutorial.
The records endpoint uses the PutRecords action. The expected request template for this endpoint is the following:
{
"StreamName": "$input.params('stream-name')",
"Records": [
{
"Data": "$util.base64Encode($elem.data)",
"PartitionKey": "$input.path('$.PartitionKey')"
}#if($foreach.hasNext),#end
]
}
Despite following the tutorial exactly as it is, if I send a Request body with the expected format such as the next one, I get a SerializationException error:
{
"StreamName": "my_kinesis_stream",
"Records": [
{
"Data": "XzxkYXRhPl8x",
"PartitionKey": "partitionKey1"
},
{
"Data": "f1PxFQo92Afh",
"PartitionKey": "partitionKey1"
},
{
"Data": "Gi4sEdd08HypA",
"PartitionKey": "partitionKey1"
}
]
}
I don't know if the template of the tutorial is the right one or if my body request has not the proper format.
Oddly, all the other endpoints of the tutorial work just fine. This is the only one not working properly.
Thanks in advance.
The documentation actually was wrong. This documentation specifies the correct request template:
{
"StreamName": "$input.params('stream-name')",
"Records": [
#foreach($elem in $input.path('$.records'))
{
"Data": "$util.base64Encode($elem.data)",
"PartitionKey": "$elem.partition-key"
}#if($foreach.hasNext),#end
#end
]
}

Why I do not receive the attachments in the Facebook Messenger webhook request?

Since yesterday (29/10/2020) i'm having this problem only on one of the pages linked to my app, the others work correctly:
The attached messages that the webhook receives from Facebook do not contain the attachment field.
Only messages with stickers contain the "attachment" field. All others (image, video, audio etc.) No.
What I expect (as facebook documentation) is:
{
"id": "682498302938465",
"time": 1518479195594,
"messaging": [
{
"sender": {
"id": "<PSID>"
},
"recipient": {
"id": "<PAGE_ID>"
},
"timestamp": 1518479195308,
"message": {
"mid": "mid.$cAAJdkrCd2ORnva8ErFhjGm0X_Q_c",
"attachments": [
{
"type": "<image|video|audio|file>",
"payload": {
"url": "<ATTACHMENT_URL>"
}
}
]
}
}
]
}
but I only receive:
{
"object": "page",
"entry": [
{
"id": "119320008135788",
"time": 1604051633128,
"messaging": [
{
"sender": {
"id": "XXXXXX"
},
"recipient": {
"id": "XXXXXX"
},
"timestamp": 1604051632953,
"message": {
"mid": "m_7DRP...."
}
}
]
}
]
}
This only happens on one page from 29/10/2020
Does anyone have the same problem / know why it happens?
The Facebook support team has confirmed my problem, and is investigating.
I am now solving using the graph api to get the desired message information using the mid
GET /v8.0/{message-id} HTTP/1.1
Host: graph.facebook.com
https://developers.facebook.com/docs/graph-api/reference/v8.0/message
Ex.
GET
https://graph.facebook.com/v8.0/' + mid + '?fields=message%2Cfrom%2Csticker%2Ctags%2Cid%2Cattachments.limit(10)%7Bid%2Cimage_data%2Cmime_type%2Cname%2Cfile_url%2Cvideo_data%7D&access_token=XXXXXX

Can not create new layer (featuretype) in GeoServer using REST API

So I just used 2 working days trying to figure this out. We are automatic rendering process for maps. All the data is given in SQL base and my job is to write "wrapper" so we can implement this in our in-house framework. I managed all but one needed requests.
That request is POST featuretype since this is a way of creating a layer that can later be rendered.
I have all requests saved in postman for pre-testing on example data given by geoserver itself. I can't even get response with status code 201 and always get 500 internal server error. This status is described as possible syntax error in sytax. But I actually just copied and pasted exampled and used geoserver provided data.
This is the requst: http://127.0.0.1:8080/geoserver/rest/workspaces/tiger/datastores/nyc/featuretypes
and its body:
{
"name": "poi",
"nativeName": "poi",
"namespace": {
"name": "tiger",
"href": "http://localhost:8080/geoserver/rest/namespaces/tiger.json"
},
"title": "Manhattan (NY) points of interest",
"abstract": "Points of interest in New York, New York (on Manhattan). One of the attributes contains the name of a file with a picture of the point of interest.",
"keywords": {
"string": [
"poi",
"Manhattan",
"DS_poi",
"points_of_interest",
"sampleKeyword\\#language=ab\\;",
"area of effect\\#language=bg\\;\\#vocabulary=technical\\;",
"Привет\\#language=ru\\;\\#vocabulary=friendly\\;"
]
},
"metadataLinks": {
"metadataLink": [
{
"type": "text/plain",
"metadataType": "FGDC",
"content": "www.google.com"
}
]
},
"dataLinks": {
"org.geoserver.catalog.impl.DataLinkInfoImpl": [
{
"type": "text/plain",
"content": "http://www.google.com"
}
]
},
"nativeCRS": "GEOGCS[\"WGS 84\", \n DATUM[\"World Geodetic System 1984\", \n SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]], \n AUTHORITY[\"EPSG\",\"6326\"]], \n PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], \n UNIT[\"degree\", 0.017453292519943295], \n AXIS[\"Geodetic longitude\", EAST], \n AXIS[\"Geodetic latitude\", NORTH], \n AUTHORITY[\"EPSG\",\"4326\"]]",
"srs": "EPSG:4326",
"nativeBoundingBox": {
"minx": -74.0118315772888,
"maxx": -74.00153046439813,
"miny": 40.70754683896324,
"maxy": 40.719885123828675,
"crs": "EPSG:4326"
},
"latLonBoundingBox": {
"minx": -74.0118315772888,
"maxx": -74.00857344353275,
"miny": 40.70754683896324,
"maxy": 40.711945649065406,
"crs": "EPSG:4326"
},
"projectionPolicy": "REPROJECT_TO_DECLARED",
"enabled": true,
"metadata": {
"entry": [
{
"#key": "kml.regionateStrategy",
"$": "external-sorting"
},
{
"#key": "kml.regionateFeatureLimit",
"$": "15"
},
{
"#key": "cacheAgeMax",
"$": "3000"
},
{
"#key": "cachingEnabled",
"$": "true"
},
{
"#key": "kml.regionateAttribute",
"$": "NAME"
},
{
"#key": "indexingEnabled",
"$": "false"
},
{
"#key": "dirName",
"$": "DS_poi_poi"
}
]
},
"store": {
"#class": "dataStore",
"name": "tiger:nyc",
"href": "http://localhost:8080/geoserver/rest/workspaces/tiger/datastores/nyc.json"
},
"cqlFilter": "INCLUDE",
"maxFeatures": 100,
"numDecimals": 6,
"responseSRS": {
"string": [
4326
]
},
"overridingServiceSRS": true,
"skipNumberMatched": true,
"circularArcPresent": true,
"linearizationTolerance": 10,
"attributes": {
"attribute": [
{
"name": "the_geom",
"minOccurs": 0,
"maxOccurs": 1,
"nillable": true,
"binding": "com.vividsolutions.jts.geom.Point"
},
{},
{},
{}
]
}
}
So it is example case and I can't get any useful response from the server. I get the code 500 with body name (the first item in json). Similarly I get same code with body FeatureTypeInfo when trying with xml body(first tag).
I already tried the request in new instance of geoserver in Docker (changed the port) and still no success.
I check if datastore, workspace is available and that layer "poi" doesn't yet exists.
Here are also some logs of request (similar for xml body):
2018-08-03 07:35:02,198 ERROR [geoserver.rest] -
com.thoughtworks.xstream.mapper.CannotResolveClassException: name at
com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:79)
at .....
Does anyone know the solution to this and got it working. I am using GeoServer 2.13.1
So i was still looking for the answer and using this post (https://gis.stackexchange.com/questions/12970/create-a-layer-in-geoserver-using-rest) got to the right content to POST featureType and hence creating a layer in GeoServer.
The documentation is off in REST API docs.
Using above link I found out that when using JSON there is a missing insertion in JSON. For API to work here we need to add:
{featureType:
name: "...",
nativeName: "...",
.
.
.}
So that it doesn't start with "name" attribute but it is contained in "featureType".
I didn't try that for XML also but I guess it could be similar.
Hope this helps someone out there struggling like I did.
Blaz is correct here, you need an outer object of FeatureType and then an inner object with your config. So;
{
"featureType": {
"name": "layer",
"nativeName": "poi",
"your config": "stuff"
}
I find though that using a post request I get very little if any response and its not obvious if the layer creation worked. But you can call http://IP:8080/geoserver/rest/layers.json to check if your new layer is there.
It costs me a lot of time to create FeatureTypes using REST API. Use Json like this really works:
{
"featureType": {
"name": "layer",
"nativeName": "poi"
"otherProperties...":"values..."
}
And use Json below to create Workspace:
{
"workspace": {
"name": "test_workspace"
}
}
The REST API is out of date now. That's disappointing. Is there anyone knows how to get the lastest REST API document?

Media Response in Custom Payload (Dialogflow)

I'm trying to code a Media Response in a Custom Payload with no luck. I'm surely doing something wrong but I have no idea :) The Media Response does not show up when testing. (Please note that I'm trying this in an english action). Here's the JSON code:
{
"platform": "google",
"type": "custom_payload",
"payload": {
"google": {
"richResponse": {
"items": [
{
"mediaResponse": {
"mediaType": "AUDIO",
"mediaObjects": [
{
"name": "Exercises",
"description": "ex",
"largeImage": {
"url": "https://firebasestorage.googleapis.com/...",
"accessibilityText": "image..."
},
"contentUrl": "https://firebasestorage.googleapis.com/..."
}
]
}
}
]
}
}
}
}
UPDATE:
I've updated the JSON to something like this. But I get an error :"API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: ": Cannot find field."
{
"platform":"google",
"type":"custom_payload",
"payload":{
"google":{
"richResponse":{
"items":[
{
"simpleResponse":{
"textToSpeech":"Hey! Good to see you."
}
},
{
"mediaResponse":{
"mediaType":"AUDIO",
"mediaObjects":[
{
"name":"Exercises",
"description":"ex",
"largeImage":{
"url":"https://firebasestorage...",
"accessibilityText":"..."
},
"contentUrl":"https://firebasestorage.googleapis.com/..."
}
]
}
}
],
"suggestions":[
{
"title":"chips"
}
]
}
}
And here's the debug information:
{
"audioResponse": "//NExAARWG...",
"conversationToken": "GidzaW11bG...",
"debugInfo": {
"agentToAssistantDebug": {
"agentToAssistantJson": "{\"message\":\"Failed to parse Dialogflow response into AppResponse, exception thrown with message: Empty speech response\",\"apiResponse\":{\"id\":\"cd7204ac-ab80-42aa-9755-6123cbb938a6\",\"timestamp\":\"2018-03-11T09:02:35.827Z\",\"lang\":\"en-us\",\"result\":{},\"status\":{\"code\":200,\"errorType\":\"success\"},\"sessionId\":\"1520758955600\"}}"
},
"assistantToAgentDebug": {
"assistantToAgentJson": "{\"user\":{\"userId\":\"AA9douaa4XGkqtmcU_EDjPy7PQ_9\",\"locale\":\"en-US\",\"lastSeen\":\"2018-03-11T09:02:09Z\"},\"conversation\":{\"conversationId\":\"1520758955600\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"VOICE\",\"query\":\"Talk to Zen Coach\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"}]}]}",
"curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=0def1bb6be4b4bf2810ec68bf6f37a6a' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: eyJhbGciOiJSUzI1NiIsImtpZCI6ImFjMmI2M2ZhZWZjZjgzNjJmNGM1MjhlN2M3ODQzMzg3OTM4NzAxNmIifQ.eyJhdWQiOiJ6ZW4tY29hY2giLCJhenAiOiI0OTYwOTIwOTE1NzEtMGNhY3VtczVkZ3F1OWpkM2k0dHZpOGFiOTVydXQ2NnQuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJleHAiOjE1MjA3NTkwNzUsImlzcyI6Imh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbSIsImp0aSI6IjY4NDc0NThhNTNhZGExODAxZjMwMjAyYjkxZGIyODZhMjk1NzA2YmIiLCJpYXQiOjE1MjA3NTg5NTUsIm5iZiI6MTUyMDc1ODY1NX0.e1cqg96F5L-BvD0yJz3UFgsnX_0TRox0Lu8R9K5NhhXcQVfC7mq1QwCqs2DGrUJGquGdW2GhzBU2lzf4ro2TUeieg4ozak1OmiYAMqtiCH0EodeHy59AXXqzb3a35YuD7CmSDu6qVQRfEp8uaaH2t-Sq9lUchudNOgjucip3ex9Rr2XacHm0qWtV69H1o-Yq5INl5HHR0kNqtEIsxUox961imKvDLN5s--F35yTbAhIWibr6OmaACyzSQW5X7OjrJ2781DSmEdYn73poDbuwMS9E2l9B-QTUHAIpUM5b4WqrFkD6XKALdf2pQFwZlRRhDzRiDKWLA-i1w-mcak0LWw' -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"AA9douaa4XGkqtmcU_EDjPy7PQ_9\",\"locale\":\"en-US\",\"lastSeen\":\"2018-03-11T09:02:09Z\"},\"conversation\":{\"conversationId\":\"1520758955600\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"VOICE\",\"query\":\"Talk to Zen Coach\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"}]}]}'"
},
"sharedDebugInfo": [
{
"name": "ResponseValidation",
"subDebugEntry": [
{
"debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\".",
"name": "UnparseableJsonResponse"
}
]
}
]
},
"response": "Zen coach isn't responding right now. Try again soon.",
"visualResponse": {
"visualElements": []
}
}
Are you adding "platform":"google" and "type":"custom_payload" in the custom payload? If so, try removing that.
I made the following work with my Voice Metronome application:
{
"google":{
"richResponse":{
"items":[
{
"simpleResponse":{
"textToSpeech":"Hey! Good to see you."
}
},
{
"mediaResponse":{
"mediaType":"AUDIO",
"mediaObjects":[
{
"name":"Exercises",
"description":"ex",
"largeImage":{
"url":"http://res.freestockphotos.biz/pictures/17/17903-balloons-pv.jpg",
"accessibilityText":"..."
},
"contentUrl":"https://freepd.com/Chill/Chill Air.mp3"
}
]
}
}
],
"suggestions":[
{
"title":"chips"
}
]
}
}
}
The issue is that the richResponse property still needs to follow the rules of the RichResponse object. The first item in it must be a SimpleResponse object. (I haven't tested, but you can probably have that say nothing, but it is a good spot to have an introduction to your audio.)
The error message Failed to parse Dialogflow response into AppResponse, exception thrown with message: Empty speech response suggests that it might also be looking for a speech parameter on the top-level object in the response, which is what Dialogflow v1 expects to duplicate either the simpleResponse ssml or textToSpeech parameters. I'm not sure why that would appear if you're set to v2, but it sounds like something might be confused there. I would make sure you're using v1 and that you have a speech parameter.
Also keep in mind that the reviewers will look for suggestion chips about how to move the conversation forward during or after the audio if this isn't a final response.

Messenger: attachment type 'video' not working correctly?

According to https://developers.facebook.com/docs/messenger-platform/send-api-reference/video-attachment I should be able to send video's via messenger. I ideally want to send youtube videos with a start and end time, but that does not seem to work.
I am currently trying to get it work in any such way, so i have the video on FB currently and even that isn't working.
python code
data = OrderedDict()
data['sender'] = {"id": APP_ID}
data['recipient'] = {"id": recipient}
data['message'] = {
"attachment": {
"type": "video",
"payload": {"url": "https://www.facebook.com/587721184763189/videos/596530243882283/"}
}
}
data = json.dumps(data)
print("data: ", data)
r = requests.post("https://graph.facebook.com/v2.6/me/messages",
params={"access_token": token},
data=data,
headers={'Content-type': 'application/json'},
timeout=60)
if r.status_code != requests.codes.ok:
print(r.text)
2016-12-20T23:45:40.685949+00:00 app[web.1]: data: {"sender": {"id": 744391742366207}, "recipient": {"id": "1297603110290455"}, "message": {"attachment": {"type": "video", "payload": {"url": "https://www.facebook.com/587721184763189/videos/596530243882283/"}}}}
2016-12-20T23:45:41.396419+00:00 app[web.1]: {"error":{"message":"(#100) Failed to fetch the file from the url","type":"OAuthException","code":100,"error_subcode":2018008,"fbtrace_id":"BjJzB1J8/42"}}
You need to supply the URL to the video file (for example MP4), not the URL of page containing the video (for example a YouTube URL).
This can be seen in the example code in Facebook's documentation
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"attachment":{
"type":"video",
"payload":{
"url":"https://petersapparel.com/bin/clip.mp4"
}
}
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN"
Sending Youtube videos in your Facebook Messenger bot is now possible if you use the open graph template.
A message object would then look like this:
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "open_graph",
"elements": [
{
"url": "https://www.youtube.com/watch?v=whatever"
}
]
}
}
}
As of today, this works (you need to add the image url of the screenshot):
message: {
text,
attachment: {
type: "template",
payload: {
template_type: "generic",
elements: [
{
title: "El espía",
image_url: "https://i.ytimg.com/vi/yj2r6KPKV1w/hqdefault.jpg?sqp=-oaymwEcCOADEI4CSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLAGKGjilp1gvYUv6c5dL_oveZ8LYg",
default_action: {
type: "web_url",
url: "https://www.youtube.com/watch?v=yj2r6KPKV1w",
},
}
],
},
},
},