[FFmpeg-user] optimize streaming ip-cameras to ffserver and opencv

lebies debeer.leon at gmail.com
Tue Jan 21 15:23:09 CET 2014


Hi all,

I'm trying to stream ip-cams through ffserver which are picked up by opencv2
for processing.

The server streaming side works, gets input stream and I can play it on the
other side. There are a few hitches that I'd really appreciate help on:

1. On both player and opencv the stream plays for a short while (few
seconds) and then freezes.
2. When I change the vcodec to libx264 (from copy), I cannot for the life of
me get around the following errors:
 
$ ffmpeg -r 30 -an -i "rtsp://192.168.1.212:554" -c:v libx264 -tune
zerolatency -b:v 200k http://127.0.0.1:8554/cam2.ffm
[libx264 @ 0xcfa380] broken ffmpeg default settings detected
[libx264 @ 0xcfa380] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0xcfa380] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0xcfa380] speed presets are listed in x264 --help
[libx264 @ 0xcfa380] profile is optional; x264 defaults to high


I compiled ffmpeg to work from my home directory. compiled without error and
all the utility programs run. ldconfig, etc all setup properly, and I
removed (as much as I could of) the repo installs for ffmpeg and
accompanying libs.

$ uname -a (SolydXK)
Linux leon 3.11-2-amd64 #1 SMP Debian 3.11.8-1 (2013-11-13) x86_64 GNU/Linux


I need to optimize the incoming feed(s) and will need to convert pix-format
to rgb at some point I guess.

Any help please :).



Here's the info I think will be of assistance:

ip-cam detail:

Type: Video
Codec: H264-MPEG-4-AVC (Part 10) (h264)
Resolution: 1280x720
Fps: 30
Format: Planar 4:2:0 YUV


commands, configs, etc:

server:
$ ffserver -d -f /home/xxxx/bin/ffserver.conf

feed:
$ ffmpeg -v info -i "rtsp://192.168.1.212:554" -vcodec copy
http://127.0.0.1:8554/cam2.ffm

playback:
$ ffplay -v info -i http://127.0.0.1:8554/cam2.mpg

opencv2:
capture = cvCreateFileCapture("http://127.0.0.1:8554/cam2.mpg");


[commented lines cut for brevity]
******************************************************************
ffserver.conf
******************************************************************
Port 8554
BindAddress 0.0.0.0
MaxHTTPConnections 100
MaxClients 10
MaxBandwidth 7000
CustomLog -

##################################################################
# Definition of the live feeds. Each live feed contains one video

<Feed cam2.ffm>

File /home/xxxx/workspace/ocvbg/Debug/cam2.ffm
FileMaxSize 2048K
ACL allow 127.0.0.1

</Feed>

##################################################################
# Now you can define each stream which will be generated from the

<Stream cam2.mpg>

# coming from live feed 'cam2'
Feed cam2.ffm

# Format of the stream : you can choose among:
# mpeg       : MPEG-1 multiplexed video and audio
# mpegvideo  : only MPEG-1 video
# mp2        : MPEG-2 audio (use AudioCodec to select layer 2 and 3 codec)
# ogg        : Ogg format (Vorbis audio codec)
# rm         : RealNetworks-compatible stream. Multiplexed audio and video.
# ra         : RealNetworks-compatible stream. Audio only.
# mpjpeg     : Multipart JPEG (works with Netscape without any plugin)
# jpeg       : Generate a single JPEG image.
# asf        : ASF compatible streaming (Windows Media Player format).
# swf        : Macromedia Flash compatible stream
# avi        : AVI format (MPEG-4 video, MPEG audio sound)
Format mpeg

VideoBitRate 64
VideoBufferSize 40
VideoFrameRate 30
VideoSize 1280x720
VideoGopSize 90
VideoCodec libx264
NoAudio
ACL ALLOW 127.0.0.1

</Stream>


##################################################################
# Example streams

##################################################################
# Special streams

# Server status

<Stream stat.html>
Format status

# Only allow local people to get the status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255

#FaviconURL http://pond1.gladstonefamily.net:8080/favicon.ico
</Stream>


