private Task ConvertStream(HttpContent httpContent, Stream outputStream) { Task convertTask = new Task(() => { var convertSettings = new ConvertSettings { CustomOutputArgs = "-map 0", CustomInputArgs = "-vcodec h264" }; var ffMpeg = new FFMpegConverter(); ffMpeg.ConvertProgress += FfMpeg_ConvertProgress; ffMpeg.LogReceived += FfMpeg_LogReceived; //var task = ffMpeg.ConvertLiveMedia(Format.h264, "C:\\Work\\Test\\converted.avi", Format.avi, convertSettings); var task = ffMpeg.ConvertLiveMedia(Format.h264, outputStream, Format.mpeg, convertSettings); task.Start(); var ffmpegStream = new FFMPegStream(task); var copyTask = httpContent.CopyToAsync(ffmpegStream); copyTask.Wait(); ffmpegStream.Close(); task.Wait(); // ffMpeg.ConvertMedia(@"C:\Work\Test\MyHomeSecureNode\devices\test\video.h264", "C:\\Work\\Test\\converted.avi", Format.avi); outputStream.Close(); }); convertTask.Start(); return convertTask; }
private Task ConvertStream(/*Stream input, */ Stream outputStream) { Task convertTask = new Task(() => { try { var convertSettings = new ConvertSettings { CustomOutputArgs = "-map 0", CustomInputArgs = "-vcodec h264" }; //convertSettings.SetVideoFrameSize(360, 360); var ffMpeg = new FFMpegConverter(); ffMpeg.ConvertProgress += FfMpeg_ConvertProgress; ffMpeg.LogReceived += FfMpeg_LogReceived; //task = ffMpeg.ConvertLiveMedia(Format.h264, outStream, Format.mjpeg, convertSettings); //task = ffMpeg.ConvertLiveMedia(inStream, Format.h264, outStream, Format.mjpeg, convertSettings); // task = ffMpeg.ConvertLiveMedia(inStream, Format.h264, $@"Files\video2.mpeg", Format.mjpeg, convertSettings); // task.Start(); //ffMpeg.ConvertMedia($@"Files\video.mpeg4", Format.h264, $@"Files\video3.mpeg", Format.mjpeg, convertSettings); //var task = ffMpeg.ConvertLiveMedia(Format.h264, "C:\\Work\\Test\\converted.avi", Format.avi, convertSettings); //ffMpeg.ConvertMedia($@"Files\video.mpeg4", $@"Files\video2.flv", Format.flv); //var setting = new NReco.VideoConverter.ConvertSettings(); //setting.SetVideoFrameSize(360, 360); //setting.VideoCodec = "h264"; //ffMpeg.ConvertMedia($@"Files\video.mpeg4", Format.h264, $@"Files\video2.mjpeg", Format.mjpeg, setting); //task.Stop(); var task = ffMpeg.ConvertLiveMedia(Format.h264, outputStream, Format.mjpeg, convertSettings); task.Start(); ffinStream = new FFMPegStream(task); //var copyTask = input.CopyToAsync(ffmpegStream); //copyTask.Wait(); //ffmpegStream.Close(); task.Wait(); //ffMpeg.ConvertMedia(@"C:\Work\Test\MyHomeSecureNode\devices\test\video.h264", "C:\\Work\\Test\\converted.avi", Format.avi); outputStream.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }); convertTask.Start(); return(convertTask); }