私のプログラムはMP4ファイルをブロブにアップロードしてから10秒間トリミングし、ブロブに再アップロードします。私は現在、VSのAzureエミュレータを使って実行しているときにこれを動作させていますが、クラウドにデプロイすると出力ファイルのサイズは0バイトになります。Azureにデプロイされたときにファイルがストリームにコピーされず、VSエミュレータを使用しています
トリマー:
public static void Trimmer(string localStoragePath, Stream output)
{
string path2= localStoragePath.Remove(localStoragePath.Length-4)+ "_trimmed.mp4";
string ffmpeg = "ffmpeg.exe";
bool success = false;
string ExeArguments;
try
{
Process proc;
proc = new Process();
proc.StartInfo.FileName = ffmpeg;
ExeArguments = @" -t 10 -i " + localStoragePath + " -map_metadata 0 -acodec copy "
+ path2 + " -y";
//ExeArguments = @"–t 10 -i -acodec" + localStoragePath + path2 ;
Trace.TraceInformation(ExeArguments);
proc.StartInfo.Arguments = ExeArguments;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.ErrorDialog = false;
proc.Start();
proc.WaitForExit();
success = true;
}
catch { }
Trace.TraceInformation(string.Format("Video has been trimmed"));
using (Stream file = File.OpenRead(path2))
{
Trace.TraceInformation(string.Format("Video moving to CopyStream"));
copyStream(file, output);
}
}
コピーストリーム:
public static void copyStream(Stream input, Stream output)
{
Trace.TraceInformation(string.Format("Video has been trimmed and now sent to be copied to stream"));
byte[] buffer = new byte[8 * 1024];
int len;
while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, len);
}
}
ブロブムーバー:
public static void fileMover (CloudBlob mover, string filePath, Stream input, Stream output)
{
string localStoragePath;
//start string from 7th letter, eg, images
string link = filePath.Substring(7);
LocalResource locRes;
locRes = RoleEnvironment.GetLocalResource("WorkerRoleLocalStorage");
//To determine the path to the local storage resource's directory
localStoragePath = string.Format(locRes.RootPath);
//Moving file to local storage
try
{
mover.DownloadToFile(localStoragePath + link, FileMode.OpenOrCreate);
Trace.TraceInformation("file mover has been called " + localStoragePath + link);
//add meta data
}
catch(Exception e) { }
try
{
Trimmer(localStoragePath + link, output);
}
catch(Exception e) {}
}
ありがとうございました。
読み書きのためにBLOBを開く部分を追加できますか? – juunas
@juunasメインポストに追加されました。 – user3107448
空のキャッチブロックにいくつかのログを追加することをお勧めします。発生する可能性のある例外から役立つ情報を捨ててしまいます。 – stuartd