基于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.bat文件移动至nginx_1.7.11.3_Gryphon解压后文件夹内,双击bat,启动nginx
1.2浏览器输入:http://localhost:1234/ 若出现如下页面,恭喜你部署成功!如未出现,可能是防火墙或者端口被占用,可修改nginx_1.7.11.3_Gryphon\conf\nginx-win-rtmp.conf中的端口号。

2.FFmpeg推流至服务器
2.1推流命令示例:打开cmd,cd到nginx_1.7.11.3_Gryphon路径下 输入 ffmpeg -re -i 11.mp4 -vcodec libx264 -acodec aac -f flv rtmp://127.0.0.1:1935/live/home 并回车 。rtmp://127.0.0.1:1935/live为推流应用,home为具体流的名称,值随意,如需多个推流同时进行,只需更改home,如rtmp://127.0.0.1:1935/live/test

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 后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Vlc.DotNet.Wpf;
using System.Reflection;
using System.IO;
using Vlc.DotNet.Core; namespace LiveStreamTest
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
private VlcVideoSourceProvider sourceProvider;
public MainWindow()
{
InitializeComponent();
} private void Window_Loaded(object sender, RoutedEventArgs e)
{
var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
// Default installation path of VideoLAN.LibVLC.Windows
var libDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, "libvlc", IntPtr.Size == ? "win-x86" : "win-x64")); this.sourceProvider = new VlcVideoSourceProvider(this.Dispatcher);
this.sourceProvider.CreatePlayer(libDirectory/* pass your player parameters here */);
var mediaOptions = new[]
{
" :network-caching=2000"
};
this.sourceProvider.MediaPlayer.Play("rtmp://127.0.0.1:1935/live/home",mediaOptions);//rtmp://114.242.105.17:1935/live/test
//string file =@"D:\01_soft\rtmp\nginx_1.7.11.3_Gryphon\11.mp4";
//this.sourceProvider.MediaPlayer.Play(new FileInfo(file));//本地文件
this.sourceProvider.MediaPlayer.Log += new EventHandler<VlcMediaPlayerLogEventArgs>(MediaPlayer_Log);
this.sourceProvider.MediaPlayer.Manager.SetFullScreen(this.sourceProvider.MediaPlayer.Manager.CreateMediaPlayer(), true);
Binding bing = new Binding();
bing.Source = sourceProvider;
bing.Path = new PropertyPath("VideoSource");
img.SetBinding(Image.SourceProperty, bing);
} void MediaPlayer_Log(object sender, VlcMediaPlayerLogEventArgs e)
{
string message = "libVlc : " + e.Level + e.Message + e.Module;
System.Diagnostics.Debug.WriteLine(message);
//System.Diagnostics.Trace.WriteLine(message); } private void imgClose_MouseDown(object sender, MouseButtonEventArgs e)
{
this.Close();
Application.Current.Shutdown(); } private void imgMin_MouseDown(object sender, MouseButtonEventArgs e)
{
// WindowStateUtil.FullOrMin(this, WindowState.Minimized); }
}
}
3.3前端 只需添加 image组件即可
3.4最终效果:

