Can't make ZoneMinder+avconv working with H.264 camera

Forum for questions and support relating to the 1.28.x releases only.
Locked
dma_k
Posts: 27
Joined: Sat Jan 19, 2013 5:58 pm

Can't make ZoneMinder+avconv working with H.264 camera

Post by dma_k »

Dear ZoneMinder community,

I am trying to make ZoneMinder to work with my H264 IP camera FI9805W. ZoneMinder used to work OK with ffmpeg package, but when it was replaced by libav-tools, I cannot make it working.

First of all I have tested that I am able to capture the video from the camera using the command-line:

Code: Select all

$ avconv -i rtsp://user:password@ipcam:80/videoMain -an -c:v copy stream.mp4
avconv version 11.4-6:11.4-1~deb8u1, Copyright (c) 2000-2014 the Libav developers
  built on Jun  4 2015 19:43:21 with gcc 4.9.2 (Debian 4.9.2-10)
[h264 @ 0x885a860] Missing reference picture
[h264 @ 0x885a860] decode_slice_header error
[h264 @ 0x885a860] concealing 920 DC, 920 AC, 920 MV errors
[rtsp @ 0x88581e0] Non-increasing DTS in stream 1: packet 14 with DTS 6630, packet 15 with DTS 5146 [pcm_mulaw @ 0x885b4e0] RTP: missed 41 packets
[rtsp @ 0x88581e0] max_analyze_duration 5000000 reached
[rtsp @ 0x88581e0] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://viewer:B9kEmWKeSHTY@ipcam-outdoor:80/videoSub':
  Metadata:
    title           : IP Camera Video
    comment         : videoSub
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: h264 (Baseline), yuv420p, 640x360, 3.33 fps, 90k tbn
    Stream #0.1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s
Output #0, mp4, to 'stream.mp4':
  Metadata:
    title           : IP Camera Video
    comment         : videoSub
    encoder         : Lavf56.1.0
    Stream #0.0: Video: libx264, yuv420p, 640x360, q=2-31, 90k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press ctrl-c to stop encoding
[NULL @ 0x885b4e0] RTP: missed 101 packets
[NULL @ 0x885a860] RTP: missed 41 packets
frame=   19 fps=  1 q=-1.0 Lsize=     114kB time=20.08 bitrate=  46.4kbits/s
The capturing worked just fine and I was able to replay the resulting video file. However ZoneMinder fails to capture the video (debug log):

Code: Select all

