Commit Graph

148 Commits

Author SHA1 Message Date
jasaw
e8161e2825 ffmpeg: do bitrate calculation in 64 bits to prevent overflow (#959) 2021-03-13 13:01:20 -07:00
Mr-DaveDev
503af40f1d Set packet stream_index for pass through
Closes #889
2019-01-19 20:40:59 -07:00
Mr-DaveDev
b8aa3819fa Fix ffmpeg keyframe interval
Closes #794
2018-09-10 17:59:40 -06:00
Mr-DaveDev
5d863a19dc Revisions to configuration options
Revisions to configuration options.

1.  Revise config options to be `movie_` and `picture_`
2.  Revise config options to align with topic and code.
    *  motion_video_pipe, ipv6_enabled, rtsp_uses_tcp
    *  switchfilter, logfile, process_id_file
3.  Revise depreciated options to still be valid for webcontrol and config files.
4.  Revise distributed config files to only include most common options
5.  Revise sequence of config options to be arranged by topic.
6.  Revise code to use names consistent with config parms.
7.  Revise manual, guide and code to specify same default values.
8.  Update guide and manual to reflect revised option names.
2018-08-17 21:00:45 -06:00
Mr-DaveDev
dff5dd21b4 Preferred codec revision (#754) 2018-07-09 17:32:54 -06:00
Mr-DaveDev
3f9ab60089 ffmpeg 4.0 revision 2018-07-04 19:10:45 -06:00
Mr-DaveDev
13ad6c2ee5 Update for ffmpeg.c (#712) 2018-05-16 21:40:17 -06:00
Mr-DaveDev
4ff191be82 Implement Translations via Gettext
Implement translations of Motion log messages and web control using the gettext function.
2018-03-25 16:39:57 -06:00
Mr-DaveDev
1e86c7a109 Watchdog and RTSP time
1.    Revert to just capturing time directly rather than in a routine.
2.    Check for null format context pointer before writing trailer.
3.    Terminate movie when lost connection.
4.    Clean up context when failed resize.
5.    Unlock mutex on failed first image.
6.    Fix memory leak when recovering from watchdog timeout.
2018-03-13 19:53:38 -06:00
James Cowgill
9b93a417e3 Fix build errors with FFmpeg 4.0 2018-02-25 13:13:57 -07:00
Mr-DaveDev
631200a928 Pass Through
Implement pass through using concept from @iskunk fork.  

Closes #124
2017-12-30 07:54:55 -07:00
Mr-DaveDev
336734e44e Compiler Warnings (#535)
* 17.10 Compiler Revisions
* Config Changes
2017-11-06 18:55:39 -07:00
MrDave
07a48e45b5 Logging for buffered packet
1.  Remove error logged when a buffered packet is encoded.

Closes #457
2017-10-28 19:35:01 -06:00
Mr-DaveDev
69ad4fb350 High Resolution (#522)
* High Resolution

Refactor the netcam_rtsp module and associated image variables to allow for processing a dual stream from rtsp cameras.

Continue the process of segregating the functionality of the netcams into distinct modules based upon their function.
2017-10-28 17:29:16 -06:00
jasaw
f9b059aa62 do not force packet keyframe (#502)
* do not force packet keyframe

* set packet metadata for old ffmpeg
2017-10-15 10:30:14 -06:00
Mr-Dave
2a140fa31f Merge pull request #501 from Mr-DaveDev/14.04-issues
14.04 issues
2017-09-16 20:35:10 -06:00
Mr-Dave
924ec9fb73 Merge pull request #477 from jasaw/tune-h264-encode-quality
Tune h264_omx encode video quality
2017-09-16 20:20:13 -06:00
Mr-Dave
8863857215 Merge pull request #476 from jasaw/add-preferred-codec-config
Extend ffmpeg_video_codec config to take optional preferred_codec
2017-09-16 20:16:51 -06:00
Joo Aun Saw
516f9f19c9 fix sizeof comparison warning 2017-09-12 14:55:58 +10:00
Joo Aun Saw
cf0d95f243 blacklist h264_omx codec 2017-09-12 14:47:26 +10:00
Mr-Dave
425bf05c08 14.04 Issues
Resolve issues related to RTSP Cameras
1.  Do not drain the codec at each frame
2.  Add variable active to context and remove #ifdef HAVE_FFMPEG
3.  Reset return code for encoding when timing problems for pts
4.  Set the jpeg error messages to debug level.
5.  Comment out the frame timing debug messages that flood log.
2017-09-10 17:03:14 -06:00
Joo Aun Saw
2c072634ef set PTS value before encoding 2017-09-05 11:09:41 +10:00
Joo Aun Saw
ac4ce84a8f replace alloca with malloc 2017-09-04 15:00:46 +10:00
Joo Aun Saw
86166cf0d6 reworked movie encode quality 2017-08-30 11:49:11 +10:00
Joo Aun Saw
473caaeda0 use av_dict_set as int version not available 2017-08-24 10:10:22 +10:00
Joo Aun Saw
5b4982e217 Tune ffmpeg encode video quality
h264_omx encoder does not take CRF option. Video quality can only be set
via bit rate option.
2017-08-24 10:01:50 +10:00
Joo Aun Saw
a08d8a5a95 Extend ffmpeg_video_codec config to take optional preferred_codec 2017-08-23 16:33:51 +10:00
Joo Aun Saw
8c996d1561 fix logging of int64 PTS values 2017-07-31 11:42:15 +10:00
tosiara
910412f175 Changed MOTION_LOG macro (#428)
* Changed MOTION_LOG macro and remover "%s:" from the format string
Function name will be now auto added

* Re-applied log-update after conflict resolution

* Some old style logging still remaining, updated
2017-07-30 17:07:40 -06:00
MrDave
1c481df116 Additional PTS Changes
1.  Revise the PTS to allow for the capture of the first image by revising the initialization of last_pts
2.  Elminate the incrementing by 1 when we have timing issues since this puts all subsequent
    frames out of sync with timing/pts problems
3.  Unref the packets when encode and PTS functions return errors to prevent leaks.
4.  Revise logging to report more values when in test mode.
2017-07-29 21:09:02 -06:00
Joo Aun Saw
b8a2a2db16 Change last_pts back to packet timebase 2017-07-27 17:02:12 +10:00
Joo Aun Saw
1aec859b62 Fix movie gap elimination setting incorrect PTS
We eliminate gaps in movie by resetting movie start time. By doing so,
we unintentionally reset the PTS value that has to be monotonically
increasing. This fixes it by offsetting the PTS value by a base PTS
value.

Signed-off-by: Joo Aun Saw <jasaw81@gmail.com>
2017-07-26 10:45:27 +10:00
MrDave
d121a93019 v4l2 Netcam
This commit resolves some of the netcam v4l2 items and a few other
small issues

1.  Use the correct return codes for the new function rtsp_decode_video
2.  Silence the notices on reconnecting
3.  Revise the v4l2 to video4linux2 for old libav versions
4.  Add additional options for the input_format
5.  Do not permit users to specify zero for camera height or width
6.  Eliminates pthread detection
7.  Revise the ffmpeg messages to INF
8.  Adds H264 palette option
2017-03-09 21:47:13 -07:00
MrDave
ce64cf9601 ffmpeg buffered packet 2017-03-05 10:22:21 -07:00
MrDave
58baeb4d65 V4l2 via netcam
This commit adds functionality to use a v4l2 device via the netcam_url
option.  This will allow for more v4l2 devices since the netcam_url
uses the ffmpeg libraries which should be able to to decode and transform
the unusual pixel formats and sizes.
2017-03-04 12:37:04 -07:00
Mr-DaveDev
b5c3a73cc6 ffmpeg 3.1 Revisions (#324)
* ffmpeg 3.1 Revisions

The ffmpeg versions after 3.1 eliminated the stream codec which was used
in many different ways in the previous code.  This commit revises the ffmpeg
module to use smaller functions and eliminates the greyscale image handling
since all images are yuv.

* ffmpeg gop and pts

Gop:  Revise the gop based upon the fps of the requested video
to make sure we get enough I frames for low fps videos.
PTS:  Revise the PTS for the timelapse videos as well as permit
debug messages of the PTS when in test mode.

* Libav Problem
 
Closes #144
2017-03-04 11:23:13 -07:00
MrDave
f196a2c5af Whitespace and Tab cleanup
Remove trailing whitespace and convert tabs to four spaces.
No code changes.
2017-02-12 18:25:43 -07:00
MrDave
422115e49d Eliminate Developer Flag Warnings
Eliminate the warnings that occur when compiling with developer-flags
2016-12-26 12:13:48 -07:00
MrDave
28f1abf75b Regression without ffmpeg fix
This commit resolves a regression error when selecting the without-ffmpeg option.

1.  The ffmpeg configuration options are now valid whether or not the user has
    included ffmpeg.  Instead the user is notified when ffmpeg options are
    requested.

2.  The initial consolidation of the HAVE_FFMPEG duplicated the public functions
    in the #else (no ffmpeg) section.  This commit changes this so that the #IF
    are inside of the public functions so we don't have to worry about keeping
    the parameters the same between them.

3.  The timevalue was added to the ffmpeg header for the situation when
    ffmpeg is not included.
2016-12-26 11:32:03 -07:00
MrDave
a838d0527e Movie pts fix when using pre-capture
The previous method for calculating the PTS was to extract the time when
the particular function was being executed.  e.g. The time when the open
ffmpeg function was executed, the time that the image was encoded into the
movie.  This commit revises that behaviour to use instead the timevalues
that are attached to each image.  This is done to handle the precapture
situation in which all the precapture images were sent in at once at the
start of the event.  For the open function, the timevalue is obtained
from the oldest image in the ring buffer.
2016-12-10 17:26:31 -07:00
MrDave
1b33f958f2 HAVE_FFMPEG consolidation
1.  Consolidate the HAVE_FFMPEG pre-processor directives that are scattered
through the code into the ffmpeg.c module.  This makes it so that a single
pre-processor check can be used rather than surrounding every call scattered
through the code.

2.  Always compile/include the ffmpeg.c module
2016-11-24 20:59:17 -07:00
Joseph Heenan
36f1466c6b Replace abort on ffmpeg lock registration fail with exit 2016-10-13 15:53:35 +01:00
Joseph Heenan
8323227e9f Change ffmpeg locking to use av_lockmgr_register etc
We now use ffmpeg's built in support for locking instead of trying to
lock ourselves before calling ffmpeg.

This may solve some race condition crashes.

Fixes #206
2016-10-12 08:21:27 +01:00
Joseph Heenan
8372f591e1 Cleanup avformat_network_init/deinit calls
avformat_network_init only needs to be called once on startup and once
on shutdown.

The functions aren't thread safe, and we can't fix that by protecting
them with the 'global_lock' as other functions in ffmpeg that we call
and that access the same data are not protected by the global_lock
(and can't be protected by that lock).

Fixes #194 - the particular issue we're seeing there is something like:

thread 1: lock mutex
thread 1: deinit network
thread 1: init network
thread 1: unlock mutex

thread 2: lock mutex
thread 2: deinit network

thread 1: call into an ffmpeg operation
thread 1: ffmpeg complains "init network" not called
2016-10-12 08:20:50 +01:00
MrDave
4afbfd2c68 typo fix 2016-10-11 07:32:50 -06:00
MrDave
987b5e5862 Add quality default for h264
This commit adds a default crf of 28 for the h264 codecs when
the user has not selected any option.
2016-10-09 16:01:00 -06:00
MrDave
e2d3e14180 pts change for libav
The presentation time stamp(pts) indicates the time which the movie
player should display a particular frame.  In the previous changes
to the pts, we set the time basis to be in microseconds by specifying
the denomintor to be equal to 1000.  This allows for additional precision
when we assign the pts when writing the frame.  For the libav variant
the time basis assignment is ignored and instead the framerate is
used.  The use of the framerate causes problems when it is small.
At 2fps, time intervals of 1 to 499 microseconds round to a pts
of zero, 500 to 1499 microseconds round to pts 1, etc.  This
commit adds a variable to keep track of the last pts used in writing
the frame.  If the newly calculated pts is not greater than the previous
pts, we just increment the pts by 1 which would be the full 1/framerate
increment.  This could result visually twitchy videos at low framerates.
It could also have a compounding affect of eliminating the handling of
variable framerates and just fallback to a constant framerate video.
2016-10-09 14:23:58 -06:00
Joseph Heenan
7f16f567c7 Prevent blank line after ffmpeg log entries
ffmpeg seems to put a \n on the end of messages, and MOTION_LOG also
adds one, so remove the ffmpeg one.
2016-09-25 13:46:45 +01:00
Joseph Heenan
f219f812a1 Merge pull request #167 from Mr-DaveDev/netcam-messages
Suppress some messages from avcodec
2016-09-12 07:26:08 +01:00
MrDave
6d384fd106 Suppress excessive and unfixable avcodec messages 2016-09-11 22:53:17 -06:00