欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Live555环境搭建(linux)

程序员文章站 2022-07-06 10:22:45
...

linux下的live555播放rtsp流

对于live555的源码的一些修改可参考我的windows篇,链接:
Live555环境搭建(windows)

a、使用ffmpeg转换命令行

aaa@qq.com:~/opensource/live_my/mediaServer$ ffmpeg -i 2.mp4 -vcodec h264 -s 352*278 -an -f m4v test.264
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --prefix=/usr/local/ffmpeg_build/ffmpeg --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-libx264 --enable-shared --extra-cflags=-I/usr/local/ffmpeg_build/x264/include --extra-ldflags=-L/usr/local/ffmpeg_build/x264/lib
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    album_artist    : GuitarCIA 15.4“
    description     : 此视频有关歌词
    track           : 0
    artist          : 解忧邵帅
    album           : 
    comment         : 163 key(Don't modify):kezMTgK7ygRBfEp+Wka72Z4v/J4Z4reBRaIqZ8YqLSaix2KvVGy/OO0dS9FLsZ1bhL4cb3NEQdSCF2O+df3SKyEbM/PajB2EhEIIQCkYmgk/R6yJqTOxkNX4hGdRGk+oFGuN0L8K/ilAq/uGwXymp5kSTeQNPLuuYY7aZyR9F96aXrekYm4KZnnlkZq7UAGnCZqGq5KGt50Leu/ymrfNttlEDh1gpU9mhee6Ml5+Y
    title           : 写给黄淮
    encoder         : Lavf57.71.100
  Duration: 00:03:59.37, start: 0.000000, bitrate: 515 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 520x240 [SAR 1:1 DAR 13:6], 379 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(zho): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
File 'test.264' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x1471b40] using SAR=1807/1056
[libx264 @ 0x1471b40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x1471b40] profile Progressive High, level 1.3, 4:2:0, 8-bit
Output #0, m4v, to 'test.264':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    album_artist    : GuitarCIA 15.4“
    description     : 此视频有关歌词
    track           : 0
    artist          : 解忧邵帅
    album           : 
    comment         : 163 key(Don't modify):kezMTgK7ygRBfEp+Wka72Z4v/J4Z4reBRaIqZ8YqLSaix2KvVGy/OO0dS9FLsZ1bhL4cb3NEQdSCF2O+df3SKyEbM/PajB2EhEIIQCkYmgk/R6yJqTOxkNX4hGdRGk+oFGuN0L8K/ilAq/uGwXymp5kSTeQNPLuuYY7aZyR9F96aXrekYm4KZnnlkZq7UAGnCZqGq5KGt50Leu/ymrfNttlEDh1gpU9mhee6Ml5+Y
    title           : 写给黄淮
    encoder         : Lavf58.20.100
    Stream #0:0(und): Video: h264 (libx264), yuv420p, 352x278 [SAR 1807:1056 DAR 13:6], q=-1--1, 23.98 fps, 23.98 tbn, 23.98 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=  308 fps=0.0 q=28.0 size=     256kB time=00:00:10.55 bitrate= 198.7kbits/s speed=21.1frame=  660 fps=658 q=28.0 size=     512kB time=00:00:25.23 bitrate= 166.2kbits/s speed=25.1frame=  931 fps=619 q=28.0 size=    1024kB time=00:00:36.53 bitrate= 229.6kbits/s speed=24.3frame= 1252 fps=625 q=28.0 size=    1280kB time=00:00:49.92 bitrate= 210.0kbits/s speed=24.9frame= 1645 fps=657 q=28.0 size=    1792kB time=00:01:06.31 bitrate= 221.4kbits/s speed=26.5frame= 2006 fps=667 q=28.0 size=    2048kB time=00:01:21.37 bitrate= 206.2kbits/s speed=27.1frame= 2342 fps=668 q=28.0 size=    2304kB time=00:01:35.38 bitrate= 197.9kbits/s speed=27.2frame= 2727 fps=681 q=28.0 size=    2560kB time=00:01:51.44 bitrate= 188.2kbits/s speed=27.8frame= 2978 fps=660 q=28.0 size=    2816kB time=00:02:01.91 bitrate= 189.2kbits/s speed=  27frame= 3313 fps=661 q=28.0 size=    3072kB time=00:02:15.88 bitrate= 185.2kbits/s speed=27.1frame= 3706 fps=672 q=28.0 size=    3328kB time=00:02:32.27 bitrate= 179.0kbits/s speed=27.6frame= 4087 fps=679 q=28.0 size=    3328kB time=00:02:48.16 bitrate= 162.1kbits/s speed=  28frame= 4495 fps=690 q=28.0 size=    3584kB time=00:03:05.18 bitrate= 158.5kbits/s speed=28.4frame= 4861 fps=693 q=28.0 size=    3840kB time=00:03:20.45 bitrate= 156.9kbits/s speed=28.6frame= 5176 fps=689 q=28.0 size=    4352kB time=00:03:33.58 bitrate= 166.9kbits/s speed=28.4frame= 5710 fps=712 q=28.0 size=    4352kB time=00:03:55.86 bitrate= 151.2kbits/s speed=29.4frame= 5739 fps=712 q=-1.0 Lsize=    4610kB time=00:03:59.28 bitrate= 157.8kbits/s speed=29.7x    
video:4610kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
[libx264 @ 0x1471b40] frame I:29    Avg QP:17.39  size:  9553
[libx264 @ 0x1471b40] frame P:1766  Avg QP:21.78  size:  1874
[libx264 @ 0x1471b40] frame B:3944  Avg QP:26.82  size:   288
[libx264 @ 0x1471b40] consecutive B-frames:  3.7% 12.9%  3.0% 80.4%
[libx264 @ 0x1471b40] mb I  I16..4: 10.5% 56.2% 33.3%
[libx264 @ 0x1471b40] mb P  I16..4:  1.6%  4.7%  1.0%  P16..4: 35.5% 14.1%  8.4%  0.0%  0.0%    skip:34.7%
[libx264 @ 0x1471b40] mb B  I16..4:  0.1%  0.2%  0.0%  B16..8: 27.7%  2.1%  0.4%  direct: 1.1%  skip:68.3%  L0:35.2% L1:56.3% BI: 8.5%
[libx264 @ 0x1471b40] 8x8 transform intra:62.9% inter:67.0%
[libx264 @ 0x1471b40] coded y,uvDC,uvAC intra: 45.2% 36.5% 9.1% inter: 9.3% 6.0% 0.1%
[libx264 @ 0x1471b40] i16 v,h,dc,p: 37% 27%  7% 30%
[libx264 @ 0x1471b40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 13% 24%  4%  5%  6%  4%  6%  4%
[libx264 @ 0x1471b40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 12% 14%  5%  6%  8%  5%  7%  4%
[libx264 @ 0x1471b40] i8c dc,h,v,p: 64% 17% 18%  2%
[libx264 @ 0x1471b40] Weighted P-Frames: Y:21.3% UV:4.2%
[libx264 @ 0x1471b40] ref P L0: 63.3% 17.7% 14.0%  4.7%  0.3%
[libx264 @ 0x1471b40] ref B L0: 91.3%  6.9%  1.8%
[libx264 @ 0x1471b40] ref B L1: 96.0%  4.0%
[libx264 @ 0x1471b40] kb/s:157.76
aaa@qq.com:~/opensource/live_my/mediaServer$ 

b、编译linux下的live555,并播放rtsp流

1、下载源码,编译
wget  http://www.live555.com/liveMedia/public/live555-latest.tar.gz
tar xzf live555-latest.tar.gz
cd live                       #此处使用的更改完buffer大小后的代码
./genMakefiles linux-64bit    #注意后面这个参数是根据当前文件夹下config.<后缀>获取得到的
make
2、运行,此处要注意文件格式
cd mediaServer
aaa@qq.com:~/opensource/live_my/mediaServer$ ./live555MediaServerLIVE555 Media Server
	version 0.98 (LIVE555 Streaming Media library version 2019.07.27).
Play streams from this server using the URL
	rtsp://192.168.1.4:8554/<filename>
where <filename> is a file present in the current directory.
Each file's type is inferred from its name suffix:
	".264" => a H.264 Video Elementary Stream file
	".265" => a H.265 Video Elementary Stream file
	".aac" => an AAC Audio (ADTS format) file
	".ac3" => an AC-3 Audio file
	".amr" => an AMR Audio file
	".dv" => a DV Video file
	".m4e" => a MPEG-4 Video Elementary Stream file
	".mkv" => a Matroska audio+video+(optional)subtitles file
	".mp3" => a MPEG-1 or 2 Audio file
	".mpg" => a MPEG-1 or 2 Program Stream (audio+video) file
	".ogg" or ".ogv" or ".opus" => an Ogg audio and/or video file
	".ts" => a MPEG Transport Stream file
		(a ".tsx" index file - if present - provides server 'trick play' support)
	".vob" => a VOB (MPEG-2 video with AC-3 audio) file
	".wav" => a WAV Audio file
	".webm" => a WebM audio(Vorbis)+video(VP8) file
See http://www.live555.com/mediaServer/ for additional documentation.
(We use port 8000 for optional RTSP-over-HTTP tunneling, or for HTTP live streaming (for indexed Transport Stream files only).)
3、使用vlc查看

Live555环境搭建(linux)