Comments (4)
I would like to achive the same thing, any clues ?
from mediatoolkit.
Any update on this?
from mediatoolkit.
I am looking for the similar implementation by passing presigned url of an object stored on S3. Any update on this?
from mediatoolkit.
MediaFile would have to internally download the mp4 file in order to process it with FFMpeg executable..
Why don't you write a separate download method and use MediaFile constructor afterwards?
Here is some code to help you download a file from S3:
private void InitializeAmazonClients()
{
_credentialsValid = TryGetAwsCredentials(out _awsCredentials);
if (!_credentialsValid)
throw new Exception("Not able to find aws credentials.");
if (_transcribeClient == null)
_transcribeClient = new AmazonTranscribeServiceClient(_awsCredentials, Amazon.RegionEndpoint.EUWest2);
if (_s3Client == null)
_s3Client = new AmazonS3Client(_awsCredentials, Amazon.RegionEndpoint.EUWest2);
if (_translateClient == null)
_translateClient = new AmazonTranslateClient(_awsCredentials, Amazon.RegionEndpoint.EUWest1);
if (_pollyClient == null)
_pollyClient = new AmazonPollyClient(_awsCredentials, Amazon.RegionEndpoint.EUWest1);
}
private bool TryGetAwsCredentials(out AWSCredentials awsCredentials)
{
CreateSettingsStoreFolderIfNotExists();
var chain = new CredentialProfileStoreChain();
if (!chain.TryGetAWSCredentials(_settings.CredentialProfile, out awsCredentials))
{
CreateAwsCredentials();
if (!chain.TryGetAWSCredentials(_settings.CredentialProfile, out awsCredentials))
{
return false;
}
}
return true;
}
private void CreateAwsCredentials()
{
var options = new CredentialProfileOptions
{
AccessKey = _settings.AccessKey,
SecretKey = _settings.SecretKey
};
var profile = new CredentialProfile(_settings.CredentialProfile, options);
profile.Region = RegionEndpoint.USWest1;
var sharedFile = new SharedCredentialsFile();
sharedFile.RegisterProfile(profile);
}
private static void CreateSettingsStoreFolderIfNotExists()
{
string settingsStoreFolder = "";
#if BCL
settingsStoreFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AWSToolkit");
#else
settingsStoreFolder = Environment.GetEnvironmentVariable("HOME");
if (string.IsNullOrEmpty(settingsStoreFolder))
settingsStoreFolder = Environment.GetEnvironmentVariable("USERPROFILE");
settingsStoreFolder = Path.Combine(settingsStoreFolder, "AppData", "Local", "AWSToolkit");
#endif
if (!Directory.Exists(settingsStoreFolder))
Directory.CreateDirectory(settingsStoreFolder);
}
public bool DownloadFileFromS3(string filePath, string bucketName, string objectName)
{
try
{
var fileTransferUtility = new TransferUtility(_s3Client);
fileTransferUtility.DownloadAsync(filePath, bucketName, objectName).Wait();
return true;
}
catch (AmazonS3Exception e)
{
_logger.LogError($"Error encountered on server. Message:'{0}' when writing an object", e.Message);
}
catch (Exception e)
{
_logger.LogError($"Unknown encountered on server. Message:'{0}' when writing an object", e.Message);
}
return false;
}
public string UploadFileToS3(string filePath, string bucketName, string objectName = null)
{
try
{
var fileTransferUtility = new TransferUtility(_s3Client);
string s3ObjectName = objectName ?? Path.GetFileName(filePath);
var fileTransferUtilityRequest = new TransferUtilityUploadRequest
{
BucketName = bucketName,
FilePath = filePath,
StorageClass = S3StorageClass.StandardInfrequentAccess,
PartSize = 6291456, // 6 MB.
Key = s3ObjectName,
CannedACL = S3CannedACL.PublicRead
};
fileTransferUtility.UploadAsync(fileTransferUtilityRequest).Wait();
return s3ObjectName;
}
catch (AmazonS3Exception e)
{
_logger.LogError($"Error encountered on server. Message:'{0}' when writing an object", e.Message);
}
catch (Exception e)
{
_logger.LogError($"Unknown encountered on server. Message:'{0}' when writing an object", e.Message);
}
return null;
}
from mediatoolkit.
Related Issues (20)
- FrameRate Does not change
- Fix for MetaVideo regex HOT 1
- Drawing Text?
- Hold Output Image In Memory Instead of Saving to File Path Automatically
- Not found file
- Update Nuget package HOT 3
- How to use events when using CustomCommand ? HOT 1
- How to get the result of custom commands ?
- Output file not saved in the specified directory path in the asp.net core with docker
- Where to set FFMpeg path? HOT 1
- .NET 5 Update HOT 1
- Permission denied to create C:\MediaToolkit folder HOT 1
- some media can't convert , but no return value
- Error: "The system cannot find the file specified" with Unity HOT 1
- Use in Unity project HOT 1
- Is ther a know issue with Windows 11 ?
- Incorrect licensing info in readme?
- ExtensionAttribute hatası.
- RobiniaDocs API Explorer
- No Errors but Trimming video just makes it be 1kb.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mediatoolkit.