简体   繁体   English

ffserver保留原始流大小

[英]ffserver leave original stream size

Hope you guys will help me, because I have got stuck and can't find solution for this problem by myself. 希望你们能帮助我,因为我被困住了,自己找不到解决方案。 I am trying to stream video from webcam to users using ffmpeg+ffserver. 我正在尝试使用ffmpeg + ffserver将视频从网络摄像头流传输到用户。 But I have faced with a problem: 但是我面临一个问题:

ffmpeg gets stream from camera and pushes it to feed of ffserver:
ffmpeg -rtsp_transport tcp -i rtsp://admin:admin@192.168.10.76:80 -y -vcodec libvpx http://127.0.0.1:8090/1.ffm

ffserver stream options: ffserver流选项:

<Stream 1.webm>
Feed 1.ffm
Format webm
NoAudio
#VideoCodec libvpx
#VideoSize 480x320
VideoFrameRate 24
AVOptionVideo flags +global_header
AVOptionVideo cpu-used 0
AVOptionVideo qmin 1
AVOptionVideo qmax 31
AVOptionVideo quality good
PreRoll 0
StartSendOnKey
VideoBitRate 128
</Stream>

(note, videoSize option is commented). (请注意,videoSize选项已注释)。 But even with default VideoSize (160x128), ffserver doesn't respond for each request. 但是,即使使用默认的VideoSize(160x128),ffserver也不会对每个请求做出响应。 Browser always gets: 浏览器总是得到:

HTTP/1.0 200 OK
Pragma: no-cache
Content-Type: video/webm

But sometimes video content is not sent. 但是有时视频内容不会发送。

If I uncomment VideoSize option - the same problem but much less successfull requests comparing with default video size. 如果我取消注释VideoSize选项-与默认视频大小相比,相同的问题但成功请求少得多。

ffserver log looks regular with no errors. ffserver日志看起来正常,没有错误。 But as you can see that sometimes it sends only headers to client: 但正如您所看到的,有时它仅将标头发送到客户端:

Thu Nov 27 12:49:11 2014 127.0.0.1 - - [POST] "/1.ffm HTTP/1.1" 200 459
Thu Nov 27 12:49:25 2014 127.0.0.1 - - [POST] "/1.ffm HTTP/1.1" 200 459
Thu Nov 27 12:49:36 2014 127.0.0.1 - - [POST] "/1.ffm HTTP/1.1" 200 459
Thu Nov 27 12:50:52 2014 127.0.0.1 - - [POST] "/1.ffm HTTP/1.1" 200 459
Thu Nov 27 12:53:54 2014 127.0.0.1 - - [POST] "/1.ffm HTTP/1.1" 200 459
Thu Nov 27 13:30:19 2014 127.0.0.1 - - [GET] "/1.ffm HTTP/1.1" 200 4175
Thu Nov 27 13:30:34 2014 127.0.0.1 - - [GET] "/1.webm HTTP/1.1" 200 385731
Thu Nov 27 13:30:34 2014 127.0.0.1 - - [POST] "/1.ffm HTTP/1.1" 200 458752
Thu Nov 27 13:30:36 2014 127.0.0.1 - - [GET] "/1.ffm HTTP/1.1" 200 4175
Thu Nov 27 13:30:58 2014 127.0.0.1 - - [GET] "/1.webm HTTP/1.1" 200 493
Thu Nov 27 13:30:58 2014 127.0.0.1 - - [POST] "/1.ffm HTTP/1.1" 200 622592

