A few how to questions on CaptureDevice: Microsoft.Devices

Hi. I'm using CaptureDevice to capture videos (
vcDevice =
CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
1. How to I set the recording resolution? (I tried setting the canvas/videobrush resolution but the playback is still normal)
2. How do I get the current size of captured file ex while recording I want to update a textblock and as the video records I want to show how many MB the file is now.
3. does keeping the video preview on uses a lot of battery power?
thanks

this is what I have so far:
// Viewfinder for capturing video.
private VideoBrush videoRecorderBrush;
// Source and device for capturing video.
private CaptureSource _cs;
private AudioVideoCaptureDevice vcDevice;
double w, h;
// File details for storing the recording.
private IsolatedStorageFileStream isoVideoFile;
private FileSink fileSink;
private string isoVideoFileName = "iClips_Video.mp4";
private StorageFile sfVideoFile;
protected async override void OnNavigatedTo(NavigationEventArgs e)
base.OnNavigatedTo(e);
// Initialize the video recorder.
await InitializeVideoRecorder();
//prepare shutter hot keys
CameraButtons.ShutterKeyHalfPressed += OnButtonHalfPress;
CameraButtons.ShutterKeyPressed += OnButtonFullPress;
CameraButtons.ShutterKeyReleased += OnButtonRelease;
// Update the buttons and text on the UI thread based on app state.
private void UpdateUI(ButtonState currentButtonState, string statusMessage)
// Run code on the UI thread.
Dispatcher.BeginInvoke(delegate
switch (currentButtonState)
// When the camera is not supported by the phone.
case ButtonState.CameraNotSupported:
StartRecording.IsEnabled = false;
StopPlaybackRecording.IsEnabled = false;
StartPlayback.IsEnabled = false;
PausePlayback.IsEnabled = false;
break;
// First launch of the application, so no video is available.
case ButtonState.Initialized:
StartRecording.IsEnabled = true;
StopPlaybackRecording.IsEnabled = false;
StartPlayback.IsEnabled = false;
PausePlayback.IsEnabled = false;
break;
// Ready to record, so video is available for viewing.
case ButtonState.Ready:
StartRecording.IsEnabled = true;
StopPlaybackRecording.IsEnabled = false;
StartPlayback.IsEnabled = true;
PausePlayback.IsEnabled = false;
break;
// Video recording is in progress.
case ButtonState.Recording:
StartRecording.IsEnabled = false;
StopPlaybackRecording.IsEnabled = true;
StartPlayback.IsEnabled = false;
PausePlayback.IsEnabled = false;
break;
// Video playback is in progress.
case ButtonState.Playback:
StartRecording.IsEnabled = false;
StopPlaybackRecording.IsEnabled = true;
StartPlayback.IsEnabled = false;
PausePlayback.IsEnabled = true;
break;
// Video playback has been paused.
case ButtonState.Paused:
StartRecording.IsEnabled = false;
StopPlaybackRecording.IsEnabled = true;
StartPlayback.IsEnabled = true;
PausePlayback.IsEnabled = false;
break;
default:
break;
// Display a message.
txtDebug.Text = statusMessage;
// Note the current application state.
currentAppState = currentButtonState;
public async Task InitializeVideoRecorder()
try
if (_cs == null)
CaptureDevice cd= CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
_cs = cd as CaptureSource;
CameraSensorLocation location = CameraSensorLocation.Back;
var captureResolutions =
AudioVideoCaptureDevice.GetAvailableCaptureResolutions(location);
vcDevice =
await AudioVideoCaptureDevice.OpenAsync(location,
captureResolutions[0]);
vcDevice.RecordingFailed += OnCaptureFailed;
vcDevice.VideoEncodingFormat = CameraCaptureVideoFormat.H264;
vcDevice.AudioEncodingFormat = CameraCaptureAudioFormat.Aac;
// Initialize the camera if it exists on the phone.
if (vcDevice != null)
//initialize fileSink
InitializeFileSink();
// Create the VideoBrush for the viewfinder.
videoRecorderBrush = new VideoBrush();
videoRecorderBrush.SetSource(CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice());
// Display the viewfinder image on the rectangle.
viewfinderRectangle.Fill = videoRecorderBrush;
// Set the button state and the message.
UpdateUI(ButtonState.Initialized, "Tap record to start recording...");
else
// Disable buttons when the camera is not supported by the phone.
UpdateUI(ButtonState.CameraNotSupported, "A camera is not supported on this phone.");
catch(Exception ex)
MessageBox.Show("InitializeVideoRecorder Error:\n" + ex.Message);
public async void InitializeFileSink()
StorageFolder isoStore = ApplicationData.Current.LocalFolder;
sfVideoFile = await isoStore.CreateFileAsync(
isoVideoFileName,
CreationCollisionOption.ReplaceExisting);
private void OnCaptureFailed(AudioVideoCaptureDevice sender, CaptureFailedEventArgs args)
MessageBox.Show(args.ToString());
private void OnCaptureSourceFailed(object sender, ExceptionRoutedEventArgs e)
MessageBox.Show(e.ErrorException.Message.ToString());
// Set the recording state: display the video on the viewfinder.
private void StartVideoPreview()
try
// Display the video on the viewfinder.
if (_cs.VideoCaptureDevice != null
&& _cs.State == CaptureState.Stopped)
// Add captureSource to videoBrush.
videoRecorderBrush.SetSource(_cs);
// Add videoBrush to the visual tree.
viewfinderRectangle.Fill = videoRecorderBrush;
_cs.Start();
// Set the button states and the message.
UpdateUI(ButtonState.Ready, "Ready to record.");
//Create optional Resolutions
// If preview fails, display an error.
catch (Exception e)
this.Dispatcher.BeginInvoke(delegate()
txtDebug.Text = "ERROR: " + e.Message.ToString();
// Set recording state: start recording.
private void StartVideoRecording()
try
// Connect fileSink to captureSource.
if (_cs.VideoCaptureDevice != null
&& _cs.State == CaptureState.Started)
_cs.Stop();
// Connect the input and output of fileSink.
fileSink.CaptureSource = _cs;
fileSink.IsolatedStorageFileName = isoVideoFileName;
// Begin recording.
if (_cs.VideoCaptureDevice != null
&& _cs.State == CaptureState.Stopped)
_cs.Start();
// Set the button states and the message.
UpdateUI(ButtonState.Recording, "Recording...");
StartTimer();
// If recording fails, display an error.
catch (Exception e)
this.Dispatcher.BeginInvoke(delegate()
txtDebug.Text = "ERROR: " + e.Message.ToString();
// Set the recording state: stop recording.
private void StopVideoRecording()
try
// Stop recording.
if (_cs.VideoCaptureDevice != null
&& _cs.State == CaptureState.Started)
_cs.Stop();
// Disconnect fileSink.
fileSink.CaptureSource = null;
fileSink.IsolatedStorageFileName = null;
// Set the button states and the message.
UpdateUI(ButtonState.Stopped, "Preparing viewfinder...");
StopTimer();
StartVideoPreview();
// If stop fails, display an error.
catch (Exception e)
this.Dispatcher.BeginInvoke(delegate()
txtDebug.Text = "ERROR: " + e.Message.ToString();
// Start the video recording.
private void StartRecording_Click(object sender, EventArgs e)
// Avoid duplicate taps.
StartRecording.IsEnabled = false;
StartVideoRecording();
private void DisposeVideoRecorder()
if (_cs != null)
// Stop captureSource if it is running.
if (_cs.VideoCaptureDevice != null
&& _cs.State == CaptureState.Started)
_cs.Stop();
// Remove the event handler for captureSource.
_cs.CaptureFailed -= OnCaptureFailed;
// Remove the video recording objects.
_cs = null;
vcDevice = null;
fileSink = null;
videoRecorderBrush = null;
private void OnCaptureFailed(object sender, ExceptionRoutedEventArgs e)
throw new NotImplementedException();
//STOP WATCH
private void StartTimer()
dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
dispatcherTimer.Start();
startTime = System.DateTime.Now;
private void StopTimer()
dispatcherTimer.Stop();
private void dispatcherTimer_Tick(object sender, EventArgs e)
System.DateTime now = System.DateTime.Now;
txtRecTime.Text = now.Subtract(startTime).ToString();
If it doesn't make sense can we start over then from the start: How to I capture video using AudioVideoCapturedevice API?

Similar Messages

  • A few How-To questions on E6-00

    1. How do I set a one-touch button to open camera ?  I know it's possible on the E72, couldn't figure why it shouldn't be possible on my E6, I guess I just couldn't find it myself.
    2. How to check battery level ?  Previously, when I used to have the Symbian Anna OS, I could do that by simply touching and holding the battery / clock icon on the screen and a small window would pop up and tell me the percentage of battery that was full.  It doesn't work anymore after upgrading to Belle.
    Thank you
    Roy

    With reference to battery condition, whilst loathe to mention paid for applications this is one example of battery info widget upon E6-00:
    Happy to have helped forum in a small way with a Support Ratio = 37.0

  • A few post config questions on new setup

    Hi Group,
    Just a few post config questions.
    First, how can I confirm my controller is in fact associating properly with an NTP server?  On a typically cisco product, I could just do a 'show ntp associations' or a 'show ntp status'.  I cannot see a way to confirm this on the gui or command line.
    Second, on my guest network with web-auth, if one were to choose to not use https for web-auth and instead use unsecure http, would that be possible and if so where in the gui?
    Thanks.

    The third field is from a WLC running v7.4 not v7.2.  I usually would install a 3rd party certificate, but what eles you can try is issue this command on from the CLI.  It had issues working with certain code versions, but you might as well give it a try.
    config network web-auth secureweb disable
    Thanks,
    Scott
    Help out other by using the rating system and marking answered questions as "Answered"

  • HOW TO FILTER DATA FROM MICROSOFT ACCESS

    HOW TO FILTER DATA FROM MICROSOFT ACCESS BASED ON DATE AND TIME AND GIVE THE RESULT TO A TABLE ?
    I need some example files , can anybody please help me ?
    Solved!
    Go to Solution.

    Just be sure to get examples specific to the Jet DBMS. It is rather "idiosyncratic" when dealing with time and date values.
    One question: the timestamp is being saved in a datetime field, right?
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How do questions disappear from forum?

    How do questions disappear from the Premiere forum?  Since I have a GTX 480 and am interested in learning how significant a difference official support for mercury playback is, vs hacked support, I had entered a question soliciting feedback from owners of GTX 470 video cards.  Someone with almost 12,000 posts took exception to my post, I responded, and my post can no longer be found.
    Is there a problem with the forum software?

    Steve,
    Do not recall that post, but then things have been pretty fast and furious in the CS5 forum.
    Now, there are a couple of ways that posts can disappear, or seem to do so:
    1.) a moderator can Lock a thread, or can branch things off into a new thread. This just happened today, however both original threads are still there, just not separated.
    2.) Adobe Admin. can remove a thread (do not think that a MOD can do that - only Lock, Move, or branch?), but would not likely do so, unless it was obviously spam. Even then, the thread would likely remain, with all URL's "[Edited by Host]" or similar.
    3.) a moderator can Move a thread, say if one was posted to the CS5 forum, and it was really concerning CS4, or earlier. This can also happen, if a thread is best suited for the Hardware Forum (would be my first guess in your case), or to the Lounge, if I have managed to drag it too far off-topic. Check the Hardware Forum, 'cause that is where I would expect such a post to be.
    4.) when Adobe went to the new software, many older posts went to bit-heaven I highly doubt that anything like that happened here. We lost a few posts when there was a major Jive update, but there has not been such an update in ~ 8 mos.
    5.) one can often not see posts, if they access the forum via e-mail, instead of a browser. I would guess that with some feeds, that could happen too, but do not know.
    Good luck, and do check the Hardware Forum,
    Hunt
    PS - usually, when Jeff, Jerry.K, Curt, et al, Moves a post, they try to let the poster know. Still, with CS5.0.2 hitting, and all the traffic, maybe they slipped up, ran completely out of time, or tried, and failed in the notification. Most likely, if one of the MOD's did Move it, they'll jump right in and report having done so. They are great, though sometimes details might get lost on a busy day, especially if they are trying to get out of town to be with their families on a holiday weekend (US) to indulge themselves in their "other lives." Or, they could be packing up to avoid a hurricane - Earl.

  • How can I sync my Microsoft Outlook tasks with my Ipad reminders? I dont want to use Icloud or an exchange

    How can I sync my Microsoft Outlook tasks with my Ipad reminders? I dont want to use Icloud or an exchange

    Plug it into your computer. Tell it to sync with "this computer" instead of iCloud. You shouldn't have to remove any apps. Otherwise, you can save the app data by using i-FunBox ( http://www.i-funbox.com/ ) just go to the "devices" tab and select 'user applications' and select all of your apps and tell iFunBox to "copy to pc" you're done! You have them all backed up.

  • How can I change a Microsoft Word document file into a picture file?

    How can I change a Microsoft Word document file into a picture or jpeg file? I am wanting to make the image I created my background on my macbook pro.

    After I had the document image the way I wanted it, I saved it as a web page and went from there. Below are the steps starting after I did the "save as" option in Word:
    1) Select "Save As Web Page". I changed the location from documents to pictures when the window came up to save it as a web page.
    2) Go to "Finder" on you main screen, or if it's on your main toolbar at the bottom.
    3) Click on the "Pictures" tab and find the file you just re-saved as a web page. (I included "web page" or something similar in the new title so I could easily find the correct file I was looking for)
    4) Open the correct file and then "right click" on the actual image. (Use 2 fingers to do so on a Mac)
    5) Select 'Use Image As Desktop Picture", and voilà! The personally created image, or whatever it is that you wanted, is now your background.
    **One problem I encountered while doing this is that the image would show up like it was right-aligned in relation to the whole screen. The only way I could figure how to fix this was to go back to the very original document in Word, (the one before it was saved as a web page), and move everything over to the left.
    I hope this helps someone else who was as frustrated as I was with something that I thought would have been very simple to do! If you have any tips or suggestions of your own, please feel free to share. : )

  • How do I open a microsoft Word 95 document in Pages?

    How can I open a Microsoft Word 95 document in Pages?

    The document format is too old. Download the free LibreOffice, and then open this Word '95 document with it. Then export to a different filename.doc, or filename.docx, and then open in Pages.

  • How do I set up microsoft outlook on the iphone?

    How do I set up microsoft outlook on the iphone?

    "Outlook" is the program you use to access your email account. You cannot use Outlook on the iPhone.
    You can, however, setup your same work email account you use in Outlook, in the "Mail" app on your iPhone.
    You will need to obtain the relevant email server settings, username and password that you used to set the email account up in Outlook on your PC, then follow these instructions:
    http://support.apple.com/kb/ht4810

  • How to i get back microsoft Windows xp after trashing it on my mac

    Help! How do I get back Microsoft Windows XP after trashing it on my Mac?

    XP is 'dead' without support from Microsoft or Apple and with Mavericks  you want Windows 7 64-bit OEM or 8.1.

  • How do I shut down Microsoft Database Daemon SyncServicesAgent - Installer wants it shut down in order to proceed with the installation of Microsoft MAC Office 2011.   I cannot find the offending application anywhere.   Why this stupid obstacle?

    How do I shut down Microsoft Database Daemon SyncServicesAgent - Installer wants it shut down in order to proceed with the installation of Microsoft MAC Office 2011.

    open activity monitor (applications>utilities) and quit all the ms office files running in there

  • "How to Web Printing with Microsoft Excel" needed!

    Hi all,
    I desperately need the SAP Howto document "How to Web Printing with Microsoft Excel" for BW 3.5. The document is listed in the Howto section of SDN, but the link is wrong or outdated - I cannot download this document. Could anyone of you provide me with this howto? Please upload it somewhere (could be interesting for other people as well) or send it to me by email ([email protected]). Points will be assigned
    Thanks a lot in advance,
    James

    Hi,
    Here is the How to Web Printing with Excel, download from the Link
    This will expire in 7 days from the posting Date.<a href="http://download.yousendit.com/143673776AFD7E8F">How to Web Printing with Excel</a>
    Cheers.
    Ranga

  • How can i convert New Microsoft Office Word Document to adobe

    how can i convert New Microsoft Office Word Document to adobe

    Hi itchigo,
    You can use Microsoft Word's inbuilt feature of converting the doc to pdf by simply selecting Save As> 'pdf doc format' from the drop down.
    Please refer: http://office.microsoft.com/en-001/word-help/save-as-pdf-HA010354239.aspx#BM11
    Adobe Reader does not have the capability of converting docs to pdf or vice versa. It can only be used to read pdf files.
    Regards,
    Rave

  • Ever time I send a link in Fire fox it transfer to Microsoft outlook. How do I turn off microsoft outlook program

    Ever time I want to send a link in Fire fox it transfer to by itself to Microsoft outlook. How do I turn off Microsoft outlook program. I tried numerous of time to set default to fire fox

    Hi
    Please find the links given below to call HP technical support.
    If you live in the US, contact HP Here.
    If you are in another part of the world, start Here.
    Let us know how it goes!
    "I work for HP."
    ****Click the (purple thumbs up icon in the lower right corner of a post) to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    Regards
    Manjunath

  • How to type Pashto in Microsoft Office Word in Macbook Pro?

    How to type Pashto in Microsoft Office Word in Macbook Pro? Though I have added Pashto Language, but when typing Pashto, It types something non-sense. Please guide me, if you know. The writing method of Pashto is the same like Arabic. I mean from Right to Left.

    No version of MS Word for OS X has ever supported Arabic script.  Instead you must use another app.  Mellel is best, but TextEdit, Nisus Writer, or OpenOffice should also work OK.

Maybe you are looking for

  • Repeated retrieval and parsing of XML file causes IE to display an error message

    I have a flash application that makes a HTTP call every 120 seconds to retrieve a xml file. This file is being generated with fresh data every few minutes or so and pushed to the apache web root with a unix mv command. I'm using the standard Flash XM

  • How do I set the default audio output for all users

    Here's the story. I have a Mac Pro in a classroom that is connected to the audio system via the digital (Toslink) output. The systems are bound to AD and OD with some minor management being performed via MCX (printers, login, etc...) When a new user

  • Setting inside margins

    I am unable to reset the inside margins on an existing document.  Editing "Document Preset" for inside margin has no effect on the document - I can change the numbers to any value with no effect on the document.  Changing gutter has no effect.  I hav

  • Table AUSP!!

    Hi, i hav an internal table having matnr etc details from likp/lips and another z table having structure : Sales Org Classification Characteristic Name Packing Material Name Rate (per KG) and The table which stores the classification data for a mater

  • FileContentConvesation.(Recordset Structure)

    If the record is mandary and comes only once we declare in recordset structure as record,1 if record has multiple occurences we declare as record,* if the record id optional .....??  what  we need to give ??recordset structure.  Thanks sagar