public async Task <string> PrependIntroAsync(CloudBlockBlob outputBlob, string introLocation, string incomingFile, ILogger log) { var localIntro = ""; var localIncoming = ""; var localConcat = ""; try { localIntro = await Utils.DownloadToLocalFileAsync(introLocation); localIncoming = await Utils.DownloadToLocalFileAsync(incomingFile); localConcat = Utils.CreateLocalConcat(localIntro, localIncoming); var transcodeParams = new TranscodeParams { OutputExtension = ".mp4", InputFile = incomingFile, FfmpegParams = $"-f concat -safe 0 -i \"{localConcat}\" -codec copy " //InputFile = $"concat:{introLocation}|{incomingFile}", // doesn't work with Uris //FfmpegParams = "-codec copy" //InputFile = introLocation, //FfmpegParams = $"-i \"{incomingFile}\" -filter_complex \"[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]\" -map \"[v]\" -map \"[a]\"" }; return(await Utils.TranscodeAndUpload(transcodeParams, outputBlob, log)); } finally { Utils.TryDeleteFiles(log, localIntro, localIncoming, localConcat); } }
public async Task <string> ExtractThumbnailAsync(string incomingFile, CloudBlockBlob outputBlob, ILogger log) { var transcodeParams = new TranscodeParams { OutputExtension = ".png", InputFile = incomingFile, FfmpegParams = "-vf \"thumbnail,scale=640:360\" -frames:v 1" }; return(await Utils.TranscodeAndUpload(transcodeParams, outputBlob, log)); }
public static async Task <string> TranscodeVideo( [ActivityTrigger] TranscodeParams transcodeParams, [Blob("processed/transcoded")] CloudBlobDirectory dir, TraceWriter log) { var outputBlobName = Path.GetFileNameWithoutExtension(transcodeParams.InputFile) + transcodeParams.OutputExtension; log.Info($"Transcoding {transcodeParams.InputFile} with params " + $"{transcodeParams.FfmpegParams} with extension {transcodeParams.OutputExtension}"); var outputBlob = dir.GetBlockBlobReference(outputBlobName); return(await videoProcessor.TranscodeAsync(transcodeParams, outputBlob, log)); }
public static async Task <string> TranscodeAndUpload(TranscodeParams transcodeParams, ICloudBlob outputBlob, ILogger log) { var outputFilePath = Path.Combine(GetTempTranscodeFolder(), $"{Guid.NewGuid()}{transcodeParams.OutputExtension}"); try { await FfmpegWrapper.Transcode(transcodeParams.InputFile, transcodeParams.FfmpegParams, outputFilePath, log); await outputBlob.UploadFromFileAsync(outputFilePath); } finally { TryDeleteFiles(log, outputFilePath); } return(GetReadSas(outputBlob, TimeSpan.FromHours(2))); }
public async Task <string> TranscodeAsync(TranscodeParams transcodeParams, ICloudBlob outputBlob, TraceWriter log) { await Task.Delay(5000); // simulate some work return($"{Path.GetFileNameWithoutExtension(transcodeParams.InputFile)}{Guid.NewGuid():N}{transcodeParams.OutputExtension}"); }
public async Task <string> TranscodeAsync(TranscodeParams transcodeParams, ICloudBlob outputBlob, ILogger log) { return(await Utils.TranscodeAndUpload(transcodeParams, outputBlob, log)); }