Xabe.FFmpeg icon indicating copy to clipboard operation
Xabe.FFmpeg copied to clipboard

Snapshot not working

Open dharmeshsharma opened this issue 4 years ago • 5 comments

I have simple use of lib but not getting snapshot in windows and ubuntu.

using System;
using System.IO;
using System.Threading.Tasks;
using Xabe.FFmpeg;

namespace ConsoleApp1
{
    class Program
    {
        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            await Thumbnail(@"E:\tmp\Upload\Video\2256\1f77d136-7aad-49ff-9464-2b9e2be9d5d2.mp4", @"E:\tmp\Upload\Video\2256\1f77d136-7aad-49ff-9464-2b9e2be9d5d2.jpg");
        }

        static async Task Thumbnail(string inputpath, string output)
        {
           
            string path = Path.Combine(System.IO.Directory.GetCurrentDirectory(), "FFmpeg");
            FFmpeg.SetExecutablesPath(path);
            await FFmpeg.Conversions.FromSnippet.Snapshot(inputpath, output, TimeSpan.FromSeconds(0));

        }
    }
}

I have tested in AWS lambda also.

dharmeshsharma avatar Sep 18 '20 19:09 dharmeshsharma

Hello,

Do you get any exceptions or errors? What "not working" mean?

tomaszzmuda avatar Sep 29 '20 15:09 tomaszzmuda

I am not getting any exception

dharmeshsharma avatar Sep 30 '20 13:09 dharmeshsharma

So the application freeze? Did nothing happen?

tomaszzmuda avatar Oct 03 '20 13:10 tomaszzmuda

NO its just complete the execution without any problem but i didn't get snapshot

dharmeshsharma avatar Oct 13 '20 13:10 dharmeshsharma

It's really hard to tell what's going on. Did you try to run unit tests from this repository? Can you do that? Are you sure that .mp4 file is correct?

Conversion result has property named Arguments. Can you paste it to ffmpeg in console? You will get extended log. Please share it here. image

tomaszzmuda avatar Oct 14 '20 17:10 tomaszzmuda

same problem. no output file

deadman2000 avatar Oct 26 '22 14:10 deadman2000

Reviving this as i just had the same problem & could get it solved for my case.

Solution: Use separate threads when running conversions with this library.

In most parts of the code GetAwaiter().GetResult() is used instead of async-await. This leads to deadlocks if the method is run on the main thread (like ui thread on a windows form), even if is run with async-await. See https://stackoverflow.com/questions/39007006/is-getawaiter-getresult-safe-for-general-use

@tomaszzmuda Is there a reason why this library uses GetAwaiter().GetResult() instead of making the methods async and using await?

frknakk avatar Jan 22 '23 23:01 frknakk