微软表达式编码器。屏幕截图
我注意到 Exression Encoder 4 屏幕录制有时比指定的要短。例如,5 分钟的录制仅产生 15 秒的视频。这似乎与与视频同时捕获的音频有关。最初我使用耳机扬声器作为音频配置文件。当我从录音中删除捕获音频时,问题就停止了。当我将音频配置文件更改为标准扬声器时,它也停止了。不过,当录音开始时,我可以通过快速改变音量来轻松再现它。结果就是录音卡住了……还是需要5分钟的时间来录音;但结果只有 15 秒(左右)的视频。
代码片段如下所示。
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));
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 reproduce 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));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定如何解决您的问题,但想为您提供一些有关音频问题的意见。在这几台机器上,我测试了我的应用程序、屏幕截图以及音频,效果非常完美。因此,据此,我只能得出结论,这可能与您的硬件或代码问题有关......(也许通过它进行调试?)
此外,您的解决方案可能与 这个。
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.