In my application, I'm using AWS media-convert jobs to generate the thumbnail from my video uploaded to s3. The video gets uploaded from mobile. It works fine when I record a video from my mobile and uploads it at the same time. I got thumbnail generated properly.
But when I upload a pre-recorded video from the same mobile and upload it the thumbnail for that video get rotated by -90 degree.
Not sure what could be the problem here.
It sounds like there is rotation metadata embedded in the video file that is being recording with the mobile device. Devices, like the iPhone, do this automatically depending on the orientation of the phone while it's recording. This data will tell MediaConvert to change rotation of the input file. By default, MediaConvert will use no rotation, I would suggest flipping this to 'AUTO', and let the service correctly rotate video accordingly.
Apples Quicktime file format (1), and ISO 14496-12 (Section A.6) should have more details about this piece of metadata if you are interested.
JSON Settings with Rotate set to AUTO:
"Inputs": [
{
"AudioSelectors": {
"Audio Selector 1": {
"Offset": 0,
"DefaultSelection": "DEFAULT",
"ProgramSelection": 1
}
},
"VideoSelector": {
"ColorSpace": "FOLLOW",
"Rotate": "AUTO",
"AlphaBehavior": "DISCARD"
},
"FilterEnable": "AUTO",
"PsiControl": "USE_PSI",
"FilterStrength": 0,
"DeblockFilter": "DISABLED",
"DenoiseFilter": "DISABLED",
"TimecodeSource": "EMBEDDED",
"FileInput": "s3://bucket123/test.mov"
}
]
== Documentation ==
[1] https://docs.aws.amazon.com/mediaconvert/latest/ug/manually-specified-rotation.html
[2]https://docs.aws.amazon.com/mediaconvert/latest/apireference/jobs.html#jobs-prop-videoselector-rotate
[3] https://developer.apple.com/standards/qtff-2001.pdf
Related
I am trying to create a reminder using Alexa's Reminder API in my custom Alexa Skill and in the SSML, I am passing the speak tag and in that, I have few words and audio tag too.
const reminderRequest = {
trigger: {
type: 'SCHEDULED_RELATIVE',
offsetInSeconds: '10',
},
alertInfo: {
spokenInfo: {
content: [{
locale: "en-US",
text: "Testing Reminder",
ssml: "<speak>Testing Reminder <audio src='https://vishalsholkaybucket.s3.amazonaws.com/uk_21042020.mp3' /></speak>"
}],
},
},
pushNotification: {
status: 'ENABLED',
},
};
The output to above in my Alexa device is:
Testing
The reminder works properly but when it comes to playing the audio file, it just keeps its light on and doesn't play the audio file, other SSML tags like break etc is working fine but only the audio tag is not working. I was under the impression that SSML tags work everywhere, I tried reading the documentation but it is not clear enough.
Also, if this is not the right approach, can anyone let me know If I can play a short audio file in Alexa's reminder API or is there any way in which I can remind the user along with an audio file.
Thanks in advance.
Edit: I am using Alexa's skill reminders demo. Nothing else is changed just trying to push the above request in the Reminders API.
I have created a simple chatbot with the following flow.
Bot: do you want to buy a book?
Human: yes
Bot: what kind of book are you interested? (Response card)
-drama
-crime
-action
Human: drama (on click or typing)
Bot: Here is list of available drama movies in store(response card)
- Django
- first man
-true story
The last part is problem , I can't figure out how I can achieve that.
Can some one please help me what do I need to do to get what I want? Similar demo or tutorial Will be appreciated.
Here you need to add a response card using your Lambda code because the values are dynamic (available movies).
Here is the example code of adding response card:
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled or Failed",
"message": {
"contentType": "PlainText or SSML",
"content": "Message to convey to the user. For example, Thanks, your pizza has been ordered."
},
"responseCard": {
"version": "1",
"contentType": "application/vnd.amazonaws.card.generic",
"genericAttachments": [
{
"title":"card-title",
"subTitle":"card-sub-title",
"imageUrl":"URL of the image to be shown",
"attachmentLinkUrl":"URL of the attachment to be associated with the card",
"buttons":[
{
"text":"button-text",
"value":"Value sent to server on button click"
}
]
}
]
}
}
This is an example of adding response card in a fulfimmnet message, you can add this in elicit_slot as well. Play around it and let us know if you have any confusion.
Hope it helps.
I am trying to build an android application (in android studio platform) which extracts different text languages from image using google cloud vision, but I have a problem in starting.
I don't know how to use google cloud files. Which files do I need to create or download and how to direct my API to extract multiple languages?
I got the API and this source code :
POST https://vision.googleapis.com/v1/images:annotate?key=YOUR_API_KEY
{
"requests": [
{
"image": {
"content": "/9j/7QBEUGhvdG9zaG9...base64-encoded-image-content...fXNWzvDEeYxxxzj/Coa6Bax//Z"
},
"features": [
{
"type": "TEXT_DETECTION"
}
]
}
]
}
public static void detectText(String filePath, PrintStream out) throws Exception, IOException {
List<AnnotateImageRequest> requests = new ArrayList<>();
ByteString imgBytes = ByteString.readFrom(new FileInputStream(filePath));
Image img = Image.newBuilder().setContent(imgBytes).build();
Feature feat = Feature.newBuilder().setType(Type.TEXT_DETECTION).build();
AnnotateImageRequest request =
AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
requests.add(request);
try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
List<AnnotateImageResponse> responses = response.getResponsesList();
for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
out.printf("Error: %s\n", res.getError().getMessage());
return;
}
// For full list of available annotations, see http://g.co/cloud/vision/docs
for (EntityAnnotation annotation : res.getTextAnnotationsList()) {
out.printf("Text: %s\n", annotation.getDescription());
out.printf("Position : %s\n", annotation.getBoundingPoly());
}
}
}
}
I would suggest you to try your image data on the Cloud Vision Api Explorer [1]. You can try the API directly on the web browser with an Oauth2 authentication. Follow the steps below:
Enable the API on Google Cloud Console -> APIs and Services -> Libraries
Set the scopes on the API Explorer checkbox:
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/cloud-vision
{
"requests": [
{
"features": [
{
"type": "TEXT_DETECTION"
}
],
"image": {
"source": {
"imageUri": "http://dps.usc.edu/files/2015/07/text-alerts.png"
},
},
"imageContext": {
"languageHints": [
"en"
]
}
]
}
Set de “imageContext”. There you can set language hints, but the API might detect the language automatically. Check this [2] for available language hints.
In the source you could use an image from your Google Cloud Storage bucket changing “imageUri” by: "gcsImageUri": "gs://your-bucket/text-alerts.png" as your image uri. Note the change in protocol.
You are using “content” instead of “source”, and this is for setting a base64 encoded string image. You can try to encode an image with Base64 copy the encode as plain text and try on the API Explorer to check that the encode is correct and works. Be careful when copying as you may get noise like \n, \t and things that might break your b64 encode. I share a python code that does the job:
import base64
f = open("text-alerts.png", "rb")
encoded = base64.b64encode(f.read())
print(encoded)
f.close()
fw = open('content.b64', "wb")
fw.write(encoded)
fw.close()
In your request:
{ "requests": [ { "image": { "content": "/9j/7QBEUGhvdG9zaG9...base64-encoded-image-content...fXNWzvDEeYxxxzj/Coa6Bax//Z" }, "features": [ { "type": "TEXT_DETECTION" } ] } ] }
The content tag is the image string in Base64:
"content":“/9j/7QBEUGhvdG9zaG9...base64-encoded-image-content...fXNWzvDEeYxxxzj/Coa6Bax//Z”
You can use a web tool to do the same and check that your Base64 works. You can load the file on the Android Studio.
Here [4] you can find a sample for Android, with a README that explains how to configure your App. You need to create your API Key here [3] and in the MainActivity you have a variable that must be set to your API Key that then is used for the request.
private static final String CLOUD_VISION_API_KEY = "YOUR_API_KEY";
The sample loads an image and converts it to Base64 before sending the request [5]. See the method callCloudVision, inside there is an AsyncTask that retrieves an image and converts it to Base64 before sending the request.
[1] https://cloud.google.com/vision/docs/quickstart
[2] https://cloud.google.com/vision/docs/languages
[3] https://console.cloud.google.com/apis/credentials?project=your-project-id
[4] https://github.com/GoogleCloudPlatform/cloud-vision/tree/master/android
[5] https://github.com/GoogleCloudPlatform/cloud-vision/blob/master/android/CloudVision/app/src/main/java/com/google/sample/cloudvision/MainActivity.java#L192
Using the Graph API I request /me?fields=videos.type(uploaded).fields(id, embed_html). This gives me a list of my uploaded videos:
{
"id": "[...snip...]",
"videos": {
"data": [
{
"id": "10151488520332264",
"embed_html": "<iframe src=\"https://graph.facebook.com/video/embed?video_id=10151488520332264\" width=\"190\" height=\"240\" frameborder=\"0\"></iframe>",
"updated_time": "2013-02-28T11:09:14+0000"
},
[...snip...]
]
}
}
I expect embed_html to be html code that embeds the video. But when I use it, the iframe shows only a graph error:
{
"error": {
"message": "Unknown path components: /embed",
"type": "OAuthException",
"code": 2500
}
}
The video is public and I get the same error also in the graph explorer when requesting it with an access token that has permissions for user_videos.
The video object also has a source property which links directly to the source video file (no player). I could use that and build my own player, but I'd prefer to use the embed code that facebook thinks is best for the video (and browser).
I'm getting my page wall with the open graph.
And when someone posted a photo, I get it on the JSON
{
"id": "27888702146_10150369820322147",
"from": {
"name": "brocoli",
"category": "Record label",
"id": "27888702146"
},
"message": "Vincent Epplay / David Fenech / Jac Berrocal \u00e0 Beaubourg ce soir, 19h, gratos.",
"picture": "http://photos-f.ak.fbcdn.net/hphotos-ak-snc7/305819_10150369820292147_27888702146_8255527_583491475_s.jpg",
"link": "https://www.facebook.com/photo.php?fbid=10150369820292147&set=a.386279807146.165840.27888702146&type=1",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"type": "photo",
"object_id": "10150369820292147",
"created_time": "2011-10-16T08:22:21+0000",
"updated_time": "2011-10-16T08:22:21+0000",
"likes": {
"data": [
{
"name": "brocoli",
"category": "Record label",
"id": "27888702146"
},
{
"name": "Agathe Morier",
"id": "601668526"
}
],
"count": 2
},
"comments": {
"count": 0
},
"is_published": true
}
The problem is that the picture link is a low resolution copy of the picture.
How can I get the URL of the full picture ?
Thanks!!
Best
Geoffroy
You can get different version of the photo by querying Graph API with its object_id (not photo post_id which is id in results you provided).
Once you'll request the photo by object id you'll get array of images with URLs and dimensions:
http://graph.facebook.com/10150369820292147?fields=images
If you're attempting to access posts on a Facebook Page (such as for a company) instead of typical user profile, you firstly need to fetch the feed like this:
https://graph.facebook.com/v15.0/YOUR_PAGE_ID_HERE/feed?fields=attachments&access_token=...
And then access data[0].attachments.data[0].subattachments.data[0].target.id to get the object ID (or "target ID" in this case) which you can then use to perform an additional query to obtain the higher resolution image. Increment the numbers to get additional posts and images inside each post.
All you need to do is :
http://graph.facebook.com/me?fields=picture.height(961)
// replace 961 with your required height which u want
You can do this from the main posts list now using
/v2.3/105753476132681/posts?limit=5&fields=likes.summary(true),comments.summary(true), attachments
If attachments doesn't work, try full_picture - but that just gave the 100x100 image for me as well.
Attachments returns a data hash with a 640x480 version of the image at least (not sure what my orig. photo size was)
Use this Code. Its Work for me and get Clear Image
String PICTURE_URL;
String getPicture = hashMap.get("picture");
if (getPicture.contains("_t.")) {
PICTURE_URL = getPicture.replaceAll("_t.", "_n.");
} else if (getPicture.contains("_a.")) {
PICTURE_URL = getPicture.replaceAll("_a.", "_n.");
} else if (getPicture.contains("_s.")) {
PICTURE_URL = getPicture.replaceAll("_s.", "_n.");
} else if (getPicture.contains("_q.")) {
PICTURE_URL = getPicture.replaceAll("_q.", "_n.");
}
url=new URL(PICTURE_URL);
Bitmap bitmap=BitmapFactory.decodeStream(url.openConnection().getInputStream());
((ImageView)view.findViewById(R.id.imageView_FullImage)).setImageBitmap(bitmap);
Though requesting a photo by its object_id will return an array of images with different dimensions, in some cases this approach would require an additional call to the Facebook API.
A simpler approach is to add full_picture to your list of parameters, which will extract the highest resolution image associated with the post.
/v2.2/6275848869/posts?fields=full_picture
For example, if you want to extract all the posts from a Facebook page in the past X days, with the object_id approach you'd need to call the API 3 times:
To get the page info.
To extract the list of posts and obtain the object_id for each post.
For each object_id, to retrieve the list of higher resolution images.