问题
I need to convert an mp4 (or any other video format) to mp3 or wav file. I am using C# Xamarin.Forms. Any library I used either doesn't work for me, or isn't compatible with android. I have tried using Xamarin.Android.FFMpeg and Xobe.FFMpeg. I repost this because it was marked as duplicate and I clearly stated that that solution isn't working for me. This is the post that was flagged as duplicate: How can I extract the audio out of a video file? (android) . Please, I tried it but it just gives me the "Downloading Video Converter" dialog with a progress bar when I try to run the code in the solution, Also, it doesn't even extract the audio so after the user waits such a long time, it turned out as a waste of time. Thanks in advance! :)
EDIT 1:
This is the code I am using:
private async Task<string> ExtractAudioAsync(string path, Action<string> logger = null,
Action<int, int> onProgress = null)
{
List<string> cmd = new List<string>();
cmd.Add("-i");
cmd.Add(path + ".mp4");
cmd.Add("-vn");
cmd.Add("-acodec");
cmd.Add("copy");
cmd.Add(path + ".mp3");
string cmdParams = string.Join(' ', cmd);
await FFMpeg.Xamarin.FFMpegLibrary.Run(Context, cmdParams);
return path + ".mp3";
}
There are no exceptions thrown. When the Run method is called it just shows on the application the following dialog:
After that, it just closes the dialog and goes to the return line without even extracting the audio out of the video. Even if I run this code again it does the same thing, downloading it again.
EDIT 2:
I tried adding the -report
option but it just did the same thing and did not save any log file. Am I doing something wrong?
来源:https://stackoverflow.com/questions/60576932/problem-with-extracting-audio-from-a-video-file-android