音频和视频播放 900 秒,然后ffmpeg
停止:
video:1889kB audio:1825kB global headers:0kB muxing overhead 2.162866%
我通过 nginx 从 AXIS IP 摄像机进行流式传输ffmpeg
。
ffmpeg -v verbose -i rtsp://root:[email protected]/axis-media/media.amp -itsoffset 00:00:05 -acodec copy -ac 1 -ab 64k -ar 16000 -f flv -r 5 -qscale 1 -b 128kB rtmp://192.168.0.107/myapp/test
我测试了许多命令,但这个命令给了我最好的结果。
控制台输出:
ffmpeg -v verbose -i rtsp://root:[email protected]/axis-media/media.amp -itsoffset 00:00:05 -acodec copy -ac 1 -ab 64k -ar 16000 -f flv -r 5 -qscale 1 -b 128kB rtmp://192.168.0.107/myapp/test
ffmpeg version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:20:06 with gcc 4.7.2
configuration: --arch=amd64 --enable-pthreads --enable-runtime-cpudetect --extra-version='6:0.8.6-1ubuntu2' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-gnutls --enable-libgsm --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-swscale --enable-libcdio --enable-x11grab --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 51. 22. 1 / 51. 22. 1
libavcodec 53. 35. 0 / 53. 35. 0
libavformat 53. 21. 1 / 53. 21. 1
libavdevice 53. 2. 0 / 53. 2. 0
libavfilter 2. 15. 0 / 2. 15. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 52. 0. 0 / 52. 0. 0
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[rtsp @ 0x63fb20] SDP:
v=0
o=- 1376246125522976 1376246125522976 IN IP4 192.168.0.106
s=Media Presentation
e=NONE
b=AS:50064
t=0 0
a=control:*
a=range:npt=0.000000-
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:50000
a=framerate:5.0
a=transform:-1,0,0;0,-1,0;0,0,1
a=control:trackID=1
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; profile-level-id=4D0029; sprop-parameter-sets=Z00AKeKQKD9gLcBAQGkHiRFQ,aO48gA==
m=audio 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:64
a=control:trackID=2
a=rtpmap:97 mpeg4-generic/16000/1
a=fmtp:97 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=1408; sizeLength=13; indexLength=3; indexDeltaLength=3; profile=1; bitrate=64000;
[rtsp @ 0x63fb20] Estimating duration from bitrate, this may be inaccurate
Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 90000.00 (180000/2)
Input #0, rtsp, from 'rtsp://root:[email protected]/axis-media/media.amp':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.062063, bitrate: N/A
Stream #0.0: Video: h264 (Main), yuvj420p, 320x240 [PAR 1:1 DAR 4:3], 90k tbr, 90k tbn, 180k tbc
Stream #0.1: Audio: aac, 16000 Hz, mono, s16
Incompatible pixel format 'yuvj420p' for codec 'flv', auto-selecting format 'yuv420p'
[buffer @ 0x641aa0] w:320 h:240 pixfmt:yuvj420p
[avsink @ 0x6512a0] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x645540] w:320 h:240 fmt:yuvj420p -> w:320 h:240 fmt:yuv420p flags:0x4
Output #0, flv, to 'rtmp://192.168.0.107/myapp/test':
Metadata:
title : Media Presentation
encoder : Lavf53.21.1
Stream #0.0: Video: flv, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 1024 kb/s, 1k tbn, 5 tbc
Stream #0.1: Audio: aac, 16000 Hz, mono
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press ctrl-c to stop encoding
frame= 1185 fps= 5 q=1.0 Lsize= 3794kB time=236.80 bitrate= 131.2kbits/s
video:1889kB audio:1825kB global headers:0kB muxing overhead 2.162866%
答案1
如果ffmpeg
停止编码,则表示没有更多输入需要解析,或者流已结束。这是流本身的问题,或者可能是您的ffmpeg
版本中的错误。
您正在使用的是一个旧的(已知)损坏的版本Ubuntu 软件包源提供的。考虑更新至最近ffmpeg
并再次尝试。
至于多路复用的开销:
每当您获取视频、音频或字幕流并将它们放入容器格式(例如在您的情况下为 FLV)时,容器都需要一些额外的数据来多路复用(复用)这些流。
它基本上是包裹实际数据的元数据,并且你无法摆脱这种开销。每个容器都会引入多路复用开销,但通常不到实际数据的百分之几。
如果你有非常由于对可用带宽有严格要求,因此您应该考虑编码视频和音频流时可能产生的开销。例如,如果您的视频为 1500 kBit/s,音频为 128 kBit/s,则所需的总带宽超过 1628 kBit/s(例如 1660 kBit/s)。