Xabe.FFmpeg
Xabe.FFmpeg copied to clipboard
Conversion starts but will not complete - UWP app
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!
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.
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:
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!
When you got an ConversionException, look on InputParameters property and paste what is there.
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 :)
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.