# Redirect index.html to the appropriate site

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


===================================================================







stream capture:
$ ffmpeg -v debug -i "rtsp://192.168.1.212:554" -vcodec copy
http://127.0.0.1:8554/cam2.ffm

ffmpeg version git-2014-01-11-e11983b Copyright (c) 2000-2014 the FFmpeg
developers
  built on Jan 21 2014 15:14:40 with gcc 4.8 (Debian 4.8.2-1)
  configuration: --prefix=/home/xxxx/ffmpeg
--extra-cflags=-I/home/xxxx/ffmpeg/include
--extra-ldflags=-L/home/xxxx/ffmpeg/lib --bindir=/home/xxxx/bin
--extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
--enable-shared
  libavutil      52. 62.100 / 52. 62.100
  libavcodec     55. 47.101 / 55. 47.101
  libavformat    55. 22.103 / 55. 22.103
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     4.  1.100 /  4.  1.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with
argument 'debug'.
Reading option '-i' ... matched as input file with argument
'rtsp://192.168.1.212:554'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec
('copy' to copy stream)) with argument 'copy'.
Reading option 'http://127.0.0.1:8554/cam2.ffm' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file rtsp://192.168.1.212:554.
Successfully parsed a group of options.
Opening an input file: rtsp://192.168.1.212:554.
[rtsp @ 0xa40900] SDP:
v=0
o=- 1262738693342514 1262738693342514 IN IP4 192.168.1.212
s=Media Presentation
e=NONE
b=AS:5050
t=0 0
a=control:rtsp://192.168.1.212:554/
m=video 0 RTP/AVP 96
b=AS:5000
a=control:rtsp://192.168.1.212:554/trackID=1
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=420029; packetization-mode=1;
sprop-parameter-sets=Z01AIIiLUCgC3QgAAC7gAAr8gCA=,aO44gA==
m=application 0 RTP/AVP 107
b=AS:50
a=control:rtsp://192.168.1.212:554/trackID=3
a=rtpmap:107 vnd.onvif.metadata/90000
a=Media_header:MEDIAINFO=4A4B5859010100000400010000000000000000000000000000000000000000000000000000000000;
a=appversion:1.0

