RTMP + nginxの基に、VLCのFFmpegはプルエンドWPFでプラグフローストリームを達成します

次のように今週の研究ベースのRTMPライブストリーミング実現+ nginxのは、要約されています:

0必要書類:

リンクします。https://pan.baidu.com/s/1U5gsNI8Rcl684l5gVL6swgの
抽出コード:dli9 

1.nginxの展開

1.1 nginx_1.7.11.3_Gryphon.zip解凍、nginxのを起動し、バットをダブルクリックし、nginx_1.7.11.3_Gryphonフォルダの後に解凍したファイルを移動nginx.bat開始

1.2ブラウザは、入力します。http:// localhost:1234 /以下のページが表示された場合は、お使いの展開を成功おめでとうございます!表示されていない場合は、ファイアウォールまたはポートが占有されているかもしれ、あなたは内nginx_1.7.11.3_Gryphon \ confに\ポート番号のnginx-WIN-rtmp.confを変更することができます。

 

2.FFmpegにストリーミングサーバ

例2.1プラグフローコマンド:オープンCMD、入力ffmpegの-re -i 11.mp4 -vcodec libx264 -acodec AAC -f FLV パスnginx_1.7.11.3_Gryphonのにcd RTMP://127.0.0.1:1935 /ライブ/家と入力します。RTMP://127.0.0.1:1935 /ライブストリーミングアプリケーションプッシュされ、特定のホーム・ストリーム、ランダムな値、同時にストリームのためにプッシュする複数の、ちょうどRTMPなど、ホームの変更の名前://127.0.0.1:1935 /ライブ/テスト

 

3.WPFエンド統合プルストリームVLC

3.1  项目里先添加Vlc.DotNet.Core.dll,Vlc.DotNet.Core.Interops.dll,Vlc.DotNet.Wpf.dll,可直接用我的 .net4.0版本,亦可下载源码自己编译(https://github.com/ZeBobo5/Vlc.DotNet   需用vs2017及以上编译)并在xaml中添加xmlns:local="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"引用,将libvlc解压至wpf生成路径下,libvlc包含必须的解码库文件及插件

 

3.2 后台代码:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Windows;
 6 using System.Windows.Controls;
 7 using System.Windows.Data;
 8 using System.Windows.Documents;
 9 using System.Windows.Input;
10 using System.Windows.Media;
11 using System.Windows.Media.Imaging;
12 using System.Windows.Navigation;
13 using System.Windows.Shapes;
14 using Vlc.DotNet.Wpf;
15 using System.Reflection;
16 using System.IO;
17 using Vlc.DotNet.Core;
18 
19 namespace LiveStreamTest
20 {
21     /// <summary>
22     /// MainWindow.xaml 的交互逻辑
23     /// </summary>
24     public partial class MainWindow : Window
25     {
26         private VlcVideoSourceProvider sourceProvider;
27         public MainWindow()
28         {
29             InitializeComponent();
30         }
31 
32         private void Window_Loaded(object sender, RoutedEventArgs e)
33         {
34             var currentAssembly = Assembly.GetEntryAssembly();
35             var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
36             // Default installation path of VideoLAN.LibVLC.Windows
37             var libDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
38 
39             this.sourceProvider = new VlcVideoSourceProvider(this.Dispatcher);
40             this.sourceProvider.CreatePlayer(libDirectory/* pass your player parameters here */);
41             var mediaOptions = new[]
42                 {                    
43                     " :network-caching=2000"
44                 };
45             this.sourceProvider.MediaPlayer.Play("rtmp://127.0.0.1:1935/live/home",mediaOptions);//rtmp://114.242.105.17:1935/live/test
46             //string file =@"D:\01_soft\rtmp\nginx_1.7.11.3_Gryphon\11.mp4";
47             //this.sourceProvider.MediaPlayer.Play(new FileInfo(file));//本地文件
48             this.sourceProvider.MediaPlayer.Log += new EventHandler<VlcMediaPlayerLogEventArgs>(MediaPlayer_Log);
49             this.sourceProvider.MediaPlayer.Manager.SetFullScreen(this.sourceProvider.MediaPlayer.Manager.CreateMediaPlayer(), true);
50             Binding bing = new Binding();
51             bing.Source = sourceProvider;
52             bing.Path = new PropertyPath("VideoSource");
53             img.SetBinding(Image.SourceProperty, bing);
54         }
55 
56         void MediaPlayer_Log(object sender, VlcMediaPlayerLogEventArgs e)
57         {
58             string message = "libVlc : " + e.Level + e.Message + e.Module;
59             System.Diagnostics.Debug.WriteLine(message);
60             //System.Diagnostics.Trace.WriteLine(message);
61             
62         }
63 
64         private void imgClose_MouseDown(object sender, MouseButtonEventArgs e)
65         {
66             this.Close();
67             Application.Current.Shutdown();
68 
69         }
70 
71         private void imgMin_MouseDown(object sender, MouseButtonEventArgs e)
72         {
73            // WindowStateUtil.FullOrMin(this, WindowState.Minimized);
74 
75         }
76     }
77 }
View Code

3.3前端 只需添加 image组件即可

3.4最终效果:

 

おすすめ

転載: www.cnblogs.com/giserlong88/p/11244779.html