、 为何要使用HTTP Live Streaming

可以参考wikipedia

HTTP Live Streaming(缩写是 HLS)是一个由苹果公司提出的基于HTTP的流媒体 网络传输协议。是苹果公司QuickTime X和iPhone软件系统的一部分。它的工作原理是把整个流分成一个个小的基于HTTP的文件来下载,每次只下载一些。当媒体流正在播放时,客户端可以选择从许多不同的备用源中以不同的速率下载同样的资源,允许流媒体会话适应不同的数据速率。在开始一个流媒体会话时,客户端会下载一个包含元数据的extended M3U (m3u8) playlist文件,用于寻找可用的媒体流。

HLS只请求基本的HTTP报文,与实时传输协议(RTP)不同,HLS可以穿过任何允许HTTP数据通过的防火墙或者代理服务器。它也很容易使用内容分发网络来传输媒体流。

2、 HTTP Live Streaming技术方案

HTTP服务:使用Nginx提供HTTP服务,通过使用nginx-rtmp-module https://github.com/arut/nginx-rtmp-module 来增加对HLS的支持

使用ffmpeg来完成对flv、mp4、mp3等格式的转化,使用ffmpeg或segmenter完成对视频/音频格式文件的切割,切割为m3u8格式及ts文件

3、 准备工作

操作系统CentOS

3.1、准备安装删除已安装包

yum erase ffmpeg x264 x264-devel

3.2、安装各种依赖包

yum install gcc make nasm pkgconfig wget curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64 pcre.i386 pcre.x86_64 pcre-devel.i386 pcre-devel.x86_64

3.3、安装git

wget -O git-devel.zip https://github.com/msysgit/git/archive/devel.zip

unzip git-devel.zip

cd git-devel/

autoconf

./configure

make

make install

3.4、创建安装包目录

mkdir ~/ffmpeg-source

4、 安装ffmpeg及其依赖包

4.1、Yasm

cd ~/ffmpeg-source

wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz

tar xzvf yasm-1.2.0.tar.gz

cd yasm-1.2.0

./configure

make

make install

4.2、x264

cd ~/ffmpeg-source

git clone git://git.videolan.org/x264

cd x264

./configure –enable-shared

make

make install

4.3、LAME

cd ~/ffmpeg-source

wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz

tar xzvf lame-3.99.5.tar.gz

cd lame-3.99.5

./configure –enable-nasm

make

make install

4.4、libogg

cd ~/ffmpeg-source

wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz

tar xzvf libogg-1.3.0.tar.gz

cd libogg-1.3.0

./configure

make

make install

4.5、libvorbis

cd ~/ffmpeg-source

wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz

tar xzvf libvorbis-1.3.3.tar.gz

cd libvorbis-1.3.3

./configure

make

make install

4.6、libvpx

cd ~/ffmpeg-source

git clone http://git.chromium.org/webm/libvpx.git

cd libvpx

./configure –enable-shared

make

make install

4.7、 FAAD2

cd ~/ffmpeg-source

wget http://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz

tar zxvf faad2-2.7.tar.gz

cd faad2-2.7

./configure

make

make install

4.8、FAAC

cd ~/ffmpeg-source

wget http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz

tar zxvf faac-1.28.tar.gz

cd faac-1.28

./configure

make

make install

4.9、Xvid

cd ~/ffmpeg-source

wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz

tar zxvf xvidcore-1.3.2.tar.gz

cd xvidcore/build/generic

./configure

make

make install

4.10、FFmpeg

cd ~/ffmpeg-source

git clone git://source.ffmpeg.org/ffmpeg

cd ffmpeg

./configure –enable-version3 –enable-libvpx –enable-libfaac –enable-libmp3lame –enable-libvorbis –enable-libx264 –enable-libxvid –enable-shared –enable-gpl –enable-postproc –enable-nonfree –enable-avfilter –enable-pthreads

PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
./configure \
  --prefix="$HOME/ffmpeg_build" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --enable-version3 \
  --enable-pthreads \
  --enable-avfilter \
  --enable-nonfree \
  --enable-gpl \
  --enable-libx264 \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libxvid \
  --enable-shared \
  --enable-postproc \
  --enable-debug=3 \
  --disable-optimizations \
  --disable-asm \
  --disable-stripping

make

make install

ldconfig –v

