本文整理汇总了C#中AviWriter.AddEncodingVideoStream方法的典型用法代码示例。如果您正苦于以下问题:C# AviWriter.AddEncodingVideoStream方法的具体用法?C# AviWriter.AddEncodingVideoStream怎么用?C# AviWriter.AddEncodingVideoStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AviWriter
的用法示例。
在下文中一共展示了AviWriter.AddEncodingVideoStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartRecord
/// <summary>
/// Records this instance.
/// </summary>
/// <exception cref="RedCell.Research.ResearchException">
/// Filename must be set before recording.
/// or
/// A recording has already started.
/// </exception>
/// <exception cref="System.InvalidOperationException">Filename must be set before recording.</exception>
public void StartRecord()
{
// Automatic filename
if (string.IsNullOrWhiteSpace(Filename))
Filename = "Video_" + DateTime.Now.ToString("yyyyMMddHHmmss");
if(_writer != null)
throw new ResearchException("A recording has already started.");
// Get video details from camera.
if (StreamSetting == null)
StreamSetting = Camera.StreamSetting;
var encoder = new Mpeg4VideoEncoderVcm(StreamSetting.Width, StreamSetting.Height, StreamSetting.Framerate, 0, 50, KnownFourCCs.Codecs.X264);
_writer = new AviWriter(Filename);
_video = _writer.AddEncodingVideoStream(encoder, true, StreamSetting.Width, StreamSetting.Height);
Camera.FrameAvailable += Camera_FrameAvailable;
}
示例2: StartRecording
private bool StartRecording()
{
int captureWidth = (int)(m_Capture.CaptureBounds.Width * m_Capture.Scale),
captureHeight = (int)(m_Capture.CaptureBounds.Height * m_Capture.Scale),
codecSelectedIndex = comboBox_videoCodec.SelectedIndex,
codecQuality = Convert.ToInt32(textBox_recordQuality.Text);
try
{
m_AviWriter = new AviWriter(m_AviFilePath)
{
FramesPerSecond = m_Capture.FramesPerSecond,
EmitIndex1 = true,
};
if (codecSelectedIndex == 0)
{
m_AviVideoStream = m_AviWriter.AddVideoStream(captureWidth, captureHeight);
}
else if (codecSelectedIndex == 1)
{
m_AviVideoStream = m_AviWriter.AddMotionJpegVideoStream(captureWidth, captureHeight, codecQuality);
}
else
{
var codecs = Mpeg4VideoEncoderVcm.GetAvailableCodecs();
var encoder = new Mpeg4VideoEncoderVcm(captureWidth, captureHeight, m_Capture.FramesPerSecond, 0, codecQuality, codecs[codecSelectedIndex - 2].Codec);
m_AviVideoStream = m_AviWriter.AddEncodingVideoStream(encoder);
}
if (checkBox_recordAudio.Checked)
{
m_AviAudioStream = m_AviWriter.AddAudioStream(m_Recorder.WaveFormat.Channels, m_Recorder.WaveFormat.SampleRate, m_Recorder.WaveFormat.BitsPerSample);
}
}
catch
{
Debug.Log("Failed to Start Recording.");
return false;
}
return true;
}
示例3: LoadSettings
private void LoadSettings()
{
try
{
writer = new AviWriter("test.avi")
{
FramesPerSecond = 25,
// Emitting AVI v1 index in addition to OpenDML index (AVI v2)
// improves compatibility with some software, including
// standard Windows programs like Media Player and File Explorer
EmitIndex1 = true
};
var encoder = new Mpeg4VideoEncoderVcm((int)numericWidth.Value, (int)numericHeight.Value, 25, 0, 100, KnownFourCCs.Codecs.Xvid);
// stream = writer.AddMotionJpegVideoStream(640, 480, quality: 100);
//stream = writer.AddMpeg4VideoStream(640, 480, 30, quality: 70, codec: KnownFourCCs.Codecs.X264, forceSingleThreadedAccess: true);
stream = writer.AddEncodingVideoStream(encoder, true, (int)numericWidth.Value, (int)numericHeight.Value);
// set standard VGA resolution
// stream.Width = 640;
// stream.Height = 480;
// class SharpAvi.KnownFourCCs.Codecs contains FOURCCs for several well-known codecs
// Uncompressed is the default value, just set it for clarity
//stream.Codec = KnownFourCCs.Codecs.MotionJpeg;
// Uncompressed format requires to also specify bits per pixel
//stream.BitsPerPixel = BitsPerPixel.Bpp32;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}