Does anybody know what could it be? 有人知道这会是什么吗? Actually I need to save original VideoSize for stream. 实际上,我需要将原始VideoSize保存为流。 I am trying to override ffserver stream options with ffmpeg using the command (passing the same parameters as in ffserver's stream): 我正在尝试使用命令(传递与ffserver的流中相同的参数)来用ffmpeg覆盖ffserver的流选项:

ffmpeg -re -override_ffserver -rtsp_transport tcp -i rtsp://admin:admin@192.168.10.76:80 -an -r 24 -qmin 1 -qmax 31 -cpu-used 0 -quality good -flags:v +global_header -b:v 128 -vcodec libvpx -f webm -y http://127.0.0.1:8090/1.ffm

But at the momment I still have error message 'Output file is empty, nothing was encoded'. 但是,现在我仍然收到错误消息“输出文件为空,什么都没有编码”。 Here is ffmpeg's output: 这是ffmpeg的输出:

ffmpeg version 2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct  6 2014 17:33:05 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/opt/ffmpeg --libdir=/opt/ffmpeg/lib/ --enable-shared --enable-avresample --disable-stripping --enable-gpl --enable-version3 --enable-runtime-cpudetect --build-suffix=.ffmpeg --enable-postproc --enable-x11grab --enable-libcdio --enable-vaapi --enable-vdpau --enable-bzlib --enable-gnutls --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libvo-aacenc --enable-nonfree --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfdk_aac --enable-libopus --enable-pthreads --enable-zlib --enable-libvpx --enable-libfreetype --enable-libpulse --enable-debug=3
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://admin:admin@192.168.10.76:80':
  Metadata:
    title           : RTSP Session/2.0
  Duration: N/A, start: 0.000000, bitrate: 128 kb/s
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 100 tbr, 90k tbn, 50 tbc
    Stream #0:1: Audio: pcm_alaw, 16000 Hz, 1 channels, s16, 128 kb/s
[swscaler @ 0x197f7a0] deprecated pixel format used, make sure you did set range correctly
[libvpx @ 0x1a0c080] Bitrate 128 is extremely low, maybe you mean 128k
[libvpx @ 0x1a0c080] v1.3.0
The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
Output #0, webm, to 'http://127.0.0.1:8090/1.ffm':
  Metadata:
    title           : RTSP Session/2.0
    encoder         : Lavf56.4.101
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 480x320 [SAR 32:27 DAR 16:9], q=1-31, 0 kb/s, 24 fps, 1k tbn, 24 tbc
    Metadata:
      encoder         : Lavc56.1.100 libvpx
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> vp8 (libvpx))
Press [q] to stop, [?] for help
frame=   33 fps= 22 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A dup=0 droframe=   43 fps= 22 q=0.0 Lsize=       0kB time=00:00:00.00 bitrate=N/A dup=0 drop=1    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Received signal 2: terminating.

Thanks in advance. 提前致谢。

As far as I understand you want to: 据我了解,您要:

  1. Get the stream from an IP camera. 从IP摄像机获取流。
  2. Encode the stream using ffmpeg with vp8 codec preserving the original video resolution. 使用ffmpeg和vp8编解码器对流进行编码,以保留原始视频分辨率。
  3. Send it to ffserver. 将其发送到ffserver。
  4. Stream it further. 进一步流式传输。

To do this you need to: 为此,您需要:

  1. create ffserver.config file 创建ffserver.config文件
  2. launch ffserver 启动ffserver
  3. launch ffmpeg console script 启动ffmpeg控制台脚本

Your case requires: 您的情况要求:

  1. In config file uncomment video codec and remove bit rate 在配置文件中取消注释视频编解码器并删除比特率
  2. After launching the server type in ffmpeg command: 启动服务器后,在ffmpeg命令中输入:

    ffmpeg -i rtsp://admin:admin@192.168.10.76:80 -c:v libvpx -b:v 800 -an htt_p://xxx.xx.xxx.xxx:SERVER_HTTP_PORT/feed1.ffm ffmpeg -i rtsp:// admin:admin@192.168.10.76:80 -c:v libvpx -b:v 800 -an htt_p://xxx.xx.xxx.xxx:SERVER_HTTP_PORT / feed1.ffm

[remove '_' from http] [从http删除“ _”]

Please note that if your camera supports more than one resolution, ffmpeg will choose the worst if you don't specify which one you need. 请注意,如果您的相机支持多种分辨率,则如果您未指定所需分辨率,则ffmpeg会选择最差的分辨率。 You can check supported resolution in web cams by typing ffmpeg -f v4l2 -list_formats all -i /dev/video0 . 您可以通过键入ffmpeg -f v4l2 -list_formats all -i /dev/video0来检查网络ffmpeg -f v4l2 -list_formats all -i /dev/video0受支持的分辨率。 This should also work for an ip cam if you replace /dev/video0 with rtsp://admin:admin@192.168.10.76:80 . 如果将/dev/video0替换为rtsp://admin:admin@192.168.10.76:80这也适用于网络摄像机。

Also remember that video bit rate (-b:v) depends on the frame size. 还请记住,视频比特率(-b:v)取决于帧大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM