I have saved a job using expression encoder (.xej) and now I need to load its video profile on my code, like this:
public static void EncodeVideo(string filePath)
{
using (Job job = new Job())
{
string xml = File.ReadAllText("test_job.xej");
XmlVideoProfile videoProfile = new XmlVideoProfile(xml);
MediaItem media = new MediaItem(filePath);
media.OutputFormat = new WindowsMediaOutputFormat()
{
VideoProfile = videoProfile
};
job.MediaItems.Add(media);
job.OutputDirectory = @"c:\videos\encoded\";
job.Encode();
}
}
But this is giving me the following error:
Microsoft.Expression.Encoder.XmlErrorException was unhandled Message="Cannot find attribute bitrate in xmlfile at 3,2." Source="Microsoft.Expression.Encoder" StackTrace: at MS.Internal.Expression.Encoder.Xml.ValidateXmlAttributeCollection.get_Item(String strName) at Microsoft.Expression.Encoder.Profiles.ProfileBaseData..ctor(ValidateXmlElement doc, MediaType type) at Microsoft.Expression.Encoder.Profiles.VideoProfileData..ctor(ValidateXmlElement doc, AdaptiveStreamingVersion adaptiveVersion) at Microsoft.Expression.Encoder.Profiles.XmlVideoProfile..ctor(String xmlDescription) at Encoder.Program.EncodeVideo(String filePath) at Encoder.Program.Main(String[] args) at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
I have tried to remove all the other nodes from the xml file and leave only the videoprofile one and i've also tried with diferent jobs.
Any suggestions?