UWP从摄像头捕获视频然后通过套接字(TCP)发送

时间:2017-01-05 05:51:54

标签: c#

我想捕获摄像头视频,然后通过TCP协议通过套接字发送到另一台机器。我使用Windows.Media.Capture.MediaCapture来捕获视频,代码如下:

 private async Task StartVideoAsync()
        {
            try
            {
                //Creat log object
                lc = new LoggingChannel("LyLog", null, new Guid("B5F3B8E9-A854-4045-A6DE-A7C4FF8FA114"));
                lc.LogMessage("LoggingChannel create success");

                //Creat video capture object
                mediaCapture = new MediaCapture();
                lc.LogMessage("MediaCapture create success");

                //Set video capture property 
                var settings = new MediaCaptureInitializationSettings();
                settings.StreamingCaptureMode = StreamingCaptureMode.Video;
                await mediaCapture.InitializeAsync(settings);
                lc.LogMessage("Set Capture property success");

                //Creat media profile
                var recordProfile = MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Auto);
                lc.LogMessage("Create media profile success");

                //Creat media stream
                m_stream = new InMemoryRandomAccessStream();
                lc.LogMessage("Create media stream success");

                //Start recording 
                await mediaCapture.StartRecordToStreamAsync(recordProfile, m_stream);
                lc.LogMessage("Start recording success");
            }
            catch (UnauthorizedAccessException) 
            {
                //There's no camera access
                lc.LogMessage("The app was denied access to the camera");
            }
            catch (Exception ex)
            {
                lc.LogMessage(ex.Message);
            }
        }

我有两个问题: 1.使用这种方式捕获流中的数据是mp4格式。如何获取h.264视频数据? 2.如何通过套接字发送h.264数据?

0 个答案:

没有答案