2014-06-11 1 views
2

MediaCapture를 사용하여 Windows Phone 8.1 Silverlight에 비디오를 레코딩 할 때 "내용을 인코딩하거나 디코딩하기 위해 적합한 변환이 없습니다"라는 예외가 발생합니다. .wmv :MediaEncodingProfile "콘텐츠를 인코딩하거나 디코딩 할 적절한 변환이 발견되지 않았습니다." 예외

MediaEncodingProfile profile = MediaEncodingProfile.CreateWmv(Windows.Media.MediaProperties.VideoEncodingQuality.Auto); 

그러나 변환을 적용하는 방법에 대한 문서 나 게시물을 찾을 수 없습니다. 누구든지 도와 줄 수 있습니까? 아래

[편집] 전체 코드 :

//PreviewSink for previewing video 
    MediaCapturePreviewSink previewSink = new MediaCapturePreviewSink(); 

    //Viewfinder for viewing video. 
    private VideoBrush videoRecorderBrush; 

    //Profile for setting up capture type 
    MediaEncodingProfile _profile; 

    //MediaCapture for recording video 
    MediaCapture mediaCaptureManager = new MediaCapture(); 

    // File details for storing the recording.   
    private IsolatedStorageFileStream isoVideoFile; 
    private string isoVideoFileName = "CameraMovie.mp4"; 

    // For managing button and application state. 
    private enum ButtonState { Initialized, Ready, Recording, Playback, Paused, NoChange, CameraNotSupported }; 
    private ButtonState currentAppState; 

//PREVIEW/VIEWFINDER 

    //Start the video preview when the page loads 
    private async void StartPreview() 
    { 
     //INITIALIZE 
     await subInitialise(); 

     //PREVIEW 
     await subPreview(); 
    } 

    //Initilize MediaCapture for previewing 
    private async System.Threading.Tasks.Task subInitialise() 
    { 
     // Find the camera device id to use 
     string deviceId = ""; 
     var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.VideoCapture); 
     for (var i = 0; i < devices.Count; i++) 
     { 
      Debug.WriteLine(devices[i]); 
      deviceId = devices[i].Id; 
     } 

     // init the settings of the capture 
     var settings = new MediaCaptureInitializationSettings(); 
     settings.AudioDeviceId = ""; 
     settings.VideoDeviceId = deviceId; 
     settings.MediaCategory = MediaCategory.Other; 
     settings.PhotoCaptureSource = PhotoCaptureSource.Photo; 
     settings.StreamingCaptureMode = StreamingCaptureMode.AudioAndVideo; 

     //This creates the recording media profile 
     CreateProfile(); 

     await mediaCaptureManager.InitializeAsync(settings); 
    } 

    //Create the MediaEncodingProfile 
    private void CreateProfile() 
    { 
     //WORKS 
     //_profile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Qvga); 
     //DOESN'T WORK 
     _profile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateWmv(Windows.Media.MediaProperties.VideoEncodingQuality.Auto); 

    } 

    //Set up the MediaCapture for previewing and start preview 
    private async System.Threading.Tasks.Task subPreview() 
    { 
     //MediaCapturePreviewSink previewSink = new MediaCapturePreviewSink(); 
     // List of supported video preview formats to be used by the default preview format selector. 
     var supportedVideoFormats = new List<string> { "nv12", "rgb32" }; 

     // Find the supported preview format 
     var availableMediaStreamProperties = mediaCaptureManager.VideoDeviceController.GetAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType.VideoPreview).OfType<Windows.Media.MediaProperties.VideoEncodingProperties>().Where(p => p != null && !String.IsNullOrEmpty(p.Subtype) && supportedVideoFormats.Contains(p.Subtype.ToLower())).ToList(); 
     var previewFormat = availableMediaStreamProperties.FirstOrDefault(); 

     // Start Preview stream 
     await mediaCaptureManager.VideoDeviceController.SetMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType.VideoPreview, previewFormat); 
     await mediaCaptureManager.StartPreviewToCustomSinkAsync(new Windows.Media.MediaProperties.MediaEncodingProfile { Video = previewFormat }, previewSink); 

     // Create the VideoBrush for the viewfinder. 
     videoRecorderBrush = new VideoBrush(); 
     // Set the source of the VideoBrush used for your preview 
     Microsoft.Devices.CameraVideoBrushExtensions.SetSource(videoRecorderBrush, previewSink); 
     // Display the viewfinder image on the rectangle. 
     viewfinderRectangle.Fill = videoRecorderBrush; 

     //Set the button states and the message. 
     UpdateUI(ButtonState.Initialized, "Ready to record."); 
    } 

//Start recording 
    private async void StartVideoRecordingNew() 
    { 
     try 
     { 
      // Get the local folder. 
      StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; 

      // Create a new file named DataFile.txt. 
      var storageFile = await local.CreateFileAsync(isoVideoFileName, CreationCollisionOption.ReplaceExisting); 

      await mediaCaptureManager.StartRecordToStorageFileAsync(_profile, storageFile); 

      // Set the button states and the message. 
      UpdateUI(ButtonState.Recording, "Recording..."); 
     } 

     // If recording fails, display an error. 
     catch (Exception e) 
     { 
      this.Dispatcher.BeginInvoke(delegate() 
      { 
       txtDebug.Text = "ERROR: " + e.Message.ToString(); 
      }); 
     } 
    } 
+0

가능한 복제본 [MediaEncodingProfile.CreateWmv는 "콘텐츠를 인코딩하거나 디코딩 할 수있는 적절한 변환이 없습니다."를 제공합니다. 오류] (http://stackoverflow.com/questions/24121125/mediaencodingprofile-createwmv-gives-no-suitable-transform-was-found-to-encode) –

답변

관련 문제