1

I am using the video recording sample provided by microsoft here. I want to change the resolution of the video being recorded in my app. Currently its recording in highest resolution by default. How to do so?

videoCaptureDevice.DesiredFormat = new VideoFormat(PixelFormatType.Unknown, 480, 640, 30);

The above statement is throwing Argument Exception.

Also, if possible let me know how to capture from the front camera?

How to achieve this? Please help.

Milan Aggarwal
  • 5,104
  • 3
  • 25
  • 54

4 Answers4

0

Second parameter for AudioVideoCaptureDevice.OpenAsync is the resolution. And you can get the resolutions using AudioVideoCaptureDevice.GetAvailableCaptureResolutions(sensor).

Claus Jørgensen
  • 25,882
  • 9
  • 87
  • 150
  • do you know why in front camera the camera feed is 180 degree rotated? – Milan Aggarwal Jul 19 '13 at 07:00
  • The camera is always recording in landscape. – Claus Jørgensen Jul 19 '13 at 08:23
  • hey claus, i realize that AudioVideoCaptureDevice might be the best solution for recording videos in WP8, however I am unable to find any samples or help in that. I have posted a similar question for it http://stackoverflow.com/questions/17898769/how-to-record-video-using-audiovideocpturedevice-in-wp8. Can you help? Thanks in advance. – Milan Aggarwal Jul 27 '13 at 14:19
0

You may try this one.

private AudioVideoCaptureDevice VideoRecordingDevice;
private Windows.Foundation.Size resolution = new Windows.Foundation.Size(320, 240);
VideoRecordingDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, resolution);

NB: Remember that it may only used for wp8 or later version.

reza.cse08
  • 5,938
  • 48
  • 39
-1

The Solution is (With my knowledge)

     VideoCaptureDevice webcam = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

 int videoformatcount = webcam.SupportedFormats.Count(); //We will get the avilable video format

  if (videoformatcount > 0)
             {
                var Temp = webcam.SupportedFormats;

                VideoFormat objVideoFormat = Temp[videoformatcount - 1];

                webcam.DesiredFormat = new VideoFormat(PixelFormatType.Format8bppGrayscale, objVideoFormat.PixelWidth, objVideoFormat.PixelHeight, 1);
            }

captureSource.VideoCaptureDevice = webcam;

This will produce the lowest resolution video

Vicky
  • 1,095
  • 16
  • 15
  • do you know why in front camera the camera feed is 180 degree rotated? – Milan Aggarwal Jul 19 '13 at 06:57
  • Sorry!i don't know..you can go thorough these links and may be it will help you [link](http://www.mindscapehq.com/blog/index.php/2012/02/28/windows-phone-7-working-with-camera-tasks/) [link] (http://msdn.microsoft.com/en-us/magazine/hh708750.aspx) – Vicky Jul 19 '13 at 07:33
  • Because the camera always record in landscape. @Vicky your code is guesswork, it's not a appropriate solution at all. – Claus Jørgensen Jul 19 '13 at 20:49
-1

Use AudioVideoCaptureDevice to recoed video

StorageFolder isoStore = await ApplicationData.Current.LocalFolder.GetFolderAsync("Shared");
            var file = await isoStore.CreateFileAsync("foos1.wmv", CreationCollisionOption.ReplaceExisting);
            using (var s = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                Windows.Foundation.Size resolution = new Windows.Foundation.Size(640, 480);
                avDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back,
                    AudioVideoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back).Last());

                VideoBrush videoRecorderBrush = new VideoBrush();
                videoRecorderBrush.SetSource(avDevice);

                viewfinderRectangle.Fill = videoRecorderBrush;

                await avDevice.StartRecordingToStreamAsync(s);

                Thread.Sleep(30000);


                await avDevice.StopRecordingAsync();



            }


            new MediaPlayerLauncher()
            {
                Media = new Uri(file.Path, UriKind.Relative),
            }.Show();
pranavjayadev
  • 937
  • 7
  • 31