2

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?

enter image description here

campnerd
  • 76
  • 1
  • 1
  • 10
  • in order to write to the root of C:\ you need a admin permission. You can validate this by copying a file to there - you well be asked to provide a password. – elyashiv Aug 08 '16 at 05:59
  • see http://stackoverflow.com/questions/2818179/how-do-i-force-my-net-application-to-run-as-administrator – nozzleman Aug 08 '16 at 06:02
  • is it possible to include the current code that you are trying? – sujith karivelil Aug 08 '16 at 06:33
  • Yeah I can add it give me a second to get back to my office. I have been working on this about 18 hours straight. So I needed a break from the invalidmediafile and access denied. Give about 5 minutes – campnerd Aug 08 '16 at 06:40

2 Answers2

0

Why you dont use "SaveFileDiaLog". I think it is the best method. You can find it in "Toolbox" in Winform_application Visual studio

  • I have thought about using the SaveFileDialog and i am not sure if i want to use it since i am the only one using it. This is for personal use and i am wanting to use a preset defined location. But if i have to use it then i can – campnerd Aug 11 '16 at 04:26
  • if you read the question, then you will see that it saves to the location i want. Its the encoding file that does not have access. – campnerd Aug 11 '16 at 04:35
  • Alright. I'm clearly. The first, you should check 2 line: Line 1 : MediaItem mediaItem = new MediaItem(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) + @"\IvanSoft Desktop Recorder"); Line 2: j.OutputDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) + @"\IvanSoft Desktop Recorder.xesc"; – chibao thach Aug 11 '16 at 11:50
  • Because, Line 1 for directory, other for file. Let's be care full – chibao thach Aug 11 '16 at 11:52
  • The second, maybe you want try EnvironmentFolders.GetPath(...). Instead of Environment.GetFolderPath(....). – chibao thach Aug 11 '16 at 11:55
  • `EnviromentFolders.GetFolderPath(........)` is not in the selection. all you have is `Enviroment` and `EnviromentVariableTarget` the error being thrown is `Access Denied` when i try to do the wmv output. I may have to do a configuration file or App Manifest to see if that works – campnerd Aug 11 '16 at 17:56
0

Ok I found out that Microsoft Expression Encoder 4 does not truely save a file to a .wmv format. It only changes the .xesc to a .wmv.

I found this out by once I got it converted to what I thought was a .wmv I loaded it to Movie Maker and it said that .xesc was not supported.

So the ultimate outcome is that MEE4 encoder will produce a .xesc format. Then I also noticed that third party converters that truely convert the file. The video and sound is not synced. So unless I missed a piece of code somewhere, third party converters are not the way to go.

So I will have to figure a way to truly convert .xesc to another format and retain frame speed and sync.

campnerd
  • 76
  • 1
  • 1
  • 10