I have reworded my question from the previous one. I have created a Desktop recorder and it works perfectly except one thing. When I try to encode the video and place the media in my output folder C:\Videos
it throws an exception.
Keep in mind that the output .xesc
will save to the Videos folder on the C drive. However when i try to convert it to .wmv format it throws the following exception.
An unhandled exception of type Microsoft.Expression.Encoder.InvalidMediaFileException occured in Microsoft.Expression.Encoder.dll Aditional Information: Access Denied (Exception from HRESULT: 0x80070005(E_AccessDenied))
I have posted the encoder below.
**** Source Code ******
Here is the source code dealing with the encoding. I was working on a few things on it and if you see any mistakes or anything to better it then let me know. It works perfectly and puts the .xesc formatbut it will not save the .wmv
void Encode(string jobPath)
{
using (Job j = new Job())
{
MediaItem mediaItem = new MediaItem(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) + @"\IvanSoft Desktop Recorder");
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 = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) + @"\IvanSoft Desktop Recorder.xesc";
j.EncodeProgress += new EventHandler<EncodeProgressEventArgs>(j_EncodeProgress);
j.Encode();
}
}
This is not necessary a problem because i can convert the .xesc
manually but that takes time. I would like it to work when i press Save_btnClik
It will encode like its supposed to. This happens in win8.1 and win10.
What kind of permission do i need to gain access?