AWS Elemental Media Converter How To Create Job Thumbnail using .Net C# - I am unable to create the Aws Elemental Media Converter Job using .Net C#. facing the output group exception. I have tried with preset defined facing the same issue using the code and preset...
createJobRequest.Role = mediaConvertRole;
createJobRequest.Queue = jobQueue;
createJobRequest.UserMetadata.Add("Customer", "Amazon");
#region Create job settings
Amazon.MediaConvert.Model.JobSettings jobSettings = new Amazon.MediaConvert.Model.JobSettings();
jobSettings.AdAvailOffset = 0;
jobSettings.TimecodeConfig = new Amazon.MediaConvert.Model.TimecodeConfig();
jobSettings.TimecodeConfig.Source = Amazon.MediaConvert.TimecodeSource.EMBEDDED;
createJobRequest.Settings = jobSettings;
#region Thumbnail
Amazon.MediaConvert.Model.OutputGroup ofgT = new Amazon.MediaConvert.Model.OutputGroup();
ofgT.Name = "Thumbnail";
ofgT.OutputGroupSettings = new Amazon.MediaConvert.Model.OutputGroupSettings();
ofgT.OutputGroupSettings.Type = Amazon.MediaConvert.OutputGroupType.FILE_GROUP_SETTINGS;
ofgT.OutputGroupSettings.FileGroupSettings = new Amazon.MediaConvert.Model.FileGroupSettings();
ofgT.OutputGroupSettings.FileGroupSettings.Destination = fileOutput;
Amazon.MediaConvert.Model.Output outputT = new Amazon.MediaConvert.Model.Output();
outputT.NameModifier = "_thumb_00001";
outputT.Extension = "png";
output.Preset = preset_thumbnail;
#region Mp4 Container
outputT.ContainerSettings = new Amazon.MediaConvert.Model.ContainerSettings();
outputT.ContainerSettings.Container = Amazon.MediaConvert.ContainerType.MP4;
Amazon.MediaConvert.Model.Mp4Settings mp4T = new Amazon.MediaConvert.Model.Mp4Settings();
mp4T.CslgAtom = Amazon.MediaConvert.Mp4CslgAtom.INCLUDE;
mp4T.FreeSpaceBox = Amazon.MediaConvert.Mp4FreeSpaceBox.EXCLUDE;
mp4T.MoovPlacement = Amazon.MediaConvert.Mp4MoovPlacement.PROGRESSIVE_DOWNLOAD;
outputT.ContainerSettings.Mp4Settings = mp4T;
#endregion Mp4 Container
ofgT.Outputs.Add(outputT);
createJobRequest.Settings.OutputGroups.Add(ofgT);
#endregion Thumbnail
#region Input
Amazon.MediaConvert.Model.Input input = new Amazon.MediaConvert.Model.Input();
input.FilterEnable = Amazon.MediaConvert.InputFilterEnable.AUTO;
input.PsiControl = Amazon.MediaConvert.InputPsiControl.USE_PSI;
input.FilterStrength = 0;
input.DeblockFilter = Amazon.MediaConvert.InputDeblockFilter.DISABLED;
input.DenoiseFilter = Amazon.MediaConvert.InputDenoiseFilter.DISABLED;
input.TimecodeSource = Amazon.MediaConvert.InputTimecodeSource.EMBEDDED;
input.FileInput = fileInput;
Amazon.MediaConvert.Model.AudioSelector audsel = new Amazon.MediaConvert.Model.AudioSelector();
audsel.Offset = 0;
audsel.DefaultSelection = Amazon.MediaConvert.AudioDefaultSelection.NOT_DEFAULT;
audsel.ProgramSelection = 1;
input.AudioSelectors.Add("Audio Selector 1", audsel);
input.VideoSelector = new Amazon.MediaConvert.Model.VideoSelector();
input.VideoSelector.ColorSpace = Amazon.MediaConvert.ColorSpace.FOLLOW;
createJobRequest.Settings.Inputs.Add(input);
#endregion Input
Amazon.MediaConvert.Model.CreateJobResponse createJobResponse = mcClient.CreateJob(createJobRequest);
string jobId = createJobResponse.Job.Id;
AWS Elemental Media Converter How To Create Job Thumbnail using .Net C#
This Code solve my problem to generate the thumbnail using Aws elemental media converter. Passing the outoup object with these parameters:
Amazon.MediaConvert.Model.Output outputThumb = new Amazon.MediaConvert.Model.Output();
outputThumb.ContainerSettings = new Amazon.MediaConvert.Model.ContainerSettings { Container = Amazon.MediaConvert.ContainerType.RAW };
outputThumb.NameModifier = "_thumbnail";
outputThumb.Extension = "png";
outputThumb.VideoDescription = new Amazon.MediaConvert.Model.VideoDescription();
outputThumb.VideoDescription.CodecSettings = new Amazon.MediaConvert.Model.VideoCodecSettings();
outputThumb.VideoDescription.CodecSettings.Codec = "FRAME_CAPTURE";
outputThumb.VideoDescription.CodecSettings.FrameCaptureSettings = new Amazon.MediaConvert.Model.FrameCaptureSettings {
MaxCaptures = 1,
Quality = 100
};
ofg.Outputs.Add(outputThumb);
Related
I'm trying to download a MapProvider to use offline map but i dont know how to download.
it works when i use ServerOnly.
This is my code:
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
_map = new GMapControl();
Map.MapProvider = GMap.NET.MapProviders.BingHybridMapProvider.Instance;
Map.DragButton = MouseButton.Left;
Map.MinZoom = 2;
Map.MaxZoom = 18;
Map.Zoom = 5;
Map.CanDragMap = true;
Map.Position = new GMap.NET.PointLatLng(48.8589507, 2.2775175);
Map.ShowCenter = false;
Thank you everyone
You can cache the map in the local storage using the ServerAndCache found in GMap.NET.AccessMode
The following function will do the work:
private void gMapStoreOffline(int lat, int lng)
{
gMapControl1.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
GMap.NET.MapProviders.OpenStreetMapProvider.UserAgent = "IE";
gMapControl1.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance;
GMaps.Instance.OptimizeMapDb(null);
// Define the location to cache the file
gMapControl1.CacheLocation = #"C:\Users\<username>\..";
gMapControl1.Zoom = 14;
gMapControl1.Size = new Size(this.Width, this.Height);
gMapControl1.ShowCenter = false;
gMapControl1.Position = new GMap.NET.PointLatLng(lat, lng)
}
I'm trying to generate a checkbox from C#.net using google sheets API but I'm encountering the oneof field kind is already set error. I tried combining extendedValue and DataValidation. Please see code snippet below:
ConditionValue conditionValueTrue = new ConditionValue();
conditionValueTrue.UserEnteredValue = "TRUE";
ConditionValue conditionValueFalse = new ConditionValue();
conditionValueFalse.UserEnteredValue = "FALSE";
ConditionValue[] validValues = { conditionValueTrue, conditionValueFalse };
BooleanCondition bc = new BooleanCondition();
bc.Type = "BOOLEAN";
bc.Values = validValues;
DataValidationRule dataValidationRule = new DataValidationRule();
dataValidationRule.Condition = bc;
dataValidationRule.ShowCustomUi = true;
GridRange validationRange = new GridRange();
validationRange.StartColumnIndex = 7;
validationRange.EndColumnIndex = 7;
validationRange.SheetId = 0;
SetDataValidationRequest setDataValidationRequest = new SetDataValidationRequest();
setDataValidationRequest.Rule = dataValidationRule;
setDataValidationRequest.Range = validationRange;
ExtendedValue extendedValue = new ExtendedValue();
extendedValue.BoolValue = true;
BatchUpdateSpreadsheetRequest busr = new BatchUpdateSpreadsheetRequest();
busr.Requests = new List<Request>();
Request r = new Request();
busr.Requests.Add(r);
r.UpdateCells = new UpdateCellsRequest();
r.SetDataValidation = setDataValidationRequest;
var gc = new GridCoordinate();
gc.ColumnIndex = 7;
gc.RowIndex = row;
gc.SheetId = 0;
r.UpdateCells.Start = gc;
r.UpdateCells.Fields = "*";
r.UpdateCells.Rows = new List<RowData>();
var rd = new RowData();
r.UpdateCells.Rows.Add(rd);
rd.Values = new List<CellData>();
var cd = new CellData();
cd.UserEnteredValue = extendedValue;
rd.Values.Add(cd);
SpreadsheetsResource.BatchUpdateRequest bur = _sheetsService.Spreadsheets.BatchUpdate(busr, SpreadsheetId);
bur.Execute();
I have an Amazon EC2 instance and I need to be able to create an AMI (image) from it programmatically. I'm trying the following:
CreateImageRequest rq = new CreateImageRequest();
rq.InstanceId = myInstanceID;
rq.Name = instance.KeyName;
rq.Description = "stam";
rq.NoReboot = true;
IAmazonEC2 ec2;
AmazonEC2Config ec2conf = new AmazonEC2Config();
ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2conf);
// CreateImageResponse imageResp;
Amazon.EC2.Model.CreateImageResponse imageResp = null;
try
{
imageResp = ec2.CreateImage(rq);
}
catch (AmazonServiceException ase)
{
MessageBox.Show(ase.Message);
}
The result is always an AmazonServiceException saying that there is a NameResolutionFailure.
How do I overcome this? I tried different possible "name" possibilities but cannot find the right one.
string amiID = ConfigurationManager.AppSettings[AmazonConstants.AwsImageId];
string keyPairName = ConfigurationManager.AppSettings[AmazonConstants.AwsKeyPair];
List<string> groups = new List<string>() { ConfigurationManager.AppSettings[AmazonConstants.AwsSecurityGroupId] };
var launchRequest = new RunInstancesRequest()
{
ImageId = amiID,
InstanceType = ConfigurationManager.AppSettings[AmazonConstants.AwsInstanceType],
MinCount = 1,
MaxCount = 1,
KeyName = keyPairName,
SecurityGroupIds = groups,
SubnetId = ConfigurationManager.AppSettings[AmazonConstants.AwsSubnetId]
};
RunInstancesResponse runInstancesResponse = amazonEc2client.RunInstances(launchRequest);
RunInstancesResult runInstancesResult = runInstancesResponse.RunInstancesResult;
Reservation reservation = runInstancesResult.Reservation;
Problem eventually solved!
it turned out thyat some codelines were doing things which were already done already and removing this part:
IAmazonEC2 ec2;
AmazonEC2Config ec2conf = new AmazonEC2Config();
ec2 = AWSClientFactory.CreateAmazonEC2Client(ec2conf);
// CreateImageResponse imageResp;
Amazon.EC2.Model.CreateImageResponse imageResp = null;
Made things clearer and no wrong repetitions happened! Now it works!
I was wondering if there was a way to crop videos in Xamarin. I can't seem to find any examples. I tried looking at the existing functions and Classes but I couldn't find anything.
Basically make square videos like what Vine and Instagram have. I think this is done by cropping out the rest of the video and not just zooming in.
I find part of the code from one source, I tried to add owner but I could not find. The solution's key part is added by me for cropping which is "VideoCleanAperture" inside AVVideoSettingsCompressed.
videoUrl = ((AVFoundation.AVUrlAsset)avAsset).Url;
NSError assetReaderError;
var assetReader = AVAssetReader.FromAsset(avAsset, out assetReaderError);
var assetTrack = avAsset.Tracks.First();
//Height = (System.nint?)avAsset.NaturalSize.Height,
//Width = (System.nint?)avAsset.NaturalSize.Width,
var inputSettings = new AVVideoSettingsUncompressed()
{
Height = (System.nint?)avAsset.NaturalSize.Height,
Width = (System.nint?)avAsset.NaturalSize.Width,
};
var assetReaderOutput = new AVAssetReaderTrackOutput(assetTrack, settings: inputSettings);
assetReaderOutput.AlwaysCopiesSampleData = false;
string tempFile = Path.Combine(Path.GetTempPath(), "CroppedVideo.mp4");
if (File.Exists(tempFile)) File.Delete(tempFile);
var url = NSUrl.FromFilename(tempFile);
NSError assetWriterError;
var assetWriter = new AVAssetWriter(url, AVFileType.Mpeg4, out assetWriterError);
var outputSettings = new AVVideoSettingsCompressed()
{
Height = 300,
Width = 300,
Codec = AVVideoCodec.H264,
CodecSettings = new AVVideoCodecSettings()
{
AverageBitRate = 1000000,
VideoCleanAperture = new AVVideoCleanApertureSettings(
new NSDictionary(
AVVideo.CleanApertureWidthKey, new NSNumber(300),
AVVideo.CleanApertureHeightKey, new NSNumber(300),
AVVideo.CleanApertureVerticalOffsetKey, new NSNumber(10),
AVVideo.CleanApertureHorizontalOffsetKey, new NSNumber(10)
)
)
},
ScalingMode = AVVideoScalingMode.ResizeAspectFill
};
var assetWriterInput = new AVAssetWriterInput(mediaType: AVMediaType.Video, outputSettings: outputSettings);
assetWriterInput.ExpectsMediaDataInRealTime = false;
assetWriter.AddInput(assetWriterInput);
assetWriter.StartWriting();
assetReader.AddOutput(assetReaderOutput);
assetReader.StartReading();
assetWriter.StartSessionAtSourceTime(CoreMedia.CMTime.Zero);
var mediaInputQueue = new DispatchQueue("mediaInputQueue");
assetWriterInput.RequestMediaData(mediaInputQueue, () =>
{
while (assetWriterInput.ReadyForMoreMediaData)
{
var nextBuffer = assetReaderOutput.CopyNextSampleBuffer();
if (nextBuffer != null)
{
assetWriterInput.AppendSampleBuffer(nextBuffer);
}
else
{
assetWriterInput.MarkAsFinished();
assetWriter.FinishWritingAsync();
assetReader.CancelReading();
assetReader.Dispose();
assetReaderOutput.Dispose();
assetWriter.Dispose();
assetWriterInput.Dispose();
break;
}
}
});
}
I have been trying to bring back 20 results of images using the Bing API. Here's the code:
SearchRequest request = new SearchRequest();
request.AppId = APPID;
request.Query = HttpUtility.HtmlEncode(searchQuery);
request.Sources = new SourceType[] { SourceType.Image };
request.Image = new ImageRequest();
request.Image.Count = 20;
request.Image.Filters = new string[1] { "Size:Medium" };
Now everything on here works, including the Image.Filters property. Just not the Count property. Is there a known bug or am I just missing something here?
I'm not sure really sure about this but I think you are missing setting CountSpecified property. Try this
request.Image = new ImageRequest();
request.Image.Offset = 0;
request.Image.Count = 20;
request.Image.CountSpecified = true;
request.Image.Filters = new string[1] { "Size:Medium" };