Microsoft Expression Encoder. ScreenCapture
I noticed that Exression Encoder 4 screen recordings are sometimes shorter than specified. E.g. a 5 minute recording yields only 15 seconds of video. This seems to be related to the audio being captured at the same time as the video. Initially I was using my headset speakers as the audio profile. When I removed captuing audio from my recording, the problems stopped. When I changed the audio profile to my standard speakers, it stopped as well. However I can easily repr开发者_如何学编程oduce it by rapidly changing volume when the recording starts. The result is that recording freezes... It still takes the 5 minutes to record; but the result is onlt 15 seconds (or so) of video.
The code snippet is shown below.
try
{
_screenCaptureJob = new ScreenCaptureJob();
_screenCaptureJob.CaptureRectangle = _screenRectangle;
_screenCaptureJob.ShowFlashingBoundary = true;
_screenCaptureJob.ScreenCaptureVideoProfile.FrameRate = 20;
_screenCaptureJob.CaptureMouseCursor = false;
_screenCaptureJob.ScreenCaptureCommandFinished += new EventHandler<ScreenCaptureCommandFinishedEventArgs>(_screenCaptureJob_ScreenCaptureCommandFinished);
_screenCaptureJob.ScreenCaptureFinished += new EventHandler<ScreenCaptureEventArgs>(_screenCaptureJob_ScreenCaptureFinished);
Collection<EncoderDevice> audioDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
try
{
EncoderDevice foundDevice = audioDevices.First(delegate(EncoderDevice item) { return item.Name.StartsWith(@"Speakers"); });
_screenCaptureJob.AddAudioDeviceSource(foundDevice);
}
catch (Exception ex)
{
_appLogger.Error(string.Format("RecordNextSegment. Cannot find prefered audio device using {0} !", audioDevices[0].Name), ex);
_screenCaptureJob.AddAudioDeviceSource(audioDevices[0]);
}
_currentDurationInSeconds = (_recordDurationInSeconds < _maxSegmentDurationInSeconds) ? _recordDurationInSeconds : _maxSegmentDurationInSeconds;
_screenCaptureJob.Duration = DateTimeUtilities.DurationToTimeSpan(_currentDurationInSeconds);
_screenCaptureJob.OutputScreenCaptureFileName = string.Format(@"{0}\{1}.wmv", _tvaConfiguration.TVAVideoDirectoryRawVideo, FileNameFromSegment(_segmentNumber ));
_screenCaptureJob.Start();
LogInfo(string.Format("Remaining time (seconds): {0}. Current time: {1}. File: {2}", _recordDurationInSeconds, _currentDurationInSeconds, _screenCaptureJob.OutputScreenCaptureFileName));
Not sure, about the way to fix your problem but wanted to give you some input on the audio problem. On the couple machines, I tested my application, the screen capture and as well the audio worked perfectly. So from that, I could only conclude, that it might be something related to your hardware or a problem with your code...(maybe debug through it ?)
Also, your solution might be the same as this.
精彩评论