nginx 播放视频(1)

标签: nginx 播放 视频 | 发表时间:2015-06-22 04:21 | 作者:
出处:http://www.iteye.com

1,首先拷贝一个flv文件到nginx 的html目录中

cp /var/www/html/ajl/uploadvideos/20150428101917_31520150408监利新闻(三).flv ./

flv文件的路径是:/usr/local/nginx/html/broadcast2/20150428101917_31520150408监利新闻(三).flv

 

2,把flv视频格式转化为ts

ffmpeg -i 20150428101917_31520150408监利新闻(三).flv -acodec copy -vcodec libx264 20150428101917_31520150408监利新闻(三).ts

ffmpeg version N-72743-g130a6c0 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
  configuration: --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 --enable-libnut --enable-libtheora
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, flv, from '20150428101917_31520150408监利新闻(三).flv':
  Metadata:
    encoder         : Lavf53.6.0
  Duration: 00:23:02.61, start: 0.000000, bitrate: 453 kb/s
    Stream #0:0: Video: flv1, yuv420p, 320x240, 800 kb/s, 18 fps, 18 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: mp3, 22050 Hz, stereo, s16p, 58 kb/s
[libx264 @ 0xa954c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0xa954c0] profile High, level 1.2
Output #0, mpegts, to '20150428101917_31520150408监利新闻(三).ts':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: h264 (libx264), yuv420p, 320x240, q=-1--1, 18 fps, 90k tbn, 18 tbc
    Metadata:
      encoder         : Lavc56.41.100 libx264
    Stream #0:1: Audio: mp3, 22050 Hz, stereo, 58 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (flv1 (flv) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=24886 fps=146 q=27.0 Lsize=   59063kB time=00:23:02.60 bitrate= 350.0kbits/s    
video:40726kB audio:10621kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 15.029047%
[libx264 @ 0xa954c0] frame I:180   Avg QP:18.64  size: 13909
[libx264 @ 0xa954c0] frame P:18092 Avg QP:23.20  size:  2073
[libx264 @ 0xa954c0] frame B:6614  Avg QP:26.06  size:   257
[libx264 @ 0xa954c0] consecutive B-frames: 60.2% 10.6%  7.8% 21.4%
[libx264 @ 0xa954c0] mb I  I16..4: 13.8% 66.2% 20.0%
[libx264 @ 0xa954c0] mb P  I16..4:  0.6%  1.9%  0.3%  P16..4: 25.3% 14.2% 12.6%  0.0%  0.0%    skip:45.1%
[libx264 @ 0xa954c0] mb B  I16..4:  0.1%  0.3%  0.0%  B16..8: 21.6%  2.9%  0.9%  direct: 1.0%  skip:73.3%  L0:41.6% L1:45.6% BI:12.8%
[libx264 @ 0xa954c0] 8x8 transform intra:67.8% inter:67.4%
[libx264 @ 0xa954c0] coded y,uvDC,uvAC intra: 69.6% 73.8% 34.0% inter: 20.4% 13.7% 2.9%
[libx264 @ 0xa954c0] i16 v,h,dc,p: 13% 69% 12%  6%
[libx264 @ 0xa954c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 28% 28%  4%  4%  4%  6%  4%  7%
[libx264 @ 0xa954c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 31% 13%  5%  6%  6%  7%  5%  7%
[libx264 @ 0xa954c0] i8c dc,h,v,p: 43% 34% 18%  5%
[libx264 @ 0xa954c0] Weighted P-Frames: Y:0.9% UV:0.5%
[libx264 @ 0xa954c0] ref P L0: 73.5% 15.3%  7.8%  3.4%  0.0%
[libx264 @ 0xa954c0] ref B L0: 86.6% 11.0%  2.4%
[libx264 @ 0xa954c0] ref B L1: 94.9%  5.1%
[libx264 @ 0xa954c0] kb/s:241.31
[root@iZ25vr4qe08Z broadcast2]# 

 

3,切片

segmenter -i 20150428101917_31520150408监利新闻(三).ts -d 10 -p segmenter_test -m vp5.m3u8 -u http://123.57.250.51:8080/broadcast2/

-d 10:每个切片为10秒,

-p segmenter_test:切片的名字的前缀

 

     -u URL地址:m3u8中播放列表的地址前缀

Output #0, mpegts, to 'segmenter_test':
    Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 320x240, q=2-31, 18 tbc
    Stream #0:1: Audio: mp3 ([3][0][0][0] / 0x0003), 22050 Hz, stereo, 60 kb/s
[mpegts @ 0x23826e0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[mpegts @ 0x23826e0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Ignoring attempt to set invalid timebase 1/0 for st:1

 

 

4,打开vp5.m3u8 确认里面的切片路径是否正确

一定要确保切片(ts文件)的url是有效的

 

 

5,命令列表

cd broadcast2/

cp /var/www/html/ajl/uploadvideos/20150428101917_31520150408监利新闻(三).flv ./

 ffmpeg -i 20150428101917_31520150408监利新闻(三).flv -acodec copy -vcodec libx264 20150428101917_31520150408监利新闻(三).ts 

segmenter -i 20150428101917_31520150408监利新闻(三).ts -d 10 -p segmenter_test -m vp5.m3u8 -u http://123.57.250.51:8080/broadcast2/

 

 vim vp5.m3u8 

参考:http://hdu104.com/294

 



已有 0 人发表留言,猛击->> 这里<<-参与讨论


ITeye推荐



相关 [nginx 播放 视频] 推荐:

nginx 播放视频(1)

- - ITeye博客
1,首先拷贝一个flv文件到nginx 的html目录中. cp /var/www/html/ajl/uploadvideos/20150428101917_31520150408监利新闻(三).flv ./. flv文件的路径是:/usr/local/nginx/html/broadcast2/20150428101917_31520150408监利新闻(三).flv.

Nginx下搭建flv视频服务器且支持视频拖动进度条播放

- gOODiDEA - CSDN博客推荐文章
目前,由于Flash的流行,网络上绝大多数的微视频网站都采用了Flv格式来播放视频. 在互联网上播放视频,有两种方式,一种是文件方式,即通过HTTP协议访问视频文件,这种方式的缺点是不能从特定的帧开始播放;另外一种就是采用专门的流媒体服务器,这种方式的缺点是要搭建复杂的流媒体服务器. 不过,现在有了一种集合了以上两种方式优点的一种解决方案,即通过HTTP来实现伪流媒体.

WebView中的视频播放

- - 移动开发 - ITeye博客
activity_main.xml如下:. private String videoUrl = "视频地址.mp4";. private String imgUrl = "视频封面图片地址.png";. private String html = "视频如下:
应用开发托管服务';