我需要將視頻流從MJPEG轉碼爲MP4,AVI或MKV格式。是否可以使用ffmpeg或vlc?我正在開發UWP Win10應用程序,並沒有太多的軟件包。在UWP中轉碼視頻
編輯:我的代碼
VLCPreview.Source = "http://Admin:[email protected]:6021/cgi-bin/cmd/encoder?GET_STREAM";
/cmd/encoder?GET_STREAM
try
{
HttpClientHandler aHandler = new HttpClientHandler();
aHandler.Credentials = new NetworkCredential("Admin", "123456");
aHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;
HttpClient aClient = new HttpClient(aHandler);
aClient.DefaultRequestHeaders.ExpectContinue = false;
//url get stream o web.Source
HttpResponseMessage response = await aClient.GetAsync("http://192.168.0.21:6021/cgi-bin/cmd/encoder?GET_STREAM", HttpCompletionOption.ResponseHeadersRead);//urlLinkToOnlineStream
Stream stream = await response.Content.ReadAsStreamAsync();
IInputStream inputStream = stream.AsInputStream();
ulong totalBytesRead = 0;
while (true)
{
// Read from the web.
IBuffer buffer = new Windows.Storage.Streams.Buffer(4096);
buffer = await inputStream.ReadAsync(buffer, buffer.Capacity, InputStreamOptions.None);
if (buffer.Length == 0)
{
break;
}
totalBytesRead += buffer.Length;
await fileStream.WriteAsync(buffer);
Debug.WriteLine("TotalBytesRead: {0:f}", totalBytesRead);
if (StopRec == true) { break;}
}
transcode(destinationFile, sampleFileVidTranscoded);
inputStream.Dispose();
fileStream.Dispose();
您確定可以使用ffmpeg,但您也應該嘗試更好地編寫您的問題。 –