繁体   English   中英

媒体元素显示 H264 比特流 [UWP]

[英]Media Element Display H264 bitstream [UWP]

我正在开发一个应该播放流媒体视频的应用程序

我正在尝试在MediaElement播放 h264 流视频,但 MediaElement 仍然为空

我使用FFmpeg作为视频源

ffmpeg -r 20   -f gdigrab   -i desktop   -f mpegts  -vcodec libx264 udp://127.0.0.1:5555 

在客户端 ( UWP ) 我使用FFmpegInterop库正确检测到视频的编解码器和分辨率,但MediaElement不播放任何内容

我也试过使用 MJPEG,例如

ffmpeg -r 20 -f gdigrab -i desktop -f mjpeg -vcodec mjpeg udp://127.0.0.1:5555

一切正常。 RTSP流也适用,例如来自OBS studio ,在这种情况下,编解码器定义为 h264

原来问题只能出在发射端? 是否可以为此目的仅使用 UDP 协议? 也许我错过了一些 FFmpeg 设置?

 private async void MediaPlayer_Loaded(object sender, RoutedEventArgs e)
    {
            MediaPlayer.Loaded -= MediaPlayer_Loaded;

            FFmpegInteropLogging.SetDefaultLogProvider();
            FFmpegInteropConfig options = new FFmpegInteropConfig();
            options.PassthroughVideoH264 = true;
            options.SkipErrors = 1000;
            options.PassthroughVideoHEVC = true;
            options.PassthroughVideoH264Hi10P = true;
           decoder = awaitFFmpegInteropMSS.CreateFromUriAsync("udp://127.0.0.1:5555",options);

            var mediaStreamSource = decoder.GetMediaStreamSource();
            mediaStreamSource.BufferTime = TimeSpan.FromSeconds(0);
            Debug.WriteLine(decoder.VideoStream.CodecName);

            MediaPlayer.MediaFailed += MediaPlayer_MediaFailed;
            MediaPlayer.SetMediaStreamSource(mediaStreamSource);
            MediaPlayer.Play();
}

设置属性 VideoDecoderMode = VideoDecoderMode.ForceFFmpegSoftwareDecoder 解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM