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

Conversion starts but will not complete - UWP app

Open jjouppi opened this issue 4 years ago • 4 comments

Hey!

Thanks for all your work creating this. Trying to use Xabe.FFmpeg for some simple file conversions in a UWP media player. Basically just want to be able to convert a wide range of video file types to an mp4.

Currently, when I use Xabe.FFmpeg it seems like the conversion may start since the app hangs but does not complete. I'm not getting errors just app hanging and the conversion not completing. I'm using code based off the basic conversion sample in the repository:

private async void FileOpen_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            FileOpenPicker filePicker = new FileOpenPicker();
            filePicker.ViewMode = PickerViewMode.Thumbnail;
            filePicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
            filePicker.FileTypeFilter.Add("*");

            // Show file picker so user can select a file
            var file = await filePicker.PickSingleFileAsync();

            Console.Out.WriteLine("[Start] Basic Conversion");
            var fileToConvert = file.Path.ToString();
            //Set directory where app should look for FFmpeg executables.
            var ffmpegFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
            await FFmpegDownloader.GetLatestVersion(FFmpegVersion.Official, ffmpegFolder.Path.ToString());
            FFmpeg.SetExecutablesPath(ffmpegFolder.Path.ToString());

            await RunConversion(fileToConvert);

            Console.Out.WriteLine("[End] Basic Conversion");
        }

        private static async Task RunConversion(string fileToConvert)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation =
            Windows.Storage.Pickers.PickerLocationId.VideosLibrary;

            savePicker.DefaultFileExtension = ".mp4";
            savePicker.SuggestedFileName = "New Video";

            savePicker.FileTypeChoices.Add("MPEG4", new string[] { ".mp4" });

            StorageFile saveLocation = await savePicker.PickSaveFileAsync();

            //Save file to the same location with changed extension
            string outputFileName = saveLocation.Path.ToString();

            var conversion = await FFmpeg.Conversions.FromSnippet.ToMp4(fileToConvert, outputFileName);
            await conversion.Start();

        }

Any ideas as to what I'm doing wrong? Thanks for any help you can provide!

jjouppi avatar Aug 05 '20 18:08 jjouppi

Hey @jjouppi,

Can you try on different file and conversion parameters? Maybe there is something wrong with parameters. You could try to run conversion with the same parameters copying Arguments from conversion.

BTW if it's a desktop application there is a possibility of deadlock.

tomaszzmuda avatar Aug 05 '20 19:08 tomaszzmuda

Hey!

Thanks for getting back to me. Yeah I'm not too clear on how to provide input parameters. Are there any examples around I can start looking over?

Here's the exception info I'm getting back from ffmpeg: image

Yeah it is a desktop application specifically a media player for Windows and I'm hoping to add some simple transcoding features but need to be able to convert a wide range of formats. Will definitely be licensing it if I can get this to work. If Xabe ffmpeg isn't a good option for this use case is there something else you would recommend?

Thanks!

jjouppi avatar Aug 15 '20 16:08 jjouppi

When you got an ConversionException, look on InputParameters property and paste what is there. image

You are getting an error on code you previously pasted here? Did something change? To resolve this issue I need to look full log from FFmpeg (valuable information should be visible a few lines after that what you pasted). It would be nice if you paste up to date code base.

Xabe.FFmpeg was created for this case so I don't think you will have to look on different libraries :)

tomaszzmuda avatar Aug 16 '20 10:08 tomaszzmuda

It doesn't look like you can launch exe files from UWP. From this SO answer it looks like the exe has to be part of the package itself or called via a special UWP runtime method. So I don't think the downloader will work for UWP.

06needhamt avatar Aug 31 '20 17:08 06needhamt