Using Windows Media Encoder to Record a Screen

Is it easy to write some .Net code to record screen and sound (from a computer microphone), and then output to a wmv file. Any reference code?

BTW: I searched all the codes from the WME SDK, no such code sample.

thank! George

+1
source share
6 answers

Microsoft and the mafi ^ H ^ H ^ H ^ Hindustry content try their best to make this impossible. You will be much better off looking for β€œgrabbing open source audio files” than looking at any officially submitted document / sample code - I would be seriously surprised if Microsoft provided something relevant.

+2

SDK, Techsmith Camtasia:

Camtasia - , .., SDK ActiveX ( .NET).

+1

, DirectShow . .NET( ).

, : http://www.hmelyoff.com/index.php?section=9

EDIT: SDK WME. DirectShow, WME -, DirectShow ( ), - API.

Hmelyoff, , -. , . , viedo ( API, ​​ BitBlt).

.

, DirectShow, - COM . http://directshownet.sourceforge.net/ .

: - , . 30 . CPU hog? , .

, , . DirectShow .

+1

Windows COM- .net- .

0

Microsoft Expression Encoder 4, , . #. .

void Encode(string jobPath)
    {
        using (Job j = new Job())
        {

            MediaItem mediaItem = new MediaItem(jobPath);
            var size = mediaItem.OriginalVideoSize;
            WindowsMediaOutputFormat WMV_Format = new WindowsMediaOutputFormat();
            WMV_Format.VideoProfile = new Microsoft.Expression.Encoder.Profiles.AdvancedVC1VideoProfile();
            WMV_Format.AudioProfile = new Microsoft.Expression.Encoder.Profiles.WmaAudioProfile();
            WMV_Format.VideoProfile.AspectRatio = new System.Windows.Size(16, 9);
            WMV_Format.VideoProfile.AutoFit = true;

            if (size.Width >= 1920 && size.Height >= 1080)
            {
                WMV_Format.VideoProfile.Size = new System.Drawing.Size(1920, 1080);
                WMV_Format.VideoProfile.Bitrate = new Microsoft.Expression.Encoder.Profiles.VariableUnconstrainedBitrate(6000);
            }
            else if (size.Width >= 1280 && size.Height >= 720)
            {
                WMV_Format.VideoProfile.Size = new System.Drawing.Size(1280, 720);
                WMV_Format.VideoProfile.Bitrate = new Microsoft.Expression.Encoder.Profiles.VariableUnconstrainedBitrate(4000);
            }
            else
            {
                WMV_Format.VideoProfile.Size = new System.Drawing.Size(size.Width, size.Height);
                WMV_Format.VideoProfile.Bitrate = new Microsoft.Expression.Encoder.Profiles.VariableUnconstrainedBitrate(2000);
            }
            mediaItem.VideoResizeMode = VideoResizeMode.Letterbox;
            mediaItem.OutputFormat = WMV_Format;
            j.MediaItems.Add(mediaItem);
            j.CreateSubfolder = false;
            j.OutputDirectory = @"D:\output";
            j.EncodeProgress += new EventHandler<EncodeProgressEventArgs>(j_EncodeProgress);
            j.Encode();
        }
    }
0

Source: https://habr.com/ru/post/1742734/


All Articles