我们有一个Quartz调度程序,它每60秒扫描一次公司的电子邮件帐户,并将相应地处理这些电子邮件。任何附件都存储在字节数组中。
视频附件需要转换为MP4,然后再转换为字节数组以存储在数据库中;我正在尝试使用FFMPEG(fflib)来完成此操作,但是我在弄清楚如何使用字节数组作为源来完成它时遇到了麻烦-该公司表示必须在进入数据库之前完成此转换。
使用Process Class访问FFMPEG CLI是否可以转换字节数组?
这是我当前拥有的代码,仅使用本地文件位置(使用fflib ffmpeg库)。
public IList<DocumentStoreAttachment> AddDocumentsToDocumentStore(IList<FileAttachment> documentsToStore, Guid personId, IList<DocumentAttributeDto> documentAttributes)
{
var storedDocuments = new List<DocumentStoreAttachment>();
foreach (var documentToStore in documentsToStore)
{
try
{
if (IsExtensionAllowed(documentToStore.AttachmentName))
{
if (documentToStore.MimeType == "mpeg")
{
Job2Convert job = new Job2Convert()
{
pszSrcFile = @"..\..\Amigo Loans 2018 Advert MPG.mpg",
pszDstFile = @"C:\Users\ben.hayward\Desktop\Amigo Loans 2018 Advert MPG.mp4",
pszDstFormat = "mp4",
pszAudioCodec = "aac",
nAudioChannels = 2,
nAudioBitrate = -1,
nAudioRate = -1,
pszVideoCodec = "h264",
nVideoBitrate = -1,
nVideoFrameRate = -1,
nVideoFrameWidth = -1,
nVideoFrameHeight = -1
};
_sut.ConvertFile(job);
}
storedDocuments.Add(AddDocumentToDocumentStore(documentToStore.AttachmentName, documentToStore.ByteArray, documentToStore.MimeType, personId, documentAttributes));
}
else
{
Logger.WarnFormat("AddDocumentsToDocumentStore: File extension not allowed for file name: {0}, person id: {1}", documentToStore.AttachmentName, personId);
}
}
catch (Exception e)
{
#region Error
Logger.Error(String.Format("There was a problem saving the document to the document store. The file name was {0}, person id: {1}",
documentToStore.AttachmentName, personId), e);
#endregion
}
}
return storedDocuments;
}
谢谢。