这周在研究基于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. JAVA基础复习(重点)

    一. 初识Java编程 1.           Java开发环境 JDK Java开发工具 JVM Java虚拟机 JRE Java运行环境 2.实现第一个hello world public cl ...

  2. nginx高级用法

    功能 说明 配置语法 配置位置 配置举例 结果验证 备注 rewrite 跳转重定向(不同于代理的跳转重定向,此处nginx不是代理服务器,而是本身就是web服务器) rewrite 正则表达式 re ...

  3. golang数据结构和算法之StackArray数组堆栈

    用数组实现的堆栈, 另一种,是用链表实现的堆栈, 在各种不同的编程语言上, 实现都是类似的. StackArray.go package StackArray //基于数组实现的堆栈 const ar ...

  4. 攻防世界pwn之新手区

    涉及的工具有 Ubuntu 16.04 pwntools IDA gdb-peda 1.get_shell 连接就给flag,可以直接用nc连接,然后输入ls查看里面的目录,发现有名字叫flag文件, ...

  5. Anomaly Detection

    数据集中的异常数据通常被成为异常点.离群点或孤立点等,典型特征是这些数据的特征或规则与大多数数据不一致,呈现出“异常”的特点,而检测这些数据的方法被称为异常检测. 异常数据根据原始数据集的不同可以分为 ...

  6. 冒泡排序法(C语言)

    冒泡排序(Bubble Sort)一种计算机科学领域的较简单的排序算法.它重复地走访过要排序的元素列,依次比较两个相邻的元素,如果顺序(如从大到小.首字母从从Z到A)错误就把他们交换过来.走访元素的工 ...

  7. javaagent的实现

    实现javaagent功能的是一个叫做instrument的JVMTIAgent(linux下对应的动态库是libinstrument.so),另外instrument agent还有个别名叫JPLI ...

  8. centos的key登录,关闭密码登录

    1.删除机器原有的key rm -rf /root/.ssh 2.创建key[root@rain ~]# ssh-keygen -t rsa一路回车 3.改名[root@rain ~]# mv /ro ...

  9. [2019BUAA软工助教]下半学期改进计划

    [2019BUAA软工助教]下半学期改进计划 结合[2019BUAA软工助教]答黄衫同学,经过26日晚陈彦吉.刘畅.赵奕.李庆想四位助教的讨论,最终整理了以下这份计划 一.技术博客 各个团队在开发的过 ...

  10. 图片转PDF

    目的:图片转pdf(image2pdf)依赖:fpdf.php 网址 为 http://fpdf.org/ 有文档和包 demo:step 1 : First download fpdf librar ...