[rtsp @ 0xa40900] video codec set to: h264
[NULL @ 0xa433c0] RTP Profile IDC: 42 Profile IOP: 0 Level: 29
[NULL @ 0xa433c0] RTP Packetization Mode: 1
[NULL @ 0xa433c0] Extradata set to 0xa439a0 (size: 32)!
[udp @ 0xa446a0] end receive buffer size reported is 131072
[udp @ 0xa54960] end receive buffer size reported is 131072
[udp @ 0xa65260] end receive buffer size reported is 131072
[udp @ 0xa64fa0] end receive buffer size reported is 131072
[rtsp @ 0xa40900] hello state=0
[h264 @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping
    Last message repeated 1 times
[rtsp @ 0xa40900] All info found
rfps: 29.333333 0.016335
rfps: 29.416667 0.012505
rfps: 29.500000 0.009189
    Last message repeated 1 times
rfps: 29.583333 0.006386
    Last message repeated 1 times
rfps: 29.666667 0.004096
    Last message repeated 1 times
rfps: 29.750000 0.002320
    Last message repeated 1 times
rfps: 29.833333 0.001057
    Last message repeated 1 times
rfps: 29.916667 0.000307
    Last message repeated 1 times
rfps: 30.000000 0.000070
rfps: 30.083333 0.000346
    Last message repeated 1 times
rfps: 30.166667 0.001136
    Last message repeated 1 times
rfps: 30.250000 0.002439
    Last message repeated 1 times
rfps: 30.333333 0.004255
    Last message repeated 1 times
rfps: 30.416667 0.006584
    Last message repeated 1 times
rfps: 30.500000 0.009427
    Last message repeated 1 times
rfps: 30.583333 0.012783
rfps: 30.666667 0.016652
rfps: 59.333333 0.016386
rfps: 59.416667 0.012576
rfps: 59.500000 0.009280
    Last message repeated 1 times
rfps: 59.583333 0.006497
    Last message repeated 1 times
rfps: 59.666667 0.004227
    Last message repeated 1 times
rfps: 59.750000 0.002471
    Last message repeated 1 times
rfps: 59.833333 0.001227
    Last message repeated 1 times
rfps: 59.916667 0.000497
rfps: 60.000000 0.000280
rfps: 29.970030 0.000096
rfps: 59.940060 0.000384
Input #0, rtsp, from 'rtsp://192.168.1.212:554':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.233667, bitrate: N/A
    Stream #0:0, 28, 1/90000: Video: h264 (Main), yuv420p, 1280x720, 1/60,
30 fps, 30 tbr, 90k tbn, 60 tbc
    Stream #0:1, 0, 1/90000: Data: none, 0/1
Successfully opened the file.
Parsing a group of options: output file http://127.0.0.1:8554/cam2.ffm.
Applying option vcodec (force video codec ('copy' to copy stream)) with
argument copy.
Successfully parsed a group of options.
Opening an output file: http://127.0.0.1:8554/cam2.ffm.
[http @ 0xc6f9a0] request: GET /cam2.ffm HTTP/1.1
User-Agent: Lavf/55.22.103
Accept: */*
Range: bytes=0-
Connection: close
Host: 127.0.0.1:8554


[http @ 0xc6f9a0] header='HTTP/1.0 200 OK'
[http @ 0xc6f9a0] http_code=200
[http @ 0xc6f9a0] header='Pragma: no-cache'
[http @ 0xc6f9a0] header='Content-Type: application/x-octet-stream'
[http @ 0xc6f9a0] header=''
[ffm @ 0xa85c00] Format ffm probed with size=2048 and score=101
[AVIOContext @ 0xd6eaa0] Statistics: 4096 bytes read, 0 seeks
[http @ 0xc6f9a0] request: POST /cam2.ffm HTTP/1.1
Transfer-Encoding: chunked
User-Agent: Lavf/55.22.103
Accept: */*
Connection: close
Host: 127.0.0.1:8554


Successfully opened the file.
Output #0, ffm, to 'http://127.0.0.1:8554/cam2.ffm':
  Metadata:
    title           : Media Presentation
    creation_time   : now
    encoder         : Lavf55.22.103
    Stream #0:0, 0, 1/1000000: Video: h264, yuv420p, 1280x720, 1/30, q=2-31,
30 fps, 1000k tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[ffm @ 0xdeb7c0] Non-monotonous DTS in output stream 0:0; previous: 0,
current: -166667; changing to 1. This may result in incorrect timestamps in
the output file.
[ffm @ 0xdeb7c0] Non-monotonous DTS in output stream 0:0; previous: 1,
current: -133667; changing to 2. This may result in incorrect timestamps in
the output file.
[ffm @ 0xdeb7c0] Non-monotonous DTS in output stream 0:0; previous: 2,
current: -99667; changing to 3. This may result in incorrect timestamps in
the output file.
[ffm @ 0xdeb7c0] Non-monotonous DTS in output stream 0:0; previous: 3,
current: -66667; changing to 4. This may result in incorrect timestamps in
the output file.
[ffm @ 0xdeb7c0] Non-monotonous DTS in output stream 0:0; previous: 4,
current: -33667; changing to 5. This may result in incorrect timestamps in
the output file.
[NULL @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping
[NULL @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping    
[NULL @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping    
[NULL @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping    
[NULL @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping    
[NULL @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping    
[NULL @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping    
[NULL @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping    
[NULL @ 0xa433c0] Current profile doesn't provide more RBSP data in PPS,
skipping    
the above is a recurring message.

frame=  289 fps= 33 q=-1.0 Lsize=    5220kB time=00:00:09.43
bitrate=4532.9kbits/s    
video:5193kB audio:0kB subtitle:0 global headers:0kB muxing overhead
0.515999%
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0xc6f7e0] Statistics: 0 seeks, 1305 writeouts

Thanks in advance,

lebies




--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/optimize-streaming-ip-cameras-to-ffserver-and-opencv-tp4663344.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.


More information about the ffmpeg-user mailing list