5、 安装nginx及nginx-rtmp-module

  • mkdir ~/nginx-source
  • cd  ~/nginx-source
  • wget http://nginx.org/download/nginx-1.2.4.tar.gz
  • tar zxvf nginx-1.2.4.tar.gz
  • wget -O nginx-rtmp-module.zip  https://github.com/arut/nginx-rtmp-module/archive/master.zip
  • unzip nginx-rtmp-module.zip
  • wget -O ngx_cache_purge.zip https://github.com/FRiCKLE/ngx_cache_purge/archive/master.zip
  • unzip ngx_cache_purge.zip
  • cd nginx-1.2.4
  • ./configure –user=daemon –group=daemon –prefix=/usr/local/nginx-1.2.4/ –add-module=../nginx-rtmp-module-master –add-module=../nginx-rtmp-module-master/hls –add-module=../ngx_cache_purge-master  –with-http_stub_status_module –with-http_ssl_module –with-http_sub_module –with-md5=/usr/lib –with-sha1=/usr/lib –with-http_gzip_static_module
  • :./configuer --user=root --group=root --prefix=/usr/local/nginx-1.9.9/ --add-module=../nginx-rtmp-module/nginx-rtmp-module --add-module=../ngx_cache_purge-master --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-md5=/usr/lib --with-sha1=/usr/lib --with-http_gzip_static_module
  • 在nginx.conf中增加rtmp模块的相关配置,配置例子

由于我们需要播放m3u8,ts类型的文件,所以要在nginx的conf/mime.types文件中加入

1
2
application/x-mpegURL                 m3u8;
video/MP2T                            ts;

参考http://yaocoder.blog.51cto.com/2668309/1435771/

  • daemon  on; master_process  off; #user  nobody; worker_processes  1; #error_log  logs/error.log; #error_log  logs/error.log  notice; #error_log  logs/error.log  info; #pid        logs/nginx.pid; events { worker_connections  1024; } rtmp { server { listen 1935; chunk_size 4000; # TV mode: one publisher, many subscribers application mytv { # enable live streaming live on; # record first 1K of stream record all; record_path /tmp/av; record_max_size 1K; # append current timestamp to each flv record_unique on; # publish only from localhost allow publish 127.0.0.1; deny publish all; #allow play all; } # Transcoding (ffmpeg needed) application big { live on; # On every pusblished stream run this command (ffmpeg) # with substitutions: $app/${app}, $name/${name} for application & stream name. # # This ffmpeg call receives stream from this application & # reduces the resolution down to 32×32. The stream is the published to # ‘small’ application (see below) under the same name. # # ffmpeg can do anything with the stream like video/audio # transcoding, resizing, altering container/codec params etc # # Multiple exec lines can be specified. exec /usr/local/bin/ffmpeg -re -i rtmp://localhost:1935/$app/$name -vcodec flv -acodec copy -s 32×32 -f flv rtmp://localhost:1935/small/${name}; } application small { live on; # Video with reduced resolution comes here from ffmpeg } application mypush { live on; # Every stream published here # is automatically pushed to # these two machines #push rtmp1.example.com; #push rtmp2.example.com:1934; } application mypull { live on; # Pull all streams from remote machine # and play locally #pull rtmp://rtmp3.example.com pageUrl=www.example.com/index.html; } # video on demand application vod { play /var/flvs; } application vod2 { play /var/mp4s; } # Many publishers, many subscribers # no checks, no recording application videochat { live on; # The following notifications receive all # the session variables as well as # particular call arguments in HTTP POST # request # Make HTTP request & use HTTP retcode # to decide whether to allow publishing # from this connection or not on_publish http://localhost:8080/publish; # Same with playing on_play http://localhost:8080/play; # Publish/play end (repeats on disconnect) on_done http://localhost:8080/done; # All above mentioned notifications receive # standard connect() arguments as well as # play/publish ones. If any arguments are sent # with GET-style syntax to play & publish # these are also included. # Example URL: #   rtmp://localhost/myapp/mystream?a=b&c=d # record 10 video keyframes (no audio) every 2 minutes record keyframes; record_path /var/vc; record_max_frames 10; record_interval 2m; # Async notify about an flv recorded on_record_done http://localhost:8080/record_done; } # HLS # HLS requires libavformat & should be configured as a separate # NGINX module in addition to nginx-rtmp-module: # ./configure … –add-module=/path/to/nginx-rtmp-module/hls … # For HLS to work please create a directory in tmpfs (/tmp/app here) # for the fragments. The directory contents is served via HTTP (see # http{} section in config) # # Incoming stream must be in H264/AAC/MP3. For iPhones use baseline H264 # profile (see ffmpeg example). # This example creates RTMP stream from movie ready for HLS: # # ffmpeg -loglevel verbose -re -i movie.avi  -vcodec libx264 #    -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 #    -f flv rtmp://localhost:1935/hls/movie # # If you need to transcode live stream use ‘exec’ feature. # application hls { hls on; #hls_path /var/app; hls_path /kkk; hls_fragment 5s; } } } # HTTP can be used for accessing RTMP stats http { server { listen      8080; # This URL provides RTMP statistics in XML location /stat { rtmp_stat all; # Use this stylesheet to view XML as web page # in browser rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { # XML stylesheet to view RTMP stats. # Copy stat.xsl wherever you want # and put the full directory path here root /path/to/stat.xsl/; } location /hls { # Serve HLS fragments #alias /var/app; autoindex on; alias /kkk; } } }