07/13/15 01:41:39.947224 zmc_m3[11189].INF-zmc.cpp/212 [Starting Capture]
07/13/15 01:41:39.987600 zmc_m3[11189].INF-zm_ffmpeg_camera.cpp/98 [Priming capture from rtsp://user:password@ipcam:80/videoMain]
07/13/15 01:41:40.031775 zmc_m3[11189].DB2-zm_ffmpeg_camera.cpp/212 [OpenFfmpeg called.]
07/13/15 01:41:40.031843 zmc_m3[11189].DB2-zm_ffmpeg_camera.cpp/234 [Number of Options: 2]
07/13/15 01:41:40.031935 zmc_m3[11189].DB2-zm_ffmpeg_camera.cpp/242 [set option 1 'rtsp_transport' to 'http']
07/13/15 01:41:40.031972 zmc_m3[11189].DB1-zm_ffmpeg_camera.cpp/251 [Calling avformat_open_input]
07/13/15 01:41:40.037494 zmc_m3[11189].ERR-zm_ffmpeg_camera.cpp/262 [Unable to open input rtsp://user:password@ipcam:80/videoMain due to: Broken pipe.
I understand that command-line utility may perform some preparation work while ZoneMinder calls library function avformat_open_input() which may not result the same. Is command-line utility used by zmc at all?

How the problem can be fixed or further investigated? Thanks.

I am using ZoneMinder 1.28.0-0.2 compiled from sources under Debian jessie (8.1).
bbunge
Posts: 2981
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: Can't make ZoneMinder+avconv working with H.264 camera

Post by bbunge »

ZM is a bit picky over the Capture Width and Capture Height settings. I'm using a Foscam h.264 camera with your basis RTSP entry with the WxH set to 320x180.
User avatar
knight-of-ni
Posts: 2406
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Can't make ZoneMinder+avconv working with H.264 camera

Post by knight-of-ni »

[NULL @ 0x885b4e0] RTP: missed 101 packets
[NULL @ 0x885a860] RTP: missed 41 packets
You got some kind of response when you tried from the command line, but as you can see from the dropped RTP packets, something doesn't seem right. Were you able to play back the saved file?

07/13/15 01:41:40.031935 zmc_m3[11189].DB2-zm_ffmpeg_camera.cpp/242 [set option 1 'rtsp_transport' to 'http']
07/13/15 01:41:40.031972 zmc_m3[11189].DB1-zm_ffmpeg_camera.cpp/251 [Calling avformat_open_input]
07/13/15 01:41:40.037494 zmc_m3[11189].ERR-zm_ffmpeg_camera.cpp/262 [Unable to open input rtsp://user:password@ipcam:80
You should verify your camera url is correct.

Foscam cameras default to port 88, not port 80, for streaming. This would explain why libav is getting a response over http (and telling you to change your transport options accordingly), rather than rtsp.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
dma_k
Posts: 27
Joined: Sat Jan 19, 2013 5:58 pm

Re: Can't make ZoneMinder+avconv working with H.264 camera

Post by dma_k »

knnniggett wrote: You got some kind of response when you tried from the command line, but as you can see from the dropped RTP packets, something doesn't seem right. Were you able to play back the saved file?
Indeed, there are some packets dropped, in particular, that results frames like that, but that is not so important. I can watch the video I have recorded using Media Player Classic and second, I can watch the stream from camera using build-in UI.
knnniggett wrote: You should verify your camera url is correct.
Foscam cameras default to port 88, not port 80, for streaming. This would explain why libav is getting a response over http (and telling you to change your transport options accordingly), rather than rtsp.
Port is absolutely correct. I have changed it on purpose from port 88 to port 80.

Indeed, there was few times when avconv reported the error as connection could not be established, but ZoneMinder always reports the problem.
bbunge wrote: ZM is a bit picky over the Capture Width and Capture Height settings. I'm using a Foscam h.264 camera with your basis RTSP entry with the WxH set to 320x180.
I tried to change that in settings menu (Video → Video Settings), but unfortunately the camera ignores the setting: always returns 1280×720 for main stream and 640×360 for sub-stream regardless the settings. I have rebooted the camera few times. It shows the settings correctly on UI, but avconv reports another. Maybe you know the secret?
bbunge
Posts: 2981
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: Can't make ZoneMinder+avconv working with H.264 camera

Post by bbunge »

My Foscam FI9821W V2
Settings/Video/Video Settings/Main Stream
Stream Type: HD Mode
Resolution: VGA (630*360)
Bit Rate: 2M
Frame Rate: 5
Key Frame Interval: 10
Variable Bitrate: Yes

ZM Settings
Source Type: Ffmpeg
Function: Modect/Mocord (switches per time of day via CRON job)
Source Path: rtsp://user:password@192.168.1.244:80/videoMain
Remote Method: RTP/Unicast
Target Colorspace: 24 bit color
Capture Width: 320
Capture Height: 180

I also have control enabled.

If you are having issues with the Foscam saving settings it might be good to do a factory reset, upgrade the firmware, factory reset again.

If you can't get you system to work I suggest you try one of the Ubuntu server setups. See:
http://www.zoneminder.com/wiki/index.ph ... ntu_Server

I recommend the LTS version: http://www.zoneminder.com/wiki/index.ph ... e_easy_way
Locked