Closed lrohrmann closed 5 months ago
There are overloads which takes a property set to pass special parameters to ffmpeg. If that doesn't work, then we will need a special implementation for it.
I have tried to add it to the ffmpeg config options list in this way:
FFmpegOptions = new Windows.Foundation.Collections.PropertySet {
{ "an", 1 }
...
But this hasn't any effect. Can you tell me the way to do it with overloads, then I will test it.
Thanks!
You need to pass that MediaSourceConfig with ffmpeg options you want in the CreateFromStream or CreateFromUri methods. Setting those afterwards will not have an effect in this case.
I have passed it in CreateFromUri, here is the relevant code part:
Config.FFmpegOptions["timeout"] = 5000000;
Config.FFmpegOptions["reconnect"] = 1;
Config.FFmpegOptions["reconnect_streamed"] = 1;
Config.FFmpegOptions["reconnect_on_network_error"] = 1;
Config.FFmpegOptions["max_delay"] = 500;
Config.FFmpegOptions["an"] = 1;
Task.Run(async () =>
{
try
{
FFmpegMSS = await FFmpegMediaSource.CreateFromUriAsync(sourceUri.AbsoluteUri, Config);
var playBackItem = FFmpegMSS.CreateMediaPlaybackItem();
MediaPlayer.Source = playBackItem;
MediaPlayer.Volume = 0;
MediaPlayer.IsMuted = true;
MediaPlayer.CommandManager.IsEnabled = false;
MediaPlayer.Play();
}
catch (Exception ex)
{
isPlaying = false;
log.Error($"Error in FFmpegCamera.Play Task.Run DebugId {debugId}", ex);
}
}).Wait();
But if I don't mute the MediaPlayer the Audio is still present.
If you set the SelectedIndex of MediaPlaybackItem AudioTracks property to - 1, does it fix the issue? I suspect MediaPlayer will forcefully select the first stream on media open, but if you set AutoPlay to false, you will be able to set the selected audio stream before playback starts.
When I try to set SelectedIndex of MediaPlaybackItem AudioTracks property to -1 I get an exception "Value does not fall within the expected range." But also I can see that the SelectedIndex is allready set to -1 after CreateMediaPlaybackItem().
Alright, this will require some new development. I will think of how this can be done.
I think I have found another solutiuon for this.
Adding Config.FFmpegOptions["allowed_media_types"] = "video";
seems to fix the issue. But maybe your exclude filter improvement is also helpful for other use cases.
Thank you for sharing the solution. Much appreciated.
Hello,
I'm not sure if it is possible or not: I'm playing a rtsp stream and searching for a way to remove the audio track from it. With ffmpeg it seems to be the -an parameter to remove all audio, but I can't find a way to pass this parameter with FmpegInteropX and also I cant find another way to do this. Currently I just mute the mediaplayer, butthis feels more like a kind of workaround.
Does anybody have an idea how to solve this in the right way?
Thanks and best regards Lorenz