UWP C++/CXプロジェクトでは、MediaCapture Camera Streamのすべてのフレームからスクリーンショットを取得し、そのストリームを最後にビデオとして保存しようとしています。私のアプローチ:機能があることを私は知っている:最初の質問についてはUWP C++プロジェクトでストリームレコードからフレームを抽出する方法は?
/// <summary>
/// Records an MP4 video to a StorageFile and adds rotation metadata to it
/// </summary>
/// <returns></returns>
task<void> CameraControl::StartRecordingAsyncStream()
{
//InMemoryRandomAccessStream^ video_stream;
// Calculate rotation angle, taking mirroring into account if necessary
auto rotationAngle = CameraRotationHelper::ConvertSimpleOrientationToClockwiseDegrees(_rotationHelper->GetCameraCaptureOrientation());
auto encodingProfile = MediaProperties::MediaEncodingProfile::CreateMp4(MediaProperties::VideoEncodingQuality::Auto);
encodingProfile->Video->Properties->Insert(RotationKey, rotationAngle);
return create_task(_mediaCapture->StartRecordToStreamAsync(encodingProfile, this->video_stream))
.then([this]()
{
_isRecording = true;
WriteLine("Started recording");
}).then([this](task<void> previousTask)
{
try
{
previousTask.get();
}
catch (Exception^ ex)
{
// File I/O errors are reported as exceptions
WriteLine(ex->Message);
}
});
}
/// <summary>
/// Stops recording a video
/// </summary>
/// <returns></returns>
task<void> CameraControl::StopRecordingAsyncStream()
{
_isRecording = false;
WriteLine("Stopping recording...");
return create_task(_mediaCapture->StopRecordAsync())
.then([this]()
{
WriteLine("Stopped recording!");
});
}
//Loads all frames as images from the stream
void CameraControl::LoadVideoStream(void) {
//TODO: Read all Frames as Thumbnails from "this->video_stream" and store them as Bitmaps, for example in a vector
}
/// <summary>
/// Stores the recorded stream as a MP4 video
/// </summary>
/// <returns></returns>
task<void> CameraControl::StoreRecordingAsync()
{
// Create storage file for the capture
return create_task(_captureFolder->CreateFileAsync("SimpleVideo.mp4", CreationCollisionOption::GenerateUniqueName))
.then([this](StorageFile^ file)
{
//TODO: Write the "this->video_stream" as a MP4 video to the file
});
}
は、私は2番目の質問に
(CapturePhotoToStreamAsyncためBitmapDecoderに類似)のストリームに変換することができますMP4Decoderようなものが必要"StartRecordToStorageFileAsync"。しかし、これは解決策ではありません。なぜなら、ビデオを保存することはオプションで終わりです。私はすべてのビデオを保存したくありません。
ありがとうございます!
Corono
編集:私はFrameArrivedイベントを持つメディアフレームリーダーを実装しようとした
。
public : IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(MediaFrameSource inputSource)
PCでうまく動作しますが、Win10モバイルデバイスにMediaFrameSourceが見つかりません。理由は分かりません。
なぜMediaCaptureカメラストリームのすべてのフレームからスクリーンショットを撮りたいのですか?私たちはビデオを直接保存できるようです。 –
私はビデオを望んでいないので、動きを段階的に分析するためには画像のストリームが必要です。ビデオを保存するには、分析後にオプションにする必要があります。 – Corono