http://www.cuplayer.com/player/PlayerCodeAs/2014/03071219_2.html

做自己的m3u8点播系统使用HTTP Live Streaming相关推荐

  1. [转]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)

    [FMS]使用ffmpeg来完成对flv.mp4.mp3等格式的转化,使用ffmpeg或segmenter完成对视频/音频格式文件的切割,切割为m3u8格式及ts文件 1. 为何要使用HTTP Liv ...

  2. 转 做自己的m3u8点播系统使用HTTP Live Streaming HLS技术)

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! [FMS ...

  3. 做一个微信语音点播系统

    最近在做一个微信项目,接触到了微信公众平台.通过公众平台可以很方便的搭建一个功能完善的移动应用.昨天发现:开发者可使用手机号来申请接口测试帐号,体验高级接口. 这篇文章的应用将使用到高级接口中的语音识 ...

  4. 基于HTTP Live Streaming(HLS) 搭建在线点播系统

    from:http://blog.csdn.net/cdnight/article/details/39156711 基于HTTP Live Streaming(HLS) 搭建在线点播系统 chuan ...

  5. 完整的OTT直播点播系统都有哪些功能?

    说到 IPTV 或者OTT直播点播系 统的完整功能,要看针对什么运营者以及在什么样的环境中使用,针对的是什么人群,这样说的完整功能才是比较有意义的.这里小编只是对 IPTV/OTT 直播点播系统 ,可 ...

  6. 直播、点播系统开发项目总结(本地视频、抓包视频、直播推流、网络直播、平台搭建等相关问题点记录)

    项目需求: 1.客户端实现各种格式的直播源兼容问题(组播.单播下常见直播地址格式皆可播放),以及直播分类.播放记录等: 2.客户端实现视频分类(单个视频可属于多个分类下).多格式兼容.本地数据库播放缓 ...

  7. 适合影院的点播系统——点量OTT点播

    随着国内外电影的大卖,票房的收入不断增加,电影可谓是大众一项娱乐的方式,私人影院也就随之发展起来.私人影院的发展给人们带来了新的生活娱乐体验,两三个好友一个包厢,喝着饮料吃着爆米花,可以一起聊着剧情, ...

  8. 用Windows Media Service 9 实现VOD广播和点播系统(上)

    用Windows Media Service 9 实现VOD广播和点播系统(上) 2006-10-27 15:25 Windows 2003(.net)目前已经推出了多个评估版本供大家试用,而其中最令 ...

  9. 联讯机顶盒直播点播系统方案,智能机顶盒,智能电视客户端

    一.  概述 为适应现代社会校园快捷方便的直播.点播形式,威海联讯信息技术有限公司推出了联讯机顶盒直播点播系统:一台智能手机.一台pc机和一台联讯校园智能机顶盒.配合显示设备即可完成一个直播活动,直播 ...

最新文章

  1. 【转】目录 aspnet_client是什么?
  2. 《PHP、MySQL和Apache入门经典(第5版)》一2.11 实践练习
  3. 全排列(含递归和非递归的解法)
  4. 基于Java的RDMA高性能通信库(六):SDP - Java Socket Direct Protocol
  5. js记录用户访问页面和停留时间
  6. 过完年,又不想上班了?
  7. log4j 程序日志_Log4j错误–减慢您的应用程序
  8. VC函数中的延时操作
  9. git commit 规范指南
  10. hash function/ hash table 背后的数学基础(二)
  11. mysql使用mybatis删除不生效_解决myBatis中删除条件的拼接问题
  12. 解决 vim 报错:the imp module is deprecated in favour of importlib
  13. WEB前端面试选择题解答
  14. VS Visual Studio 2022调试控制台 输出不全 不完整 缺内容 少了很多代码 有屋设计拆单管理一体化软件 全屋定制拆单 橱柜衣柜整装 木门归方程序
  15. html5学习17:定制input元素
  16. Java8新特性——Lambda函数式编程
  17. 今日杂感-20220322
  18. 什么是CSTC价值协议
  19. 西门子1200PLC的MODBUS_RTU轮询程序
  20. 游戏手机平台简单介绍

热门文章

  1. 易基因|手把手教你做全基因组DNA甲基化测序分析
  2. 基于Stm32的WiFi多功能LED
  3. 如何高效的使用mac
  4. thinkpad x250装黑苹果教程_[黑苹果]x250 黑苹果历险记
  5. 评郭德纲《论50年相声之现状》
  6. 倍福--CAB文件的配置
  7. Win10 误删winsock注册表修复。 winsock.reg
  8. 我写了一个微信排版编辑器(已开源)
  9. Photoshop制作WiFi图标
  10. NBA表格_数据分析NBA历史前十球星排名