Khaled Janky
Khaled Janky

Reputation: 45

The specified executable is not a valid application for this OS platform mediatoolkit

I have this function to get the duration of an mp3 file using mediaToolKit.

but when execute engine.GetMetadata(inputFile); I have an exception that is :

System.ComponentModel.Win32Exception: 'The specified executable is not a valid application for this OS platform.'

private string getDuration()
        {
            string orginalFilePath = LocalMediaPath;
            if (File.Exists(orginalFilePath))
            {
                var inputFile = new MediaFile { Filename = orginalFilePath };
                using (var engine = new Engine())
                {
                    engine.GetMetadata(inputFile);
                    return inputFile.Metadata.Duration.TotalSeconds.ToString();
                }
            }
            else
                return "-1";
        }

Upvotes: 0

Views: 487

Answers (1)

Jiale Xue - MSFT
Jiale Xue - MSFT

Reputation: 3670

I found the source code.

It works well!

enter image description here

Snippet:

using MediaToolkit;
using MediaToolkit.Model;
using System;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputFile = new MediaFile { Filename = @"C:\Users\Admin\source\repos\ConsoleApp2\ConsoleApp2\music\123.mp3" };
            using (var engine = new Engine())
            {
                engine.GetMetadata(inputFile);
            }
            Console.WriteLine(inputFile.Metadata.Duration);
            System.Console.ReadLine();
        }
    }
}

Change your file, it is likely that your file is not supported.

Upvotes: 1

Related Questions