Difference between revisions of "Ffmpeg"

From ZoneMinder Wiki
Jump to navigationJump to search
Line 27: Line 27:


<code>-c:v libx264 -preset ultrafast </code>
<code>-c:v libx264 -preset ultrafast </code>
===Examples===
Use ffmpeg to concatenate all jpg images in an event export to MP4 (=<1.30.4)
<code>ffmpeg -framerate ### -i %05d-capture.jpg output.mp4</code>
(Reference: https://askubuntu.com/questions/610903/how-can-i-create-a-video-file-from-a-set-of-jpg-images)
Note that %05d-capture.jpg here means
search for numbers (0), search for 5 of them, increment numbers d, then the rest is a string common to all jpg files. Edit the framerate appropriately

Revision as of 11:44, 13 June 2019

ffmpeg is a set of video processing tools used by ZoneMinder to generate video files from the frames captured and saved. It has always been under heavy development.

FFMPEG is used in two fashions in Zoneminder.

  • 1) For exporting videos, an ffmpeg binary is used (vers. 1.30.4).
  • 2) If you examine the source code, you will see zm_ffmpeg.cpp which uses libavcodec, which is library for the functions that the ffmpeg binary provides which you can wrap into a program (such as ZM). This is how ZM records when using only the ffmpeg method.

Obtaining FFMPEG

You have the option of compiling from source, or downloading a binary, which are linked from the main ffmpeg website.

A note on the RPI

The RPI has its own build of FFMPEG which includes support for the omx and mmal hardware peripherals. It is recommended to obtain it from the official RPI repos. Note that this provides hardware support for exporting, but not necessarily for recording videos (see above paragraphs).

FFMPEG Video Export Options

Ffmpeg is used in exporting events to downloadable video files. Exporting video is done using the zmvideo.pl script.

You can control the options that get passed to ffmpeg during the export process using 2 config options found in the Images tab of the options dialog.

FFMPEG_INPUT_OPTIONS

usually leave this empty

FFMPEG_OUTPUT_OPTIONS

Here are some possible settings:

To obtain a good quality export x264 based mp4 video file - the following example works...

-r 30 -vcodec libx264 -threads 2 -b 2000k -minrate 800k -maxrate 5000k

If you want as fast as possible h264(with some sacrifice in quality) you can try

-c:v libx264 -preset ultrafast

Examples

Use ffmpeg to concatenate all jpg images in an event export to MP4 (=<1.30.4)

ffmpeg -framerate ### -i %05d-capture.jpg output.mp4

(Reference: https://askubuntu.com/questions/610903/how-can-i-create-a-video-file-from-a-set-of-jpg-images) Note that %05d-capture.jpg here means search for numbers (0), search for 5 of them, increment numbers d, then the rest is a string common to all jpg files. Edit the framerate appropriately