ffmpeg-视频实时供稿

时间:2019-06-22 03:14:17

标签: ffmpeg

我在家里使用AMCREST安全摄像头。我的目标是使用rtsp://我的环境是Raspberry pi,将连接到我的NVR的IP摄像机的一个实时馈送到Webportal。

我能够成功启动ffserver,但是当我尝试传递输入视频并将其流式传输到video.ffm时,转换失败。

我在命令中尝试了各种参数组合,但是下面的参数似乎非常接近,仅出现一个错误(av_interleaved_write_frame():对等连接重置)


$ffmpeg  -thread_queue_size 800  -i "rtsp://home:Home1234@192.168.1.32:554/cam/realmonitor?channel=4&subtype=0" -f lavfi -i aevalsrc=0  http://127.0.0.1:8090/video.ffm 

******* ffmpeg服务器配置文件内容:etc / livestream.conf


#Default port
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 100000
CustomLog -

#############################################################

<Feed video.ffm>
  File /tmp/video.ffm                    # this creates a temp video.ffm file where streams are read/write
  FileMaxSize 0.5G
  ACL allow localhost
  ACL allow 127.0.0.1
  ACL allow 192.168.0.0 192.168.255.255
</Feed>

<Stream stream>
# streaming for webm file
# run : ffserver -f /etc/ffserver.conf
# run : ffmpeg -i videoname.mp4 http://localhost:8090/video.ffm
# error : encoder setup failed
  Feed video.ffm
  Format webm

# Audio settings
  AudioCodec vorbis
  AudioBitRate 64                             # Audio bitrate

# Video settings
  VideoCodec libvpx
  VideoSize 720x486                           # Video resolution
  VideoFrameRate 30                           # Video FPS
  AVOptionVideo flags +global_header          # Parameters passed to encoder

  AVOptionVideo cpu-used 0
  AVOptionVideo qmin 10                       # lower the better, min 0
  AVOptionVideo qmax 42                       # higher outputs bad quality, max 63
  AVOptionVideo quality good
  AVOptionAudio flags +global_header
  PreRoll 15
  StartSendOnKey
  VideoBitRate 400                            # Video bitrate
</Stream>



###########################################################################

# Audio only
# run ffmpeg -i audio.mp3 http://localhost:8090/audio.ffm
# run http://localhost:8090/audio in vlc or browser

<Feed audio.ffm>
  File /tmp/audio.ffm
  FileMaxSize 1G
  ACL allow localhost
  ACL allow 127.0.0.1
  ACL allow 192.168.0.0 192.168.255.255
</Feed>

<Stream audio>
  Feed audio.ffm
  Format mp2                                     #audio format
  AudioCodec libmp3lame                          #audio codec
  AudioBitRate 64                                #audio bitrate
  AudioChannels 1                                #audio channel, 1 for mono and 2 for stereo
  AudioSampleRate 44100
  NoVideo                                        #discard video
</Stream>

####################################################################
#view status of ffserver
<Stream stat.html>
  Format status
  ACL allow localhost
  ACL allow 192.168.0.0 192.168.255.255
</Stream>



# Redirect index.html to the appropriate site

<Redirect index.html>
  URL http://www.ffmpeg.org/
</Redirect>


*****在单独的控制台上成功运行的ffmpeg服务器的输出***

$ ffserver -f /etc/livestream.conf

ffserver版本3.2.14-1〜deb9u1 + rpt1版权所有(c)2000-2019 FFmpeg开发人员   使用gcc 6.3.0(Raspbian 6.3.0-18 + rpi1 + deb9u1)内置20170516   配置:--prefix = / usr --extra-version ='1〜deb9u1 + rpt1'--toolchain = hardened --libdir = / usr / lib / arm-linux-gnueabihf --incdir = / usr / include / arm -linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b- -enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame- -enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh- -enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi- -enable-omx --enable-omx-rpi --enable-mmal --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --arch = armhf --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared   libavutil 55. 34.101 / 55. 34.101   libavcodec 57. 64.101 / 57. 64.101   libavformat 57. 56.101 / 57. 56.101   libavdevice 57. 1.100 / 57. 1.100   libavfilter 6. 65.100 / 6. 65.100   libavresample 3. 1. 0 / 3. 1. 0   libswscale 4. 2.100 / 4. 2.100   libswresample 2. 3.100 / 2. 3.100   libpostproc 54. 1.100 / 54. 1.100 /etc/livestream.conf:45:设置音频采样率的默认值=22050。使用NoDefaults禁用它。 /etc/livestream.conf:45:设置音频通道数的默认值=1。使用NoDefaults禁用它。 /etc/livestream.conf:45:设置视频比特率容限的默认值=100000。使用NoDefaults禁用它。 /etc/livestream.conf:45:设置视频速率控制方程式的默认值= tex ^ qComp。使用NoDefaults将其禁用。 /etc/livestream.conf:45:设置视频最大速率的默认值=13749264。使用NoDefaults禁用它。 /etc/livestream.conf:45:设置视频缓冲区大小的默认值=800000。使用NoDefaults禁用它。 2019年6月21日星期五19:43:59 FFserver启动。


第二个控制台


$$ffmpeg  -thread_queue_size 800  -i "rtsp://home:Home1234@192.168.1.32:554/cam/realmonitor?channel=4&subtype=0" -f lavfi -i aevalsrc=0  http://127.0.0.1:8090/video.ffm 

*************************输出**********


