MediaToolkit icon indicating copy to clipboard operation
MediaToolkit copied to clipboard

Video to Audio ConvertProgressEvent not firing

Open amynkvirani opened this issue 7 years ago • 15 comments

When I try to convert a video .mpg to an audio .wav, both ConvertProgressEvent and ConversionCompleteEvent events are not fired.

amynkvirani avatar Aug 05 '16 07:08 amynkvirani

I found that someone else already fixed this and is available for you to merge. If you could do it, that would be great. Thanks

amynkvirani avatar Aug 05 '16 09:08 amynkvirani

Please accept the Pull requests!

tgiachi avatar Aug 25 '16 11:08 tgiachi

Can somebody provide solution for this. I'm in urgent need of the same. I believe regex could be an issue

vijaykishans avatar Jan 18 '17 19:01 vijaykishans

I believe it is already resolved with the last merge "699cb4a3dc14cfefe5ddaf1709f0de936c6533e0"

amynkvirani avatar Jan 18 '17 19:01 amynkvirani

Hi,

Thanks for your quick response. But Im unable to get the latest merge. How do I do that Pls help.

Regards

Vijay

From: Amyn Karim Virani [mailto:[email protected]] Sent: 19 January 2017 01:04 To: AydinAdn/MediaToolkit [email protected] Cc: vijaykishans [email protected]; Comment [email protected] Subject: Re: [AydinAdn/MediaToolkit] Video to Audio ConvertProgressEvent not firing (#49)

I believe it is already resolved with the last merge "699cb4a3dc14cfefe5ddaf1709f0de936c6533e0"

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AydinAdn/MediaToolkit/issues/49#issuecomment-273576939 , or mute the thread https://github.com/notifications/unsubscribe-auth/AYClwLEUMar0CLbYt8Zi_XgkNv1lc7Vtks5rTmkhgaJpZM4JdcTI . https://github.com/notifications/beacon/AYClwDJ3ahBtxI2zIlBz6E77VWPIvmC_ks5rTmkhgaJpZM4JdcTI.gif

vijaykishans avatar Jan 18 '17 19:01 vijaykishans

are you using the github code or used the nuget package?

amynkvirani avatar Jan 18 '17 19:01 amynkvirani

https://github.com/AydinAdn/MediaToolkit

Clicked on Clone or Download button

Added a console application.

Used the below code as mentioned in readme but engine_ConversionCompleteEvent never gets triggered :

static void Main(string[] args)

    {

        StartConverting(); 

    }

  

    static public void StartConverting()

    {

        MediaFile objInputFiles = new MediaFile();

        var inputFile = new MediaFile { Filename = @"F:\ffmpeg\Baahubali2.mp4" };

        var outputFile = new MediaFile { Filename = @"F:\ffmpeg\encoded_Baahubali2.mp4" };



        using (var engine = new Engine())

        {

            engine.ConvertProgressEvent += ConvertProgressEvent;

            engine.ConversionCompleteEvent += engine_ConversionCompleteEvent;

            engine.Convert(inputFile, outputFile);

        }

    }



    static private void ConvertProgressEvent(object sender, ConvertProgressEventArgs e)

    {

        Console.WriteLine("\n------------\nConverting...\n------------");

        Console.WriteLine("Bitrate: {0}", e.Bitrate);

        Console.WriteLine("Fps: {0}", e.Fps);

        Console.WriteLine("Frame: {0}", e.Frame);

        Console.WriteLine("ProcessedDuration: {0}", e.ProcessedDuration);

        Console.WriteLine("SizeKb: {0}", e.SizeKb);

        Console.WriteLine("TotalDuration: {0}\n", e.TotalDuration);

        Console.ReadLine();

    }



  static  private void engine_ConversionCompleteEvent(object sender, ConversionCompleteEventArgs e)

    {

        Console.WriteLine("\n------------\nConversion complete!\n------------");

        Console.WriteLine("Bitrate: {0}", e.Bitrate);

        Console.WriteLine("Fps: {0}", e.Fps);

        Console.WriteLine("Frame: {0}", e.Frame);

        Console.WriteLine("ProcessedDuration: {0}", e.ProcessedDuration);

        Console.WriteLine("SizeKb: {0}", e.SizeKb);

        Console.WriteLine("TotalDuration: {0}\n", e.TotalDuration);

        Console.ReadLine();

    }

From: Amyn Karim Virani [mailto:[email protected]] Sent: 19 January 2017 01:13 To: AydinAdn/MediaToolkit [email protected] Cc: vijaykishans [email protected]; Comment [email protected] Subject: Re: [AydinAdn/MediaToolkit] Video to Audio ConvertProgressEvent not firing (#49)

are you using the github code or used the nuget package?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AydinAdn/MediaToolkit/issues/49#issuecomment-273579522 , or mute the thread https://github.com/notifications/unsubscribe-auth/AYClwEwnVLRcKDr7DQ6XOI8tI4-Hh8Uaks5rTmszgaJpZM4JdcTI . https://github.com/notifications/beacon/AYClwOPlglIE7V1eNF4COVdptxy58y9zks5rTmszgaJpZM4JdcTI.gif

vijaykishans avatar Jan 18 '17 19:01 vijaykishans

Hi, Am I missing something here?

regards vijay

vijaykishans avatar Jan 18 '17 20:01 vijaykishans

remove the line Console.ReadLine(); from function engine_ConversionCompleteEvent and ConvertProgressEvent

amynkvirani avatar Jan 18 '17 20:01 amynkvirani

Removed ReadLine stmts.

  1. Progress Event is working but not the engine_ConversionCompleteEvent.. On debug, it doesnot even get into the code.

Regards

Vijay

From: Amyn Karim Virani [mailto:[email protected]] Sent: 19 January 2017 01:34 To: AydinAdn/MediaToolkit [email protected] Cc: vijaykishans [email protected]; Comment [email protected] Subject: Re: [AydinAdn/MediaToolkit] Video to Audio ConvertProgressEvent not firing (#49)

remove the line Console.ReadLine(); from function engine_ConversionCompleteEvent and ConvertProgressEvent

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AydinAdn/MediaToolkit/issues/49#issuecomment-273585286 , or mute the thread https://github.com/notifications/unsubscribe-auth/AYClwKK6DSvMpAi1K4jruEKazUayZCfvks5rTnASgaJpZM4JdcTI . https://github.com/notifications/beacon/AYClwMPDhCNgaakFiCfcCDa5uYGYskYKks5rTnASgaJpZM4JdcTI.gif

vijaykishans avatar Jan 18 '17 20:01 vijaykishans

After testing it myself, I was able to reproduce the same behavior i.e. ConversionCompleteEvent is never fired. Unfortunately, after the last merge, this thing broke. So what you can do is checkout the code at the following commit and try it out.

amynkvirani avatar Jan 18 '17 21:01 amynkvirani

Thanks a lot. I will try now and let you know my results.⁣

Sent from BlueMail ​

On Jan 19, 2017, 3:09 AM, at 3:09 AM, Amyn Karim Virani [email protected] wrote:

After testing it myself, I was able to reproduce the same behavior i.e. ConversionCompleteEvent is never fired. Unfortunately, after the last merge, this thing broke. So what you can do is checkout the code at the following commit and try it out.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/AydinAdn/MediaToolkit/issues/49#issuecomment-273610034

vijaykishans avatar Jan 19 '17 03:01 vijaykishans

Hi ,

Will I lose any important feature if I use this old commit ? How do I go about that. Please suggest.

Regards

Vijay

From: Amyn Karim Virani [mailto:[email protected]] Sent: 19 January 2017 03:09 To: AydinAdn/MediaToolkit [email protected] Cc: vijaykishans [email protected]; Comment [email protected] Subject: Re: [AydinAdn/MediaToolkit] Video to Audio ConvertProgressEvent not firing (#49)

After testing it myself, I was able to reproduce the same behavior i.e. ConversionCompleteEvent is never fired. Unfortunately, after the last merge, this thing broke. So what you can do is checkout the code at the following commit https://github.com/AydinAdn/MediaToolkit/tree/0fead8a8fcc745d07e3b88952e605a068c7e5e9d and try it out.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AydinAdn/MediaToolkit/issues/49#issuecomment-273610034 , or mute the thread https://github.com/notifications/unsubscribe-auth/AYClwPLutqQ_aTbizoZzSxddf9FMYg8Jks5rToaGgaJpZM4JdcTI . https://github.com/notifications/beacon/AYClwIDoDqZGqerEz4jta0JofcXq01KHks5rToaGgaJpZM4JdcTI.gif

vijaykishans avatar Jan 19 '17 14:01 vijaykishans

I don't think that you will miss anything important. It was a stable version and should get your job done.

amynkvirani avatar Jan 19 '17 18:01 amynkvirani

The fix for this is as follows. in RegexEngine.cs in the function internal static bool IsProgressData

fps and frame are not sent in any of the examples i tried, so change your match requirements to if (!matchSize.Success || !matchTime.Success || !matchBitrate.Success) return false; As that is all we really need to monitor update progress and if for some reason we get data with fps and frame change the below too

        long frame = 0;
        double fps = 0;
        if(matchFrame.Success)
            frame = Convert.ToInt64(matchFrame.Groups[1].Value, CultureInfo.InvariantCulture);
        if (matchFps.Success)
            fps = Convert.ToDouble(matchFps.Groups[1].Value, CultureInfo.InvariantCulture);

        int sizeKb = Convert.ToInt32(matchSize.Groups[1].Value, CultureInfo.InvariantCulture);
        double bitrate = Convert.ToDouble(matchBitrate.Groups[1].Value, CultureInfo.InvariantCulture);

this works for me to update progress

ghost avatar Dec 29 '17 21:12 ghost