基于rtmp+nginx 、vlc实现FFmpeg推流与wpf端拉流的更多相关文章
- c# 基于RTMP推流 PC+移动端 拉流播放
网上关于直播相关的文章很多,但是讲解还是不够系统,对于刚刚接触直播开发的朋友实施起来会浪费不少时间.下面结合我自己的经验, 介绍一下直播方面的实战经验. 分成两个部分 第一部分是标题中介绍的基于RTM ...
- SRS服务器搭建,ffmpeg 本地推流,srs从本地拉流
参考: https://github.com/ossrs/srs/wiki/v2_CN_SampleFFMPEG git clone https://github.com/ossrs/srs cd s ...
- 直播推流之blibli和拉流LFLiveKit
执行上面操作后,导入合成的拉流blibli包到工程中,然后新建个播放控制器来设置播放 1. 播放的一些操作. 2. 高斯模糊. 3. 新建聊天控制器. - (void)viewDidLoad { [ ...
- SRS流媒体服务器搭建+ffmpeg推流VLC取流观看
一.编译SRS https://github.com/winlinvip/simple-rtmp-server 目前有1.0-release.2.0.3.0等版本 2.0官方文档地址:https:// ...
- iOS - 直播流程,视频推流,视频拉流,简介,SMTP、RTMP、HLS、 PLPlayerKit
收藏笔记 1 . 音视频处理的一般流程: 数据采集→数据编码→数据传输(流媒体服务器) →解码数据→播放显示1.数据采集:摄像机及拾音器收集视频及音频数据,此时得到的为原始数据涉及技术或协议:摄像机: ...
- 【转】直播流程,视频推流,视频拉流,简介,SMTP、RTMP、HLS、 PLPlayerKit
原:https://www.cnblogs.com/baitongtong/p/11248966.html 1 .音视频处理的一般流程: 数据采集→数据编码→数据传输(流媒体服务器) →解码数据→播放 ...
- 利用Nginx搭建RTMP视频直播,点播服务器,ffmpeg推流,回看
一.环境和工具 ubuntu 14.04 desktop 不用server的原因是一部分的演示用到了linux视频播放和直播软件,自己还要装桌面,麻烦. 不建议使用 最新的16TLS,我一开始 ...
- iOS 直播推流 - 搭建基于RTMP的本地Nginx服务器
前端时间,公司要调研直播相关的内容,特地花时间进行了一番调研. 本篇将记录其中的推流篇-本地推理播放测试. 关于Nginx: 配置Nginx以支持HLS.RTMP的推流与拉流,iOS系统使用LFLiv ...
- 三、Windows下用FFmpeg+nginx+rtmp搭建直播环境 实现推流、拉流
一.环境 1.开发环境:windows 2.开发工具:FFmpeg.nginx.nginx-rmtp-module (链接:https://pan.baidu.com/s/119d2GeMzddas_ ...
随机推荐
- Linux—各种重要配置文件详解
一./etc/profile文件详解(环境变量) 添加环境变量 .编辑profile文件 [root@localhost ~]# vi /etc/profile .在profile文件中添加如下内容 ...
- 1. java 基本规则
一.命名规范 1. 类名规范:首字母大写,后面每个单词首字母大写(大驼峰式),HelloWorld 2. 变量名规范:首字母小写,后面每个单词首字母大写(小驼峰式),helloWorld 3. 方法名 ...
- IEEE754 浮点数
IEEE754 浮点数 1.阅读IEEE754浮点数 A,阶码是用移码表示的,这里会有一个127的偏移量,它的127相当于0,小于127时为负,大于127时为正,比如:10000001表示指数为129 ...
- 3.git 远程
首次拉取代码的话.可以使用 git clone 这个指令 git clone https://github.com/guohongze/adminset.git 带密码方式 git clone htt ...
- 《深度学习》圣经"花书"经验法则中文版!
作者:Jeff Macaluso https://jeffmacaluso.github.io/post/DeepLearningRulesOfThumb/ 转自CVer,仅用作个人学习 当我在研究生 ...
- appium Ui自动化调起应用点击
appium Ui自动化调起微信并点击登录按钮的java代码(对的,就这么一丢丢). public class testWX { public static void main(String[] ar ...
- (day52)四、视图层、模板层
目录 一.视图层 (一)Request和Response对象 (1)Request对象 (2)Response对象 (二)JsonResponse对象 (1)前后端分离 (2)json_dumps_p ...
- git--配置文件、.gitignore
配置文件 git给我们提供了三种配置文件的方法,一种是项目配置文件,一种是全局配置文件,还有一种是系统配置文件. 在我们第一次使用git commit提交代码的时候,git让我们配置用户名和邮箱 全局 ...
- Python入门基础学习记录(二)汇率案例学习记录
一.汇总整理 1.操作 ①新建python文件 工程右键--new--python file 2.注意问题与知识点 >变量定义:直接写变量名即可,例如定义一个字符串并赋值123: rmb_str ...
- html-加水印--watermark--代码测试
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...