这周在研究基于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端拉流的更多相关文章

  1. c# 基于RTMP推流 PC+移动端 拉流播放

    网上关于直播相关的文章很多,但是讲解还是不够系统,对于刚刚接触直播开发的朋友实施起来会浪费不少时间.下面结合我自己的经验, 介绍一下直播方面的实战经验. 分成两个部分 第一部分是标题中介绍的基于RTM ...

  2. SRS服务器搭建,ffmpeg 本地推流,srs从本地拉流

    参考: https://github.com/ossrs/srs/wiki/v2_CN_SampleFFMPEG git clone https://github.com/ossrs/srs cd s ...

  3. 直播推流之blibli和拉流LFLiveKit

    执行上面操作后,导入合成的拉流blibli包到工程中,然后新建个播放控制器来设置播放 1.  播放的一些操作. 2. 高斯模糊. 3. 新建聊天控制器. - (void)viewDidLoad { [ ...

  4. SRS流媒体服务器搭建+ffmpeg推流VLC取流观看

    一.编译SRS https://github.com/winlinvip/simple-rtmp-server 目前有1.0-release.2.0.3.0等版本 2.0官方文档地址:https:// ...

  5. iOS - 直播流程,视频推流,视频拉流,简介,SMTP、RTMP、HLS、 PLPlayerKit

    收藏笔记 1 . 音视频处理的一般流程: 数据采集→数据编码→数据传输(流媒体服务器) →解码数据→播放显示1.数据采集:摄像机及拾音器收集视频及音频数据,此时得到的为原始数据涉及技术或协议:摄像机: ...

  6. 【转】直播流程,视频推流,视频拉流,简介,SMTP、RTMP、HLS、 PLPlayerKit

    原:https://www.cnblogs.com/baitongtong/p/11248966.html 1 .音视频处理的一般流程: 数据采集→数据编码→数据传输(流媒体服务器) →解码数据→播放 ...

  7. 利用Nginx搭建RTMP视频直播,点播服务器,ffmpeg推流,回看

        一.环境和工具 ubuntu 14.04 desktop 不用server的原因是一部分的演示用到了linux视频播放和直播软件,自己还要装桌面,麻烦. 不建议使用 最新的16TLS,我一开始 ...

  8. iOS 直播推流 - 搭建基于RTMP的本地Nginx服务器

    前端时间,公司要调研直播相关的内容,特地花时间进行了一番调研. 本篇将记录其中的推流篇-本地推理播放测试. 关于Nginx: 配置Nginx以支持HLS.RTMP的推流与拉流,iOS系统使用LFLiv ...

  9. 三、Windows下用FFmpeg+nginx+rtmp搭建直播环境 实现推流、拉流

    一.环境 1.开发环境:windows 2.开发工具:FFmpeg.nginx.nginx-rmtp-module (链接:https://pan.baidu.com/s/119d2GeMzddas_ ...

随机推荐

  1. docker部署gitlab-ce

    简介 环境准备 centos7 docker 1.13.1 gitlab-ce 安装步骤 1.首先需要从docker镜像仓库当中获取gitlab-ce的最新镜像文件,由于我本机已经获取了该镜像,所以在 ...

  2. Flask—好的博客

    https://www.cnblogs.com/cwp-bg/p/8892403.html https://www.cnblogs.com/ExMan/p/9825710.html https://w ...

  3. NOIP 2011 计算系数

    洛谷 P1313 计算系数 洛谷传送门 JDOJ 1747: [NOIP2011]计算系数 D2 T1 JDOJ传送门 Description 给定一个多项式(ax + by)k,请求出多项式展开后x ...

  4. Vue 使用lodash库减少watch对后台请求压力

    lodash需要新引入 我使用的是npm方式 使用lodash的_.debounce方法 具体代码: <!doctype html> <html lang="en" ...

  5. gradle是什么

    Gradle是JVM生态下又一款开源的自动化构建工具,以基于Groovy的DSL描述构建过程,在结合了ant和maven的优点的基础上,提供了更为简洁,灵活和高效的build体验. Task代表了构建 ...

  6. spring cloud 与spring boot 版本不匹配引发的问题总结

    为了将前期项目慢慢转移到微服务上,今天开始搭建eureka服务时,出现以下错误: org.springframework.context.ApplicationContextException: Un ...

  7. docker 更新内存限制步骤

    停止容器: docker stop id 更新配额: docker update -m 80G id 内存参数和大小 容器ID重启容器:docker start id

  8. telnet: Unable to connect to remote host: Connection refused

    问题描述: telnet: Unable to connect to remote host: Connection refused 已解决,需要安装telent 服务,请查看下方的链接文章: htt ...

  9. Elasticsearch搜索调优权威指南 (1/3)

    本文首发于 vivo互联网技术 微信公众号 https://mp.weixin.qq.com/s/qwkZKLb_ghmlwrqMkqlb7Q英文原文:https://qbox.io/blog/ela ...

  10. 如何保障MySQL主从复制关系的稳定性?关键词(新特性、crash-safe)

    一 前言 MySQL 主从架构已经被广泛应用,保障主从复制关系的稳定性是大家一直关注的焦点.MySQL 5.6 针对主从复制稳定性提供了新特性: slave 支持 crash-safe.该功能可以解决 ...