How to stream h264 with ffmpeg from an Axis P3343

From ZoneMinder Wiki
Revision as of 00:41, 5 August 2012 by Pashdown (talk | contribs) (avconv dependency is installed)
Jump to navigationJump to search

--stagecoach 12:45, 19 October 2010 (BST)

Go back to the How To pages...

Introduction

We are trying to get h264 capturing and recording going in ZM. This page provides a starting point. The goal of this page is to test and make sure that h264 streaming is working in principal.

Reference

FFmpeg x264 encoding guide

x264 Preset Files

If you build ffmpeg from scratch, then the preset files are by default located in /usr/local/share/ffmpeg

General Camera Configuration

Variable Bit Rate

Camera Settings:

Variable Bit Rate configuration

ffmpeg command: two-pass vbr: ffmpeg -t 00:00:30 -f rtsp -i rtsp://172.16.2.100:554/axis-media/media.amp -an -pass 1 -vcodec libx264 -vpre slow_firstpass -b 180000 -bt 180000 -threads 0 -y outfile.mp4

Output file plays back in Totem Media Player.

Constant Bit Rate

Camera Settings:

Constant Bit Rate configuration

ffmpeg command: ffmpeg -t 00:00:30 -f rtsp -i rtsp://172.16.2.100:554/axis-media/media.amp -vcodec libx264 -vpre medium -crf 20.0 -b 180000 -threads 0 -y outfile.mp4

Output file plays back in Totem Media Player.

Ubuntu 12.04 Configuration

After much searching and researching, this configuration works for me for the Axis P3343, M3014, and M3011.

The default Ubuntu 12.04 ffmpeg, or "avconv" as the new fork is known as, works fine for camera capture, h264 video construction, and EyeZM. It is automatically installed as a dependency to the zoneminder package.


Set the following options for Zoneminder under the Images tab:

OPT_FFMPEG: (Checked)
PATH_FFMPEG: /usr/bin/avconv


Add the Zoneminder cameras with the following settings:

General

Source Type: Ffmpeg
Maximum FPS: Empty
Alarm Maximum FPS: Empty

Source

Source Path: rtsp://(camera dns name or IP address)/axis-media/media.amp?streamprofile=Quality?tcp
Capture Width (pixels): 640 for the M3011, 1280 for the P3343 and the M3014
Capture Height (pixels): 480 for the M3011, 800 for the P3343 and the M3014


If your camera status repeatedly goes orange or red, copy the "Quality" profile on the camera and setup a "ZM" profile on the camera with GOV Settings length of 20. Note that this is usually due to the camera trying to handle multiple streams. It can usually do the "Quality" profile just fine if it is only serving 1 stream.

The "?tcp" argument on the Source Path URL is critical. Otherwise you will get packets dropped and half and artifacted frames.