基于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_ ...
随机推荐
- SparkStreaming 整合kafka Demo
这里使用的是低级API,因为高级API非常不好用,需要繁琐的配置,也不够自动化,却和低级API的效果一样,所以这里以低级API做演示 你得有zookeeper和kafka 我这里是3台节点主机 架构图 ...
- 什么是技术规划(TPP)?
什么是技术? 1.技,巧也. ——<说文> 2.为了人类的目的而操纵自然世界的工具.机器.系统和技巧的集合. ——梅里特·罗·史密斯 3.人类都在利用自然和改造自然的过程中积累起来并在生产 ...
- [20190522]DISABLE TABLE LOCK.txt
[20190522]DISABLE TABLE LOCK.txt --//如果禁止table lock时,一些ddl操作会被禁止.但是我有点吃惊的是增加字段不受限制.--//通过测试说明问题. 1.环 ...
- 【转载】Kafka史上最详细原理总结
Kafka是最初由Linkedin公司开发,是一个分布式.支持分区的(partition).多副本的(replica),基于zookeeper协调的分布式消息系统,它的最大的特性就是可以实时的处理大量 ...
- jira Licenses更新步骤
有时候我们不想花钱使用jira,那么只有通过一个月以续期的方式来使用jira.下面提供下自己实测的方式 1.获取License Key 登录地址:https://my.atlassian.com 登录 ...
- Oracle 导入dmp 故障存储文件
创建表空间及用户CREATE TABLESPACE OracleDBFDATAFILE 'D:\app\zhoulx\oradata\bdc\OracleDBF.DBF' SIZE 100M AUTO ...
- 不能聚焦元素问题 WebDriverException: Message: unknown error: cannot focus element
上周碰到了 Unable to locate element,即“无法定位元素”,后靠两行代码解决: wait = ui.WebDriverWait(driver,5) wait.until(lamb ...
- 6.GC垃圾回收算法和垃圾收集器的关系
JAVAGC垃圾回收机制和常见垃圾回收算法 推荐博客:JVM垃圾回收机制和常见垃圾回收算法 JVM的内存结构.垃圾回收算法
- 【cf915】E. Physical Education Lessons(线段树)
传送门 简单的线段树区间修改区间查询,但是因为数据范围过大,所以采用动态开点的方法(注意一下空间问题). 也可以直接对询问区间的端点离散化然后建树,这种方法时间复杂度和空间复杂度都比较优秀. 给出动态 ...
- 6.web3
http://123.206.87.240:8002/web3/