Input #0, rtsp, from 'rtsp://home:Home1234@192.168.1.32:554/cam/realmonitor?channel=4&subtype=0':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 0.290000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 2304x1296 [SAR 1:1 DAR 16:9], 20 fps, 250 tbr, 90k tbn, 40 tbc
Input #1, lavfi, from 'aevalsrc=0':
  Duration: N/A, start: 0.000000, bitrate: 2822 kb/s
    Stream #1:0: Audio: pcm_f64le, 44100 Hz, mono, dbl, 2822 kb/s
[swscaler @ 0x256dd80] deprecated pixel format used, make sure you did set range correctly
[libvpx @ 0x2564190] v1.6.1
Output #0, ffm, to 'http://127.0.0.1:8090/video.ffm':
  Metadata:
    title           : Media Server
    creation_time   : now
    encoder         : Lavf57.56.101
    Stream #0:0: Audio: vorbis (libvorbis), 22050 Hz, mono, fltp, 64 kb/s
    Metadata:
      encoder         : Lavc57.64.101 libvorbis
    Stream #0:1: Video: vp8 (libvpx), yuv420p, 720x486 [SAR 6:5 DAR 16:9], q=10-42, 400 kb/s, 20 fps, 1000k tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.64.101 libvpx
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 800000 vbv_delay: -1
Stream mapping:
  Stream #1:0 -> #0:0 (pcm_f64le (native) -> vorbis (libvorbis))
  Stream #0:0 -> #0:1 (h264 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
frame=    2 fps=1.2 q=0.0 size=       8kB time=00:00:00.03 bitrate=1966.0kbits/s dup=1 drop=0 speed=0.0av_interleaved_write_frame(): Connection reset by peer
Error writing trailer of http://127.0.0.1:8090/video.ffm: Connection reset by peer frame=    2 fps=1.1 q=0.0 Lsize=      40kB time=00:00:00.03 bitrate=9830.2kbits/s dup=1 drop=0 speed=0.0189x    
video:29kB audio:0kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 36.183796%
Conversion failed

我的期望是ffmpeg将开始将数据写入位于/ tmp目录中的video.ffm,以便我可以通过输入以下链接从浏览器或vlc媒体播放器读取数据 http://localhost:8090/stream

****** 2小时后更新******

我对命令参数做了些微更改,我的输出也进行了更改。在/ tmp文件夹中生成的临时视频文件看起来没有被video.ffm占用(我的分析可能是错误的)

ffmpeg  -thread_queue_size 1200  -i "rtsp://home:Home1234@192.168.1.32:554/cam/realmonitor?channel=4&subtype=0" -f lavfi -i aevalsrc=0 -override_ffserver  http://127.0.0.1:8090/video.ffm

*****************输出****

Past duration 0.660332 too large     376kB time=00:00:01.03 bitrate=2978.9kbits/s dup=3 drop=5 speed=0.171x    
Past duration 0.637352 too large     840kB time=00:00:03.72 bitrate=1847.5kbits/s dup=14 drop=5 speed=0.213x    
Past duration 0.678307 too large
Past duration 0.713280 too large    1180kB time=00:00:05.52 bitrate=1749.0kbits/s dup=21 drop=5 speed=0.218x    
Past duration 0.901085 too large    1372kB time=00:00:06.72 bitrate=1670.4kbits/s dup=26 drop=5 speed=0.22x     
Past duration 0.948051 too large    2456kB time=00:00:12.97 bitrate=1551.1kbits/s dup=51 drop=5 speed=0.226x    
[rtsp @ 0x1fd7670] Thread message queue blocking; consider raising the thread_queue_size option (current value: 1200)
Past duration 0.713280 too large    3336kB time=00:00:17.64 bitrate=1549.0kbits/s dup=70 drop=5 speed=0.228x    
[rtsp @ 0x1fd7670] max delay reached. need to consume packetbitrate=1537.0kbits/s dup=76 drop=5 speed=0.229x    
[rtsp @ 0x1fd7670] RTP: missed 30 packets
[rtsp @ 0x1fd7670] max delay reached. need to consume packetbitrate=1533.3kbits/s dup=78 drop=5 speed=0.228x    
[rtsp @ 0x1fd7670] RTP: missed 134 packets
[rtsp @ 0x1fd7670] max delay reached. need to consume packetbitrate=1539.5kbits/s dup=82 drop=5 speed=0.229x    
[rtsp @ 0x1fd7670] RTP: missed 111 packets
[rtsp @ 0x1fd7670] max delay reached. need to consume packetbitrate=1526.3kbits/s dup=84 drop=5 speed=0.229x    
[rtsp @ 0x1fd7670] RTP: missed 19 packets
[rtsp @ 0x1fd7670] max delay reached. need to consume packetbitrate=1521.7kbits/s dup=92 drop=5 speed=0.23x     
[rtsp @ 0x1fd7670] RTP: missed 626 packets
Past duration 0.651329 too large    4408kB time=00:00:23.64 bitrate=1527.0kbits/s dup=94 drop=5 speed=0.23x    
[rtsp @ 0x1fd7670] max delay reached. need to consume packetbitrate=1516.7kbits/s dup=94 drop=5 speed=0.23x    
[rtsp @ 0x1fd7670] RTP: missed 134 packets
[rtsp @ 0x1fd7670] max delay reached. need to consume packetbitrate=1521.3kbits/s dup=98 drop=5 speed=0.231x    
[rtsp @ 0x1fd7670] RTP: missed 123 packets
Past duration 0.633354 too large    4608kB time=00:00:24.98 bitrate=1511.0kbits/s dup=99 drop=5 speed=0.23x     
[rtsp @ 0x1fd7670] max delay reached. need to consume packetbitrate=1523.4kbits/s dup=99 drop=5 speed=0.231x    

0 个答案:

没有答案
相关问题