Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
// ZoneMinder Video Storage Implementation
|
|
|
|
// Written by Chris Wiggins
|
|
|
|
// http://chriswiggins.co.nz
|
|
|
|
// Modification by Steve Gilvarry
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
//
|
|
|
|
|
|
|
|
#define __STDC_FORMAT_MACROS 1
|
|
|
|
|
|
|
|
|
|
|
|
#include "zm.h"
|
|
|
|
#include "zm_videostore.h"
|
|
|
|
|
2019-09-10 04:13:32 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <cinttypes>
|
|
|
|
|
2017-06-03 04:52:52 +08:00
|
|
|
extern "C" {
|
2017-08-23 22:37:32 +08:00
|
|
|
#include "libavutil/time.h"
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
}
|
|
|
|
|
2018-02-28 23:17:16 +08:00
|
|
|
VideoStore::CodecData VideoStore::codec_data[] = {
|
2020-12-31 22:15:49 +08:00
|
|
|
{ AV_CODEC_ID_H264, "h264", "h264_vaapi", AV_PIX_FMT_NV12 },
|
2018-02-28 23:17:16 +08:00
|
|
|
{ AV_CODEC_ID_H264, "h264", "h264_omx", AV_PIX_FMT_YUV420P },
|
|
|
|
{ AV_CODEC_ID_H264, "h264", "h264", AV_PIX_FMT_YUV420P },
|
|
|
|
{ AV_CODEC_ID_H264, "h264", "libx264", AV_PIX_FMT_YUV420P },
|
|
|
|
{ AV_CODEC_ID_MJPEG, "mjpeg", "mjpeg", AV_PIX_FMT_YUVJ422P },
|
|
|
|
};
|
|
|
|
|
2017-10-27 01:12:56 +08:00
|
|
|
VideoStore::VideoStore(
|
2017-11-13 00:42:34 +08:00
|
|
|
const char *filename_in,
|
|
|
|
const char *format_in,
|
2017-10-27 01:12:56 +08:00
|
|
|
AVStream *p_video_in_stream,
|
2021-01-26 07:50:35 +08:00
|
|
|
AVCodecContext *p_video_in_ctx,
|
2017-11-13 00:42:34 +08:00
|
|
|
AVStream *p_audio_in_stream,
|
2021-01-26 07:50:35 +08:00
|
|
|
AVCodecContext *p_audio_in_ctx,
|
2017-12-05 07:06:42 +08:00
|
|
|
Monitor *p_monitor
|
2021-01-26 07:50:35 +08:00
|
|
|
) :
|
|
|
|
monitor(p_monitor),
|
|
|
|
out_format(nullptr),
|
|
|
|
oc(nullptr),
|
|
|
|
video_out_stream(nullptr),
|
|
|
|
audio_out_stream(nullptr),
|
|
|
|
video_in_stream_index(-1),
|
|
|
|
audio_in_stream_index(-1),
|
|
|
|
video_out_codec(nullptr),
|
|
|
|
video_in_ctx(p_video_in_ctx),
|
|
|
|
video_out_ctx(nullptr),
|
|
|
|
video_in_stream(p_video_in_stream),
|
|
|
|
audio_in_stream(p_audio_in_stream),
|
|
|
|
audio_in_codec(nullptr),
|
|
|
|
audio_in_ctx(p_audio_in_ctx),
|
|
|
|
audio_out_codec(nullptr),
|
|
|
|
audio_out_ctx(nullptr),
|
|
|
|
video_in_frame(nullptr),
|
|
|
|
in_frame(nullptr),
|
|
|
|
out_frame(nullptr),
|
|
|
|
packets_written(0),
|
|
|
|
frame_count(0),
|
2018-12-27 01:02:00 +08:00
|
|
|
#if defined(HAVE_LIBSWRESAMPLE) || defined(HAVE_LIBAVRESAMPLE)
|
2021-01-26 07:50:35 +08:00
|
|
|
resample_ctx(nullptr),
|
2019-02-19 05:23:17 +08:00
|
|
|
#if defined(HAVE_LIBSWRESAMPLE)
|
2021-01-26 07:50:35 +08:00
|
|
|
fifo(nullptr),
|
2017-06-03 04:52:52 +08:00
|
|
|
#endif
|
2017-12-05 07:06:42 +08:00
|
|
|
#endif
|
2021-01-26 07:50:35 +08:00
|
|
|
converted_in_samples(nullptr),
|
|
|
|
filename(filename_in),
|
|
|
|
format(format_in),
|
2021-01-30 03:04:50 +08:00
|
|
|
video_first_pts(0), /* starting pts of first in frame/packet */
|
2021-01-26 07:50:35 +08:00
|
|
|
video_first_dts(0),
|
|
|
|
audio_first_pts(0),
|
|
|
|
audio_first_dts(0),
|
2021-01-30 03:04:50 +08:00
|
|
|
video_last_pts(AV_NOPTS_VALUE),
|
|
|
|
audio_last_pts(AV_NOPTS_VALUE),
|
2021-01-26 07:50:35 +08:00
|
|
|
next_dts(nullptr),
|
|
|
|
audio_next_pts(0),
|
|
|
|
max_stream_index(-1)
|
|
|
|
{
|
2021-01-16 06:02:26 +08:00
|
|
|
FFMPEGInit();
|
2020-12-30 01:18:26 +08:00
|
|
|
swscale.init();
|
2017-12-05 07:06:42 +08:00
|
|
|
} // VideoStore::VideoStore
|
|
|
|
|
|
|
|
bool VideoStore::open() {
|
2020-12-30 01:18:26 +08:00
|
|
|
Debug(1, "Opening video storage stream %s format: %s", filename, format);
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2020-08-26 07:45:48 +08:00
|
|
|
int ret = avformat_alloc_output_context2(&oc, nullptr, nullptr, filename);
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( ret < 0 ) {
|
2017-08-23 22:37:32 +08:00
|
|
|
Warning(
|
|
|
|
"Could not create video storage stream %s as no out ctx"
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
" could be assigned based on filename: %s",
|
2017-08-23 22:37:32 +08:00
|
|
|
filename, av_make_error_string(ret).c_str());
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
}
|
|
|
|
|
2017-08-23 22:37:32 +08:00
|
|
|
// Couldn't deduce format from filename, trying from format name
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( !oc ) {
|
2020-08-26 07:45:48 +08:00
|
|
|
avformat_alloc_output_context2(&oc, nullptr, format, filename);
|
2017-12-01 08:26:51 +08:00
|
|
|
if ( !oc ) {
|
2017-12-13 01:41:11 +08:00
|
|
|
Error(
|
2017-08-23 22:37:32 +08:00
|
|
|
"Could not create video storage stream %s as no out ctx"
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
" could not be assigned based on filename or format %s",
|
|
|
|
filename, format);
|
2017-12-13 04:30:47 +08:00
|
|
|
return false;
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
}
|
2017-12-01 08:26:51 +08:00
|
|
|
} // end if ! oc
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2020-08-26 07:45:48 +08:00
|
|
|
AVDictionary *pmetadata = nullptr;
|
2017-12-01 08:26:51 +08:00
|
|
|
ret = av_dict_set(&pmetadata, "title", "Zoneminder Security Recording", 0);
|
|
|
|
if ( ret < 0 ) Warning("%s:%d: title set failed", __FILE__, __LINE__);
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
|
|
|
oc->metadata = pmetadata;
|
2017-08-23 22:37:32 +08:00
|
|
|
out_format = oc->oformat;
|
2019-09-09 04:10:57 +08:00
|
|
|
out_format->flags |= AVFMT_TS_NONSTRICT; // allow non increasing dts
|
2017-06-03 04:52:52 +08:00
|
|
|
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( video_in_stream ) {
|
2021-01-30 03:04:50 +08:00
|
|
|
zm_dump_codecpar(video_in_stream->codecpar);
|
2017-11-13 00:42:34 +08:00
|
|
|
video_in_stream_index = video_in_stream->index;
|
2017-08-23 22:37:32 +08:00
|
|
|
|
2021-01-07 22:46:35 +08:00
|
|
|
if ( monitor->GetOptVideoWriter() == Monitor::PASSTHROUGH ) {
|
|
|
|
// Don't care what codec, just copy parameters
|
|
|
|
video_out_ctx = avcodec_alloc_context3(nullptr);
|
2021-01-28 23:17:23 +08:00
|
|
|
// There might not be a useful video_in_stream. v4l in might not populate this very
|
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
|
|
|
ret = avcodec_parameters_to_context(video_out_ctx, video_in_stream->codecpar);
|
|
|
|
#else
|
|
|
|
ret = avcodec_copy_context(video_out_ctx, video_in_ctx);
|
|
|
|
#endif
|
|
|
|
if ( ret < 0 ) {
|
|
|
|
Error("Could not initialize ctx parameters");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
fix_deprecated_pix_fmt(video_out_ctx);
|
2021-01-07 22:46:35 +08:00
|
|
|
if ( oc->oformat->flags & AVFMT_GLOBALHEADER ) {
|
2018-02-28 23:17:16 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0)
|
2021-01-07 22:46:35 +08:00
|
|
|
video_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
2018-02-28 23:17:16 +08:00
|
|
|
#else
|
2021-01-07 22:46:35 +08:00
|
|
|
video_out_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
2017-12-08 23:38:16 +08:00
|
|
|
#endif
|
2021-01-07 22:46:35 +08:00
|
|
|
}
|
|
|
|
video_out_ctx->time_base = video_in_ctx->time_base;
|
|
|
|
if ( ! (video_out_ctx->time_base.num && video_out_ctx->time_base.den) ) {
|
|
|
|
Debug(2,"No timebase found in video in context, defaulting to Q");
|
|
|
|
video_out_ctx->time_base = AV_TIME_BASE_Q;
|
|
|
|
}
|
|
|
|
} else if ( monitor->GetOptVideoWriter() == Monitor::ENCODE ) {
|
|
|
|
int wanted_codec = monitor->OutputCodec();
|
|
|
|
if ( !wanted_codec ) {
|
|
|
|
// default to h264
|
|
|
|
Debug(2, "Defaulting to H264");
|
|
|
|
wanted_codec = AV_CODEC_ID_H264;
|
|
|
|
// FIXME what is the optimal codec? Probably low latency h264 which is effectively mjpeg
|
|
|
|
} else {
|
2021-01-27 01:24:43 +08:00
|
|
|
Debug(2, "Codec wanted %d", wanted_codec);
|
2018-02-28 23:17:16 +08:00
|
|
|
}
|
2021-01-07 22:46:35 +08:00
|
|
|
std::string wanted_encoder = monitor->Encoder();
|
|
|
|
|
2020-07-22 05:38:32 +08:00
|
|
|
for ( unsigned int i = 0; i < sizeof(codec_data) / sizeof(*codec_data); i++ ) {
|
2020-12-30 01:18:26 +08:00
|
|
|
if ( wanted_encoder != "" ) {
|
|
|
|
if ( wanted_encoder != codec_data[i].codec_name ) {
|
|
|
|
Debug(1, "Not the right codec name %s != %s", codec_data[i].codec_name, wanted_encoder.c_str());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2020-12-16 05:54:35 +08:00
|
|
|
if ( codec_data[i].codec_id != wanted_codec ) {
|
|
|
|
Debug(1, "Not the right codec %d != %d", codec_data[i].codec_id, wanted_codec);
|
2020-07-22 05:38:32 +08:00
|
|
|
continue;
|
2020-12-16 05:54:35 +08:00
|
|
|
}
|
2020-07-22 05:38:32 +08:00
|
|
|
|
|
|
|
video_out_codec = avcodec_find_encoder_by_name(codec_data[i].codec_name);
|
2020-12-30 01:18:26 +08:00
|
|
|
if ( !video_out_codec ) {
|
2020-07-22 05:38:32 +08:00
|
|
|
Debug(1, "Didn't find encoder for %s", codec_data[i].codec_name);
|
|
|
|
continue;
|
|
|
|
}
|
2020-12-16 05:54:35 +08:00
|
|
|
Debug(1, "Found video codec for %s", codec_data[i].codec_name);
|
2020-12-31 10:25:12 +08:00
|
|
|
video_out_ctx = avcodec_alloc_context3(video_out_codec);
|
|
|
|
if ( oc->oformat->flags & AVFMT_GLOBALHEADER ) {
|
2020-12-30 01:18:26 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0)
|
2020-12-31 10:25:12 +08:00
|
|
|
video_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
2020-12-30 01:18:26 +08:00
|
|
|
#else
|
2020-12-31 10:25:12 +08:00
|
|
|
video_out_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
2020-12-30 01:18:26 +08:00
|
|
|
#endif
|
2020-12-31 10:25:12 +08:00
|
|
|
}
|
2017-12-01 08:26:51 +08:00
|
|
|
|
2021-01-27 01:24:43 +08:00
|
|
|
video_out_ctx->time_base = video_in_ctx ? video_in_ctx->time_base : AV_TIME_BASE_Q;
|
2020-12-31 10:25:12 +08:00
|
|
|
if ( ! (video_out_ctx->time_base.num && video_out_ctx->time_base.den) ) {
|
2021-01-16 06:02:26 +08:00
|
|
|
Debug(2, "No timebase found in video in context, defaulting to Q which is microseconds");
|
2020-12-31 10:25:12 +08:00
|
|
|
video_out_ctx->time_base = AV_TIME_BASE_Q;
|
|
|
|
}
|
2020-12-30 01:18:26 +08:00
|
|
|
|
|
|
|
video_out_ctx->codec_id = codec_data[i].codec_id;
|
2020-07-22 05:38:32 +08:00
|
|
|
video_out_ctx->pix_fmt = codec_data[i].pix_fmt;
|
|
|
|
video_out_ctx->level = 32;
|
|
|
|
|
|
|
|
// Don't have an input stream, so need to tell it what we are sending it, or are transcoding
|
|
|
|
video_out_ctx->width = monitor->Width();
|
|
|
|
video_out_ctx->height = monitor->Height();
|
|
|
|
video_out_ctx->codec_type = AVMEDIA_TYPE_VIDEO;
|
|
|
|
|
|
|
|
if ( video_out_ctx->codec_id == AV_CODEC_ID_H264 ) {
|
2020-12-30 01:18:26 +08:00
|
|
|
video_out_ctx->bit_rate = 2000000;
|
|
|
|
video_out_ctx->gop_size = 12;
|
2020-07-22 05:38:32 +08:00
|
|
|
video_out_ctx->max_b_frames = 1;
|
2021-01-16 06:02:26 +08:00
|
|
|
|
|
|
|
ret = av_opt_set(video_out_ctx->priv_data, "crf", "36", AV_OPT_SEARCH_CHILDREN);
|
|
|
|
if ( ret < 0 ) {
|
|
|
|
Error("Could not set 'crf' for output codec %s.",
|
|
|
|
codec_data[i].codec_name);
|
|
|
|
}
|
2020-07-22 05:38:32 +08:00
|
|
|
} else if ( video_out_ctx->codec_id == AV_CODEC_ID_MPEG2VIDEO ) {
|
|
|
|
/* just for testing, we also add B frames */
|
|
|
|
video_out_ctx->max_b_frames = 2;
|
|
|
|
} else if ( video_out_ctx->codec_id == AV_CODEC_ID_MPEG1VIDEO ) {
|
|
|
|
/* Needed to avoid using macroblocks in which some coeffs overflow.
|
|
|
|
* This does not happen with normal video, it just happens here as
|
|
|
|
* the motion of the chroma plane does not match the luma plane. */
|
|
|
|
video_out_ctx->mb_decision = 2;
|
|
|
|
}
|
2018-02-28 23:17:16 +08:00
|
|
|
|
2020-07-22 05:38:32 +08:00
|
|
|
AVDictionary *opts = 0;
|
|
|
|
std::string Options = monitor->GetEncoderOptions();
|
2020-12-17 23:16:54 +08:00
|
|
|
Debug(2, "Options? %s", Options.c_str());
|
2020-07-22 05:38:32 +08:00
|
|
|
ret = av_dict_parse_string(&opts, Options.c_str(), "=", ",#\n", 0);
|
|
|
|
if ( ret < 0 ) {
|
|
|
|
Warning("Could not parse ffmpeg encoder options list '%s'\n", Options.c_str());
|
2018-02-28 23:17:16 +08:00
|
|
|
} else {
|
2020-12-30 01:18:26 +08:00
|
|
|
AVDictionaryEntry *e = nullptr;
|
2020-07-22 05:38:32 +08:00
|
|
|
while ( (e = av_dict_get(opts, "", e, AV_DICT_IGNORE_SUFFIX)) != NULL ) {
|
|
|
|
Debug(3, "Encoder Option %s=%s", e->key, e->value);
|
|
|
|
}
|
|
|
|
}
|
2019-03-20 01:17:26 +08:00
|
|
|
|
2020-07-22 05:38:32 +08:00
|
|
|
if ( (ret = avcodec_open2(video_out_ctx, video_out_codec, &opts)) < 0 ) {
|
|
|
|
Warning("Can't open video codec (%s) %s",
|
|
|
|
video_out_codec->name,
|
|
|
|
av_make_error_string(ret).c_str()
|
|
|
|
);
|
2020-12-30 01:18:26 +08:00
|
|
|
video_out_codec = nullptr;
|
2018-02-28 23:17:16 +08:00
|
|
|
}
|
2017-12-02 21:12:04 +08:00
|
|
|
|
2020-12-30 01:18:26 +08:00
|
|
|
AVDictionaryEntry *e = nullptr;
|
|
|
|
while ( (e = av_dict_get(opts, "", e, AV_DICT_IGNORE_SUFFIX)) != nullptr ) {
|
2020-07-22 05:38:32 +08:00
|
|
|
Warning("Encoder Option %s not recognized by ffmpeg codec", e->key);
|
2017-11-14 14:59:15 +08:00
|
|
|
}
|
2020-12-31 10:25:12 +08:00
|
|
|
//av_dict_free(&opts);
|
2020-07-22 05:38:32 +08:00
|
|
|
if ( video_out_codec ) break;
|
|
|
|
} // end foreach codec
|
2018-02-28 23:17:16 +08:00
|
|
|
|
2020-07-22 05:38:32 +08:00
|
|
|
if ( !video_out_codec ) {
|
|
|
|
Error("Can't open video codec!");
|
2017-12-05 07:06:42 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2020-07-22 05:38:32 +08:00
|
|
|
// We allocate and copy in newer ffmpeg, so need to free it
|
|
|
|
avcodec_free_context(&video_out_ctx);
|
2017-12-05 07:06:42 +08:00
|
|
|
#endif
|
2020-12-30 01:18:26 +08:00
|
|
|
video_out_ctx = nullptr;
|
2018-02-28 23:17:16 +08:00
|
|
|
|
2020-07-22 05:38:32 +08:00
|
|
|
return false;
|
|
|
|
} // end if can't open codec
|
2021-01-30 03:04:50 +08:00
|
|
|
Debug(2, "Success opening codec");
|
2020-07-22 05:38:32 +08:00
|
|
|
} // end if copying or transcoding
|
2021-01-28 23:17:23 +08:00
|
|
|
zm_dump_codec(video_out_ctx);
|
2020-07-22 05:38:32 +08:00
|
|
|
} // end if video_in_stream
|
2018-02-28 23:17:16 +08:00
|
|
|
|
2017-10-27 01:12:56 +08:00
|
|
|
video_out_stream = avformat_new_stream(oc, video_out_codec);
|
2019-04-26 02:49:16 +08:00
|
|
|
if ( !video_out_stream ) {
|
2017-12-15 04:56:22 +08:00
|
|
|
Error("Unable to create video out stream");
|
|
|
|
return false;
|
2017-06-01 08:44:23 +08:00
|
|
|
}
|
2020-09-29 23:02:40 +08:00
|
|
|
max_stream_index = video_out_stream->index;
|
2017-11-13 00:42:34 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2017-11-28 00:28:36 +08:00
|
|
|
ret = avcodec_parameters_from_context(video_out_stream->codecpar, video_out_ctx);
|
2017-10-27 01:12:56 +08:00
|
|
|
if ( ret < 0 ) {
|
2017-11-13 00:42:34 +08:00
|
|
|
Error("Could not initialize stream parameteres");
|
2017-12-05 07:06:42 +08:00
|
|
|
return false;
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
}
|
2017-11-13 00:42:34 +08:00
|
|
|
#else
|
2017-11-28 00:28:36 +08:00
|
|
|
avcodec_copy_context(video_out_stream->codec, video_out_ctx);
|
2019-09-13 04:52:59 +08:00
|
|
|
#endif
|
2020-12-16 05:54:35 +08:00
|
|
|
// Only set orientation if doing passthrough, otherwise the frame image will be rotated
|
|
|
|
Monitor::Orientation orientation = monitor->getOrientation();
|
|
|
|
if ( orientation ) {
|
2021-01-16 06:02:26 +08:00
|
|
|
Debug(3, "Have orientation %d", orientation);
|
2020-12-16 05:54:35 +08:00
|
|
|
if ( orientation == Monitor::ROTATE_0 ) {
|
|
|
|
} else if ( orientation == Monitor::ROTATE_90 ) {
|
|
|
|
ret = av_dict_set(&video_out_stream->metadata, "rotate", "90", 0);
|
|
|
|
if ( ret < 0 ) Warning("%s:%d: title set failed", __FILE__, __LINE__);
|
|
|
|
} else if ( orientation == Monitor::ROTATE_180 ) {
|
|
|
|
ret = av_dict_set(&video_out_stream->metadata, "rotate", "180", 0);
|
|
|
|
if ( ret < 0 ) Warning("%s:%d: title set failed", __FILE__, __LINE__);
|
|
|
|
} else if ( orientation == Monitor::ROTATE_270 ) {
|
|
|
|
ret = av_dict_set(&video_out_stream->metadata, "rotate", "270", 0);
|
|
|
|
if ( ret < 0 ) Warning("%s:%d: title set failed", __FILE__, __LINE__);
|
|
|
|
} else {
|
|
|
|
Warning("Unsupported Orientation(%d)", orientation);
|
|
|
|
}
|
|
|
|
} // end if orientation
|
2021-01-27 01:24:43 +08:00
|
|
|
video_out_stream->time_base = video_in_stream ? video_in_stream->time_base : AV_TIME_BASE_Q;
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2021-01-28 05:14:07 +08:00
|
|
|
if ( audio_in_stream and audio_in_ctx ) {
|
|
|
|
Debug(2, "Have audio_in_stream %p", audio_in_stream);
|
2017-11-13 00:42:34 +08:00
|
|
|
audio_in_stream_index = audio_in_stream->index;
|
2019-04-02 02:02:39 +08:00
|
|
|
|
|
|
|
if (
|
2017-06-16 01:02:54 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2019-04-02 02:02:39 +08:00
|
|
|
audio_in_stream->codecpar->codec_id
|
2017-06-03 04:52:52 +08:00
|
|
|
#else
|
2019-04-02 02:02:39 +08:00
|
|
|
audio_in_stream->codec->codec_id
|
2017-06-03 04:52:52 +08:00
|
|
|
#endif
|
2020-12-31 10:25:12 +08:00
|
|
|
!= AV_CODEC_ID_AAC
|
2019-04-26 02:49:16 +08:00
|
|
|
) {
|
2017-06-03 04:52:52 +08:00
|
|
|
|
2019-04-04 01:23:00 +08:00
|
|
|
audio_out_codec = avcodec_find_encoder(AV_CODEC_ID_AAC);
|
|
|
|
if ( !audio_out_codec ) {
|
|
|
|
Error("Could not find codec for AAC");
|
2020-12-31 10:25:12 +08:00
|
|
|
} else {
|
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
|
|
|
audio_in_ctx = avcodec_alloc_context3(audio_out_codec);
|
|
|
|
ret = avcodec_parameters_to_context(audio_in_ctx,
|
|
|
|
audio_in_stream->codecpar);
|
|
|
|
audio_in_ctx->time_base = audio_in_stream->time_base;
|
|
|
|
#else
|
|
|
|
audio_in_ctx = audio_in_stream->codec;
|
|
|
|
#endif
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2019-04-02 02:02:39 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2020-12-31 10:25:12 +08:00
|
|
|
audio_out_ctx = avcodec_alloc_context3(audio_out_codec);
|
|
|
|
if ( !audio_out_ctx ) {
|
|
|
|
Error("could not allocate codec ctx for AAC");
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-10 04:13:32 +08:00
|
|
|
#else
|
2020-12-31 10:25:12 +08:00
|
|
|
audio_out_ctx = audio_out_stream->codec;
|
2019-04-02 02:02:39 +08:00
|
|
|
#endif
|
2020-12-31 10:25:12 +08:00
|
|
|
audio_out_stream = avformat_new_stream(oc, audio_out_codec);
|
|
|
|
audio_out_stream->time_base = audio_in_stream->time_base;
|
2017-06-03 04:52:52 +08:00
|
|
|
|
2020-12-31 10:25:12 +08:00
|
|
|
if ( !setup_resampler() ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} // end if found AAC codec
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
} else {
|
2019-04-04 01:23:00 +08:00
|
|
|
Debug(2, "Got AAC");
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2020-12-31 10:25:12 +08:00
|
|
|
// normally we want to pass params from codec in here
|
|
|
|
// but since we are doing audio passthrough we don't care
|
|
|
|
audio_out_stream = avformat_new_stream(oc, audio_out_codec);
|
2017-12-01 08:26:51 +08:00
|
|
|
if ( !audio_out_stream ) {
|
2019-04-04 01:23:00 +08:00
|
|
|
Error("Could not allocate new stream");
|
2019-04-26 02:49:16 +08:00
|
|
|
return false;
|
2019-04-04 01:23:00 +08:00
|
|
|
}
|
|
|
|
audio_out_stream->time_base = audio_in_stream->time_base;
|
|
|
|
|
2017-06-16 01:02:54 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2019-04-04 01:23:00 +08:00
|
|
|
// Just use the ctx to copy the parameters over
|
2019-04-04 02:51:10 +08:00
|
|
|
audio_out_ctx = avcodec_alloc_context3(audio_out_codec);
|
2019-04-04 01:23:00 +08:00
|
|
|
if ( !audio_out_ctx ) {
|
|
|
|
Error("Could not allocate new output_context");
|
2019-04-26 02:49:16 +08:00
|
|
|
return false;
|
2019-04-04 01:23:00 +08:00
|
|
|
}
|
2017-06-14 05:06:50 +08:00
|
|
|
|
2019-04-04 01:23:00 +08:00
|
|
|
// We don't actually care what the time_base is..
|
2021-01-26 07:50:35 +08:00
|
|
|
audio_out_ctx->time_base = audio_in_ctx->time_base;
|
2019-04-04 01:23:00 +08:00
|
|
|
|
|
|
|
// Copy params from instream to ctx
|
|
|
|
ret = avcodec_parameters_to_context(
|
|
|
|
audio_out_ctx, audio_in_stream->codecpar);
|
|
|
|
if ( ret < 0 ) {
|
|
|
|
Error("Unable to copy audio params to ctx %s",
|
2018-02-28 23:17:16 +08:00
|
|
|
av_make_error_string(ret).c_str());
|
2019-04-04 01:23:00 +08:00
|
|
|
}
|
|
|
|
ret = avcodec_parameters_from_context(
|
|
|
|
audio_out_stream->codecpar, audio_out_ctx);
|
|
|
|
if ( ret < 0 ) {
|
|
|
|
Error("Unable to copy audio params to stream %s",
|
2018-02-28 23:17:16 +08:00
|
|
|
av_make_error_string(ret).c_str());
|
2019-04-04 01:23:00 +08:00
|
|
|
}
|
2017-06-01 08:44:23 +08:00
|
|
|
#else
|
2019-04-04 01:23:00 +08:00
|
|
|
audio_out_ctx = audio_out_stream->codec;
|
|
|
|
ret = avcodec_copy_context(audio_out_ctx, audio_in_stream->codec);
|
|
|
|
if ( ret < 0 ) {
|
|
|
|
Error("Unable to copy audio ctx %s",
|
2018-02-28 23:17:16 +08:00
|
|
|
av_make_error_string(ret).c_str());
|
2020-08-26 07:45:48 +08:00
|
|
|
audio_out_stream = nullptr;
|
2021-01-28 23:17:23 +08:00
|
|
|
return false;
|
2020-12-31 10:25:12 +08:00
|
|
|
} // end if
|
2019-04-04 01:23:00 +08:00
|
|
|
audio_out_ctx->codec_tag = 0;
|
2017-06-01 08:44:23 +08:00
|
|
|
#endif
|
2019-04-04 01:23:00 +08:00
|
|
|
|
|
|
|
if ( audio_out_ctx->channels > 1 ) {
|
|
|
|
Warning("Audio isn't mono, changing it.");
|
|
|
|
audio_out_ctx->channels = 1;
|
|
|
|
} else {
|
|
|
|
Debug(3, "Audio is mono");
|
|
|
|
}
|
2018-02-28 23:17:16 +08:00
|
|
|
} // end if is AAC
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2019-04-04 01:23:00 +08:00
|
|
|
if ( oc->oformat->flags & AVFMT_GLOBALHEADER ) {
|
2017-11-13 00:42:34 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0)
|
2019-04-04 01:23:00 +08:00
|
|
|
audio_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
2017-11-13 00:42:34 +08:00
|
|
|
#else
|
2019-04-04 01:23:00 +08:00
|
|
|
audio_out_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
2017-11-13 00:42:34 +08:00
|
|
|
#endif
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
}
|
2019-10-23 21:25:16 +08:00
|
|
|
|
|
|
|
// We will assume that subsequent stream allocations will increase the index
|
|
|
|
max_stream_index = audio_out_stream->index;
|
2017-08-23 22:37:32 +08:00
|
|
|
} // end if audio_in_stream
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2019-10-23 21:25:16 +08:00
|
|
|
//max_stream_index is 0-based, so add 1
|
|
|
|
next_dts = new int64_t[max_stream_index+1];
|
|
|
|
for ( int i = 0; i <= max_stream_index; i++ ) {
|
|
|
|
next_dts[i] = 0;
|
|
|
|
}
|
2017-09-26 03:28:14 +08:00
|
|
|
|
2017-08-23 22:37:32 +08:00
|
|
|
/* open the out file, if needed */
|
2018-02-28 23:17:16 +08:00
|
|
|
if ( !(out_format->flags & AVFMT_NOFILE) ) {
|
2020-08-26 07:45:48 +08:00
|
|
|
ret = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE, nullptr, nullptr);
|
2018-12-03 23:33:53 +08:00
|
|
|
if ( ret < 0 ) {
|
2018-12-27 01:02:00 +08:00
|
|
|
Error("Could not open out file '%s': %s", filename,
|
2018-02-28 23:17:16 +08:00
|
|
|
av_make_error_string(ret).c_str());
|
2017-09-26 03:28:14 +08:00
|
|
|
return false;
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-23 22:37:32 +08:00
|
|
|
zm_dump_stream_format(oc, 0, 0, 1);
|
2020-07-31 03:06:05 +08:00
|
|
|
if ( audio_out_stream ) zm_dump_stream_format(oc, 1, 0, 1);
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2020-08-26 07:45:48 +08:00
|
|
|
AVDictionary *opts = nullptr;
|
2020-07-31 03:06:05 +08:00
|
|
|
|
2020-08-08 05:52:43 +08:00
|
|
|
std::string option_string = monitor->GetEncoderOptions();
|
2020-07-31 03:06:05 +08:00
|
|
|
ret = av_dict_parse_string(&opts, option_string.c_str(), "=", ",\n", 0);
|
|
|
|
if ( ret < 0 ) {
|
|
|
|
Warning("Could not parse ffmpeg output options '%s'", option_string.c_str());
|
|
|
|
}
|
|
|
|
|
2020-08-26 07:45:48 +08:00
|
|
|
const AVDictionaryEntry *movflags_entry = av_dict_get(opts, "movflags", nullptr, AV_DICT_MATCH_CASE);
|
2020-07-31 03:06:05 +08:00
|
|
|
if ( !movflags_entry ) {
|
|
|
|
Debug(1, "setting movflags to frag_keyframe+empty_moov");
|
|
|
|
// Shiboleth reports that this may break seeking in mp4 before it downloads
|
|
|
|
av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
|
|
|
|
} else {
|
|
|
|
Debug(1, "using movflags %s", movflags_entry->value);
|
|
|
|
}
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( (ret = avformat_write_header(oc, &opts)) < 0 ) {
|
2020-07-31 03:16:31 +08:00
|
|
|
Warning("Unable to set movflags trying with defaults.");
|
2020-08-26 07:45:48 +08:00
|
|
|
ret = avformat_write_header(oc, nullptr);
|
2017-11-13 00:42:34 +08:00
|
|
|
} else if ( av_dict_count(opts) != 0 ) {
|
2020-07-31 03:16:31 +08:00
|
|
|
Info("some options not used, turn on debugging for a list.");
|
2020-08-26 07:45:48 +08:00
|
|
|
AVDictionaryEntry *e = nullptr;
|
|
|
|
while ( (e = av_dict_get(opts, "", e, AV_DICT_IGNORE_SUFFIX)) != nullptr ) {
|
2020-07-31 03:16:31 +08:00
|
|
|
Debug(1, "Encoder Option %s=>%s", e->key, e->value);
|
|
|
|
if ( !e->value ) {
|
2020-08-26 07:45:48 +08:00
|
|
|
av_dict_set(&opts, e->key, nullptr, 0);
|
2020-07-31 03:16:31 +08:00
|
|
|
}
|
|
|
|
}
|
2017-05-17 00:04:56 +08:00
|
|
|
}
|
2018-10-21 05:31:14 +08:00
|
|
|
if ( opts ) av_dict_free(&opts);
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( ret < 0 ) {
|
2018-10-21 05:31:14 +08:00
|
|
|
Error("Error occurred when writing out file header to %s: %s",
|
2018-02-28 23:17:16 +08:00
|
|
|
filename, av_make_error_string(ret).c_str());
|
2018-09-27 03:34:01 +08:00
|
|
|
avio_closep(&oc->pb);
|
2017-09-26 03:28:14 +08:00
|
|
|
return false;
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
}
|
2017-12-17 06:08:21 +08:00
|
|
|
|
2017-12-15 04:56:22 +08:00
|
|
|
zm_dump_stream_format(oc, 0, 0, 1);
|
|
|
|
if (audio_out_stream) zm_dump_stream_format(oc, 1, 0, 1);
|
2017-09-26 03:28:14 +08:00
|
|
|
return true;
|
2017-11-13 00:42:34 +08:00
|
|
|
} // end bool VideoStore::open()
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2018-04-15 02:58:25 +08:00
|
|
|
void VideoStore::flush_codecs() {
|
2020-05-03 06:03:42 +08:00
|
|
|
int ret;
|
2018-04-15 02:58:25 +08:00
|
|
|
// The codec queues data. We need to send a flush command and out
|
|
|
|
// whatever we get. Failures are not fatal.
|
2020-12-31 10:25:12 +08:00
|
|
|
AVPacket pkt;
|
|
|
|
// Without these we seg fault becuse av_init_packet doesn't init them
|
|
|
|
pkt.data = nullptr;
|
|
|
|
pkt.size = 0;
|
2021-01-16 06:02:26 +08:00
|
|
|
av_init_packet(&pkt);
|
2018-01-04 23:07:51 +08:00
|
|
|
|
2018-04-15 02:58:25 +08:00
|
|
|
// I got crashes if the codec didn't do DELAY, so let's test for it.
|
|
|
|
if ( video_out_ctx->codec && ( video_out_ctx->codec->capabilities &
|
2017-11-13 00:42:34 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2018-04-15 02:58:25 +08:00
|
|
|
AV_CODEC_CAP_DELAY
|
2017-11-13 00:42:34 +08:00
|
|
|
#else
|
2018-04-15 02:58:25 +08:00
|
|
|
CODEC_CAP_DELAY
|
2017-11-13 00:42:34 +08:00
|
|
|
#endif
|
2018-04-15 02:58:25 +08:00
|
|
|
) ) {
|
2021-01-28 23:17:23 +08:00
|
|
|
while ( (ret = zm_send_frame_receive_packet(video_out_ctx, nullptr, pkt) ) > 0 ) {
|
2018-04-15 02:58:25 +08:00
|
|
|
// Put encoder into flushing mode
|
2020-05-03 06:03:42 +08:00
|
|
|
write_packet(&pkt, video_out_stream);
|
2018-04-15 02:58:25 +08:00
|
|
|
zm_av_packet_unref(&pkt);
|
|
|
|
} // while have buffered frames
|
|
|
|
} // end if have delay capability
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2018-04-15 02:58:25 +08:00
|
|
|
if ( audio_out_codec ) {
|
2020-05-03 06:03:42 +08:00
|
|
|
// The codec queues data. We need to send a flush command and out
|
|
|
|
// whatever we get. Failures are not fatal.
|
|
|
|
|
|
|
|
int frame_size = audio_out_ctx->frame_size;
|
|
|
|
/*
|
|
|
|
* At the end of the file, we pass the remaining samples to
|
|
|
|
* the encoder. */
|
|
|
|
while ( zm_resample_get_delay(resample_ctx, audio_out_ctx->sample_rate) ) {
|
2020-09-29 23:02:40 +08:00
|
|
|
zm_resample_audio(resample_ctx, nullptr, out_frame);
|
2020-05-03 06:03:42 +08:00
|
|
|
|
|
|
|
if ( zm_add_samples_to_fifo(fifo, out_frame) ) {
|
|
|
|
// Should probably set the frame size to what is reported FIXME
|
|
|
|
if ( zm_get_samples_from_fifo(fifo, out_frame) ) {
|
2019-09-13 22:55:30 +08:00
|
|
|
if ( zm_send_frame_receive_packet(audio_out_ctx, out_frame, pkt) ) {
|
2019-09-13 05:59:08 +08:00
|
|
|
pkt.stream_index = audio_out_stream->index;
|
2019-09-13 04:52:59 +08:00
|
|
|
|
2019-09-13 22:55:30 +08:00
|
|
|
av_packet_rescale_ts(&pkt,
|
2019-09-13 04:52:59 +08:00
|
|
|
audio_out_ctx->time_base,
|
|
|
|
audio_out_stream->time_base);
|
2019-09-13 22:55:30 +08:00
|
|
|
write_packet(&pkt, audio_out_stream);
|
2020-12-31 10:25:12 +08:00
|
|
|
zm_av_packet_unref(&pkt);
|
2019-09-13 04:52:59 +08:00
|
|
|
}
|
|
|
|
} // end if data returned from fifo
|
2020-05-03 06:03:42 +08:00
|
|
|
}
|
2019-09-13 04:52:59 +08:00
|
|
|
|
2020-05-03 06:03:42 +08:00
|
|
|
} // end if have buffered samples in the resampler
|
|
|
|
|
|
|
|
Debug(2, "av_audio_fifo_size = %d", av_audio_fifo_size(fifo));
|
|
|
|
while ( av_audio_fifo_size(fifo) > 0 ) {
|
|
|
|
/* Take one frame worth of audio samples from the FIFO buffer,
|
|
|
|
* encode it and write it to the output file. */
|
|
|
|
|
|
|
|
Debug(1, "Remaining samples in fifo for AAC codec frame_size %d > fifo size %d",
|
|
|
|
frame_size, av_audio_fifo_size(fifo));
|
|
|
|
|
|
|
|
// SHould probably set the frame size to what is reported FIXME
|
|
|
|
if ( av_audio_fifo_read(fifo, (void **)out_frame->data, frame_size) ) {
|
|
|
|
if ( zm_send_frame_receive_packet(audio_out_ctx, out_frame, pkt) ) {
|
|
|
|
pkt.stream_index = audio_out_stream->index;
|
2018-01-04 23:07:51 +08:00
|
|
|
|
2020-05-03 06:03:42 +08:00
|
|
|
av_packet_rescale_ts(&pkt,
|
|
|
|
audio_out_ctx->time_base,
|
|
|
|
audio_out_stream->time_base);
|
|
|
|
write_packet(&pkt, audio_out_stream);
|
2020-12-31 10:25:12 +08:00
|
|
|
zm_av_packet_unref(&pkt);
|
2019-09-13 22:55:30 +08:00
|
|
|
}
|
2020-05-03 06:03:42 +08:00
|
|
|
} // end if data returned from fifo
|
|
|
|
} // end while still data in the fifo
|
2019-07-12 05:56:53 +08:00
|
|
|
|
2019-04-01 23:13:14 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
|
|
|
// Put encoder into flushing mode
|
2020-08-26 07:45:48 +08:00
|
|
|
avcodec_send_frame(audio_out_ctx, nullptr);
|
2019-04-01 23:13:14 +08:00
|
|
|
#endif
|
2018-01-04 23:07:51 +08:00
|
|
|
|
2020-05-03 06:03:42 +08:00
|
|
|
while (1) {
|
|
|
|
if ( ! zm_receive_packet(audio_out_ctx, pkt) ) {
|
|
|
|
Debug(1, "No more packets");
|
|
|
|
break;
|
|
|
|
}
|
2018-01-04 23:07:51 +08:00
|
|
|
|
2020-05-03 06:03:42 +08:00
|
|
|
dumpPacket(&pkt, "raw from encoder");
|
|
|
|
av_packet_rescale_ts(&pkt, audio_out_ctx->time_base, audio_out_stream->time_base);
|
|
|
|
dumpPacket(audio_out_stream, &pkt, "writing flushed packet");
|
|
|
|
write_packet(&pkt, audio_out_stream);
|
|
|
|
zm_av_packet_unref(&pkt);
|
|
|
|
} // while have buffered frames
|
|
|
|
} // end if audio_out_codec
|
|
|
|
} // end flush_codecs
|
2018-02-28 23:17:16 +08:00
|
|
|
|
2018-04-15 02:58:25 +08:00
|
|
|
VideoStore::~VideoStore() {
|
|
|
|
if ( oc->pb ) {
|
2021-01-27 01:24:43 +08:00
|
|
|
flush_codecs();
|
2018-01-04 23:07:51 +08:00
|
|
|
|
|
|
|
// Flush Queues
|
2019-04-26 02:49:16 +08:00
|
|
|
Debug(1, "Flushing interleaved queues");
|
2020-08-26 07:45:48 +08:00
|
|
|
av_interleaved_write_frame(oc, nullptr);
|
2018-01-04 23:07:51 +08:00
|
|
|
|
2019-09-13 05:59:08 +08:00
|
|
|
Debug(1, "Writing trailer");
|
2018-01-04 23:07:51 +08:00
|
|
|
/* Write the trailer before close */
|
2018-01-05 23:06:18 +08:00
|
|
|
if ( int rc = av_write_trailer(oc) ) {
|
2018-01-04 23:07:51 +08:00
|
|
|
Error("Error writing trailer %s", av_err2str(rc));
|
|
|
|
} else {
|
2018-09-27 03:34:01 +08:00
|
|
|
Debug(3, "Success Writing trailer");
|
2018-01-04 23:07:51 +08:00
|
|
|
}
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2018-09-09 23:34:12 +08:00
|
|
|
// When will we not be using a file ?
|
2018-01-04 23:07:51 +08:00
|
|
|
if ( !(out_format->flags & AVFMT_NOFILE) ) {
|
|
|
|
/* Close the out file. */
|
|
|
|
Debug(2, "Closing");
|
2019-01-05 23:15:22 +08:00
|
|
|
if ( int rc = avio_close(oc->pb) ) {
|
2018-01-04 23:07:51 +08:00
|
|
|
Error("Error closing avio %s", av_err2str(rc));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Debug(3, "Not closing avio because we are not writing to a file.");
|
|
|
|
}
|
2020-12-31 10:25:12 +08:00
|
|
|
oc->pb = nullptr;
|
2018-01-05 23:06:18 +08:00
|
|
|
} // end if oc->pb
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
|
|
|
// I wonder if we should be closing the file first.
|
2017-08-23 22:37:32 +08:00
|
|
|
// I also wonder if we really need to be doing all the ctx
|
|
|
|
// allocation/de-allocation constantly, or whether we can just re-use it.
|
|
|
|
// Just do a file open/close/writeheader/etc.
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
// What if we were only doing audio recording?
|
2018-02-28 23:17:16 +08:00
|
|
|
|
2018-01-11 03:19:47 +08:00
|
|
|
if ( video_out_stream ) {
|
2020-08-26 07:45:48 +08:00
|
|
|
video_in_ctx = nullptr;
|
2017-11-28 22:50:09 +08:00
|
|
|
|
2020-12-31 10:25:12 +08:00
|
|
|
Debug(4, "Freeing video_out_ctx");
|
2019-04-04 01:23:00 +08:00
|
|
|
avcodec_free_context(&video_out_ctx);
|
2021-01-26 07:50:35 +08:00
|
|
|
Debug(1, "Success freeing video_out_ctx %p", video_out_codec);
|
2020-12-31 10:25:12 +08:00
|
|
|
video_out_codec = nullptr;
|
2018-12-05 07:23:08 +08:00
|
|
|
} // end if video_out_stream
|
|
|
|
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( audio_out_stream ) {
|
2017-11-28 22:50:09 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2018-12-05 07:23:08 +08:00
|
|
|
// We allocate and copy in newer ffmpeg, so need to free it
|
2021-01-26 07:50:35 +08:00
|
|
|
//avcodec_free_context(&audio_in_ctx);
|
2017-11-28 22:50:09 +08:00
|
|
|
#endif
|
2021-01-26 07:50:35 +08:00
|
|
|
//Debug(4, "Success freeing audio_in_ctx");
|
2020-12-31 10:25:12 +08:00
|
|
|
audio_in_codec = nullptr;
|
2018-12-05 07:23:08 +08:00
|
|
|
|
2019-04-02 02:02:39 +08:00
|
|
|
if ( audio_out_ctx ) {
|
|
|
|
Debug(4, "Success closing audio_out_ctx");
|
2019-04-04 01:23:00 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2019-04-04 02:25:18 +08:00
|
|
|
avcodec_free_context(&audio_out_ctx);
|
2017-11-28 22:50:09 +08:00
|
|
|
#endif
|
2019-04-02 02:02:39 +08:00
|
|
|
}
|
2019-04-04 01:23:00 +08:00
|
|
|
|
2018-12-21 02:38:11 +08:00
|
|
|
#if defined(HAVE_LIBAVRESAMPLE) || defined(HAVE_LIBSWRESAMPLE)
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( resample_ctx ) {
|
2019-02-16 06:26:30 +08:00
|
|
|
if ( fifo ) {
|
|
|
|
av_audio_fifo_free(fifo);
|
2020-08-26 07:45:48 +08:00
|
|
|
fifo = nullptr;
|
2019-02-16 06:26:30 +08:00
|
|
|
}
|
2019-09-14 04:06:25 +08:00
|
|
|
#if defined(HAVE_LIBSWRESAMPLE)
|
2018-12-21 02:38:11 +08:00
|
|
|
swr_free(&resample_ctx);
|
2019-04-04 01:23:00 +08:00
|
|
|
#else
|
|
|
|
#if defined(HAVE_LIBAVRESAMPLE)
|
2017-08-23 22:37:32 +08:00
|
|
|
avresample_close(resample_ctx);
|
|
|
|
avresample_free(&resample_ctx);
|
2019-04-04 01:23:00 +08:00
|
|
|
#endif
|
|
|
|
#endif
|
2017-05-17 00:04:56 +08:00
|
|
|
}
|
2018-04-12 23:29:35 +08:00
|
|
|
if ( in_frame ) {
|
2017-08-23 22:37:32 +08:00
|
|
|
av_frame_free(&in_frame);
|
2020-08-26 07:45:48 +08:00
|
|
|
in_frame = nullptr;
|
2017-08-12 00:03:37 +08:00
|
|
|
}
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( out_frame ) {
|
2017-08-23 22:37:32 +08:00
|
|
|
av_frame_free(&out_frame);
|
2020-08-26 07:45:48 +08:00
|
|
|
out_frame = nullptr;
|
2017-08-12 00:03:37 +08:00
|
|
|
}
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( converted_in_samples ) {
|
2017-08-23 22:37:32 +08:00
|
|
|
av_free(converted_in_samples);
|
2020-08-26 07:45:48 +08:00
|
|
|
converted_in_samples = nullptr;
|
2017-08-15 06:22:52 +08:00
|
|
|
}
|
2017-05-17 00:04:56 +08:00
|
|
|
#endif
|
2018-04-15 02:58:25 +08:00
|
|
|
} // end if audio_out_stream
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2020-12-31 10:25:12 +08:00
|
|
|
Debug(4, "free context");
|
2019-04-04 01:23:00 +08:00
|
|
|
/* free the streams */
|
2017-08-24 03:05:44 +08:00
|
|
|
avformat_free_context(oc);
|
2019-10-23 21:25:16 +08:00
|
|
|
delete[] next_dts;
|
2020-12-31 10:25:12 +08:00
|
|
|
next_dts = nullptr;
|
2018-04-12 23:29:35 +08:00
|
|
|
} // VideoStore::~VideoStore()
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2017-05-17 00:04:56 +08:00
|
|
|
bool VideoStore::setup_resampler() {
|
2018-12-21 02:38:11 +08:00
|
|
|
#if !defined(HAVE_LIBSWRESAMPLE) && !defined(HAVE_LIBAVRESAMPLE)
|
|
|
|
Error(
|
|
|
|
"Not built with resample library. "
|
|
|
|
"Cannot do audio conversion to AAC");
|
|
|
|
return false;
|
|
|
|
#else
|
2019-09-09 04:10:57 +08:00
|
|
|
int ret;
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2019-04-26 02:49:16 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2017-08-23 22:37:32 +08:00
|
|
|
// Newer ffmpeg wants to keep everything separate... so have to lookup our own
|
|
|
|
// decoder, can't reuse the one from the camera.
|
2017-11-28 22:50:09 +08:00
|
|
|
audio_in_codec =
|
2017-08-23 22:37:32 +08:00
|
|
|
avcodec_find_decoder(audio_in_stream->codecpar->codec_id);
|
2019-04-04 01:23:00 +08:00
|
|
|
audio_in_ctx = avcodec_alloc_context3(audio_in_codec);
|
2019-04-04 02:25:18 +08:00
|
|
|
// Copy params from instream to ctx
|
|
|
|
ret = avcodec_parameters_to_context(
|
|
|
|
audio_in_ctx, audio_in_stream->codecpar);
|
2018-12-03 23:33:53 +08:00
|
|
|
if ( ret < 0 ) {
|
2019-04-04 02:25:18 +08:00
|
|
|
Error("Unable to copy audio params to ctx %s",
|
|
|
|
av_make_error_string(ret).c_str());
|
2017-06-03 04:52:52 +08:00
|
|
|
}
|
|
|
|
|
2019-04-04 01:23:00 +08:00
|
|
|
#else
|
2019-04-02 02:02:39 +08:00
|
|
|
// codec is already open in ffmpeg_camera
|
2019-04-04 01:23:00 +08:00
|
|
|
audio_in_ctx = audio_in_stream->codec;
|
2019-09-10 05:09:01 +08:00
|
|
|
audio_in_codec = reinterpret_cast<const AVCodec *>(audio_in_ctx->codec);
|
2019-09-14 04:06:25 +08:00
|
|
|
if ( !audio_in_codec ) {
|
|
|
|
audio_in_codec = avcodec_find_decoder(audio_in_stream->codec->codec_id);
|
|
|
|
}
|
|
|
|
if ( !audio_in_codec ) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-04-04 01:23:00 +08:00
|
|
|
#endif
|
2017-12-01 11:18:33 +08:00
|
|
|
|
2019-04-04 01:23:00 +08:00
|
|
|
// if the codec is already open, nothing is done.
|
2020-08-26 07:45:48 +08:00
|
|
|
if ( (ret = avcodec_open2(audio_in_ctx, audio_in_codec, nullptr)) < 0 ) {
|
2019-04-04 02:25:18 +08:00
|
|
|
Error("Can't open audio in codec!");
|
2017-05-17 00:04:56 +08:00
|
|
|
return false;
|
|
|
|
}
|
2017-06-03 04:52:52 +08:00
|
|
|
|
2019-04-04 01:23:00 +08:00
|
|
|
Debug(2, "Got something other than AAC (%s)", audio_in_codec->name);
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2018-12-21 02:38:11 +08:00
|
|
|
// Some formats (i.e. WAV) do not produce the proper channel layout
|
2019-01-05 23:15:22 +08:00
|
|
|
if ( audio_in_ctx->channel_layout == 0 ) {
|
|
|
|
Debug(2, "Setting input channel layout to mono");
|
2019-02-13 22:42:03 +08:00
|
|
|
// Perhaps we should not be modifying the audio_in_ctx....
|
2018-12-21 02:38:11 +08:00
|
|
|
audio_in_ctx->channel_layout = av_get_channel_layout("mono");
|
2019-01-05 23:15:22 +08:00
|
|
|
}
|
2017-05-17 00:04:56 +08:00
|
|
|
|
|
|
|
/* put sample parameters */
|
2019-01-05 23:15:22 +08:00
|
|
|
audio_out_ctx->bit_rate = audio_in_ctx->bit_rate <= 32768 ? audio_in_ctx->bit_rate : 32768;
|
2017-08-23 22:37:32 +08:00
|
|
|
audio_out_ctx->sample_rate = audio_in_ctx->sample_rate;
|
2017-12-09 02:46:02 +08:00
|
|
|
audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt;
|
2017-08-23 22:37:32 +08:00
|
|
|
audio_out_ctx->channels = audio_in_ctx->channels;
|
|
|
|
audio_out_ctx->channel_layout = audio_in_ctx->channel_layout;
|
|
|
|
audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt;
|
2019-04-04 04:51:41 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100)
|
2019-01-14 23:48:29 +08:00
|
|
|
if ( !audio_out_ctx->channel_layout ) {
|
2018-10-25 01:45:33 +08:00
|
|
|
Debug(3, "Correcting channel layout from (%d) to (%d)",
|
|
|
|
audio_out_ctx->channel_layout,
|
|
|
|
av_get_default_channel_layout(audio_out_ctx->channels)
|
|
|
|
);
|
|
|
|
audio_out_ctx->channel_layout = av_get_default_channel_layout(audio_out_ctx->channels);
|
|
|
|
}
|
2019-04-04 04:51:41 +08:00
|
|
|
#endif
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( audio_out_codec->supported_samplerates ) {
|
2017-05-17 00:04:56 +08:00
|
|
|
int found = 0;
|
2019-02-16 06:52:51 +08:00
|
|
|
for ( unsigned int i = 0; audio_out_codec->supported_samplerates[i]; i++ ) {
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( audio_out_ctx->sample_rate ==
|
2018-12-03 23:33:53 +08:00
|
|
|
audio_out_codec->supported_samplerates[i] ) {
|
2017-05-17 00:04:56 +08:00
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( found ) {
|
2019-09-13 04:52:59 +08:00
|
|
|
Debug(3, "Sample rate is good %d", audio_out_ctx->sample_rate);
|
2017-05-17 00:04:56 +08:00
|
|
|
} else {
|
2017-08-23 22:37:32 +08:00
|
|
|
audio_out_ctx->sample_rate =
|
2018-04-15 02:58:25 +08:00
|
|
|
audio_out_codec->supported_samplerates[0];
|
2018-12-03 23:33:53 +08:00
|
|
|
Debug(1, "Sample rate is no good, setting to (%d)",
|
2017-08-23 22:37:32 +08:00
|
|
|
audio_out_codec->supported_samplerates[0]);
|
2017-05-17 00:04:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-23 22:37:32 +08:00
|
|
|
/* check that the encoder supports s16 pcm in */
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( !check_sample_fmt(audio_out_codec, audio_out_ctx->sample_fmt) ) {
|
2017-08-23 22:37:32 +08:00
|
|
|
Debug(3, "Encoder does not support sample format %s, setting to FLTP",
|
2018-04-15 02:58:25 +08:00
|
|
|
av_get_sample_fmt_name(audio_out_ctx->sample_fmt));
|
2017-08-23 22:37:32 +08:00
|
|
|
audio_out_ctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
|
2017-05-17 00:04:56 +08:00
|
|
|
}
|
|
|
|
|
2017-12-09 02:46:02 +08:00
|
|
|
// Example code doesn't set the codec tb. I think it just uses whatever defaults
|
|
|
|
//audio_out_ctx->time_base = (AVRational){1, audio_out_ctx->sample_rate};
|
2017-06-03 04:52:52 +08:00
|
|
|
|
2020-08-26 07:45:48 +08:00
|
|
|
AVDictionary *opts = nullptr;
|
2017-12-13 04:29:19 +08:00
|
|
|
// Needed to allow AAC
|
2017-12-13 01:38:30 +08:00
|
|
|
if ( (ret = av_dict_set(&opts, "strict", "experimental", 0)) < 0 ) {
|
|
|
|
Error("Couldn't set experimental");
|
|
|
|
}
|
2017-08-23 22:37:32 +08:00
|
|
|
ret = avcodec_open2(audio_out_ctx, audio_out_codec, &opts);
|
2017-05-17 00:04:56 +08:00
|
|
|
av_dict_free(&opts);
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( ret < 0 ) {
|
2018-12-05 07:23:08 +08:00
|
|
|
Error("could not open codec (%d) (%s)",
|
|
|
|
ret, av_make_error_string(ret).c_str());
|
2020-08-26 07:45:48 +08:00
|
|
|
audio_out_codec = nullptr;
|
|
|
|
audio_out_ctx = nullptr;
|
|
|
|
audio_out_stream = nullptr;
|
2017-05-17 00:04:56 +08:00
|
|
|
return false;
|
2017-08-23 22:37:32 +08:00
|
|
|
}
|
2019-09-13 04:52:59 +08:00
|
|
|
zm_dump_codec(audio_out_ctx);
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2017-12-09 02:46:02 +08:00
|
|
|
audio_out_stream->time_base = (AVRational){1, audio_out_ctx->sample_rate};
|
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
|
|
|
if ( (ret = avcodec_parameters_from_context(
|
|
|
|
audio_out_stream->codecpar,
|
|
|
|
audio_out_ctx)) < 0 ) {
|
|
|
|
Error("Could not initialize stream parameteres");
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-13 05:26:19 +08:00
|
|
|
zm_dump_codecpar(audio_out_stream->codecpar);
|
2017-12-09 02:46:02 +08:00
|
|
|
#endif
|
|
|
|
|
2019-04-03 02:08:46 +08:00
|
|
|
Debug(3,
|
|
|
|
"Time bases: AUDIO in stream (%d/%d) in codec: (%d/%d) out "
|
|
|
|
"stream: (%d/%d) out codec (%d/%d)",
|
|
|
|
audio_in_stream->time_base.num, audio_in_stream->time_base.den,
|
|
|
|
audio_in_ctx->time_base.num, audio_in_ctx->time_base.den,
|
|
|
|
audio_out_stream->time_base.num, audio_out_stream->time_base.den,
|
|
|
|
audio_out_ctx->time_base.num, audio_out_ctx->time_base.den);
|
|
|
|
|
2019-02-16 06:26:30 +08:00
|
|
|
Debug(1,
|
|
|
|
"Audio in bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
|
|
|
"layout(%d) frame_size(%d)",
|
|
|
|
audio_in_ctx->bit_rate, audio_in_ctx->sample_rate,
|
|
|
|
audio_in_ctx->channels, audio_in_ctx->sample_fmt,
|
|
|
|
audio_in_ctx->channel_layout, audio_in_ctx->frame_size);
|
2017-08-23 22:37:32 +08:00
|
|
|
Debug(1,
|
2018-04-15 02:58:25 +08:00
|
|
|
"Audio out context bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
|
|
|
"layout(%d) frame_size(%d)",
|
|
|
|
audio_out_ctx->bit_rate, audio_out_ctx->sample_rate,
|
|
|
|
audio_out_ctx->channels, audio_out_ctx->sample_fmt,
|
|
|
|
audio_out_ctx->channel_layout, audio_out_ctx->frame_size);
|
2017-08-10 00:50:46 +08:00
|
|
|
|
2017-12-01 20:26:34 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
|
|
|
Debug(1,
|
2018-04-15 02:58:25 +08:00
|
|
|
"Audio out stream bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
|
|
|
"layout(%d) frame_size(%d)",
|
|
|
|
audio_out_stream->codecpar->bit_rate, audio_out_stream->codecpar->sample_rate,
|
|
|
|
audio_out_stream->codecpar->channels, audio_out_stream->codecpar->format,
|
|
|
|
audio_out_stream->codecpar->channel_layout, audio_out_stream->codecpar->frame_size);
|
2017-12-01 20:26:34 +08:00
|
|
|
#else
|
2017-12-01 11:18:33 +08:00
|
|
|
Debug(1,
|
2018-04-15 02:58:25 +08:00
|
|
|
"Audio out bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
|
|
|
"layout(%d) frame_size(%d)",
|
|
|
|
audio_out_stream->codec->bit_rate, audio_out_stream->codec->sample_rate,
|
|
|
|
audio_out_stream->codec->channels, audio_out_stream->codec->sample_fmt,
|
|
|
|
audio_out_stream->codec->channel_layout, audio_out_stream->codec->frame_size);
|
2017-12-01 20:26:34 +08:00
|
|
|
#endif
|
2017-12-01 11:18:33 +08:00
|
|
|
|
2017-05-17 00:04:56 +08:00
|
|
|
/** Create a new frame to store the audio samples. */
|
2017-10-27 01:12:56 +08:00
|
|
|
if ( ! in_frame ) {
|
2017-11-13 00:42:34 +08:00
|
|
|
if (!(in_frame = zm_av_frame_alloc())) {
|
|
|
|
Error("Could not allocate in frame");
|
|
|
|
return false;
|
|
|
|
}
|
2017-10-27 01:12:56 +08:00
|
|
|
}
|
2017-05-17 00:04:56 +08:00
|
|
|
|
|
|
|
/** Create a new frame to store the audio samples. */
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( !(out_frame = zm_av_frame_alloc()) ) {
|
2017-08-23 22:37:32 +08:00
|
|
|
Error("Could not allocate out frame");
|
|
|
|
av_frame_free(&in_frame);
|
2017-05-17 00:04:56 +08:00
|
|
|
return false;
|
|
|
|
}
|
2017-12-09 02:46:02 +08:00
|
|
|
out_frame->sample_rate = audio_out_ctx->sample_rate;
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2019-08-27 04:17:45 +08:00
|
|
|
if ( !(fifo = av_audio_fifo_alloc(
|
2019-02-16 06:26:30 +08:00
|
|
|
audio_out_ctx->sample_fmt,
|
2019-08-27 04:17:45 +08:00
|
|
|
audio_out_ctx->channels, 1)) ) {
|
2019-02-16 06:26:30 +08:00
|
|
|
Error("Could not allocate FIFO");
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-14 04:06:25 +08:00
|
|
|
#if defined(HAVE_LIBSWRESAMPLE)
|
2020-08-26 07:45:48 +08:00
|
|
|
resample_ctx = swr_alloc_set_opts(nullptr,
|
2019-02-13 05:40:27 +08:00
|
|
|
audio_out_ctx->channel_layout,
|
2018-12-21 02:38:11 +08:00
|
|
|
audio_out_ctx->sample_fmt,
|
|
|
|
audio_out_ctx->sample_rate,
|
2019-02-13 05:40:27 +08:00
|
|
|
audio_in_ctx->channel_layout,
|
2018-12-21 02:38:11 +08:00
|
|
|
audio_in_ctx->sample_fmt,
|
|
|
|
audio_in_ctx->sample_rate,
|
2020-08-26 07:45:48 +08:00
|
|
|
0, nullptr);
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( !resample_ctx ) {
|
2018-12-21 02:38:11 +08:00
|
|
|
Error("Could not allocate resample context");
|
|
|
|
av_frame_free(&in_frame);
|
|
|
|
av_frame_free(&out_frame);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ( (ret = swr_init(resample_ctx)) < 0 ) {
|
|
|
|
Error("Could not open resampler");
|
|
|
|
av_frame_free(&in_frame);
|
|
|
|
av_frame_free(&out_frame);
|
|
|
|
swr_free(&resample_ctx);
|
2017-05-17 00:04:56 +08:00
|
|
|
return false;
|
|
|
|
}
|
2019-01-05 23:15:22 +08:00
|
|
|
Debug(1,"Success setting up SWRESAMPLE");
|
2018-12-21 02:38:11 +08:00
|
|
|
#else
|
|
|
|
#if defined(HAVE_LIBAVRESAMPLE)
|
2017-05-17 00:04:56 +08:00
|
|
|
// Setup the audio resampler
|
2017-08-24 03:05:44 +08:00
|
|
|
resample_ctx = avresample_alloc_context();
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2018-12-03 23:33:53 +08:00
|
|
|
if ( !resample_ctx ) {
|
|
|
|
Error("Could not allocate resample ctx");
|
2018-12-21 02:38:11 +08:00
|
|
|
av_frame_free(&in_frame);
|
|
|
|
av_frame_free(&out_frame);
|
2017-05-17 00:04:56 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-12-21 02:38:11 +08:00
|
|
|
av_opt_set_int(resample_ctx, "in_channel_layout",
|
|
|
|
audio_in_ctx->channel_layout, 0);
|
2017-08-23 22:37:32 +08:00
|
|
|
av_opt_set_int(resample_ctx, "in_sample_fmt",
|
2018-12-21 02:38:11 +08:00
|
|
|
audio_in_ctx->sample_fmt, 0);
|
2017-08-23 22:37:32 +08:00
|
|
|
av_opt_set_int(resample_ctx, "in_sample_rate",
|
2018-12-21 02:38:11 +08:00
|
|
|
audio_in_ctx->sample_rate, 0);
|
|
|
|
av_opt_set_int(resample_ctx, "in_channels",
|
|
|
|
audio_in_ctx->channels, 0);
|
2017-08-23 22:37:32 +08:00
|
|
|
av_opt_set_int(resample_ctx, "out_channel_layout",
|
2018-12-21 02:38:11 +08:00
|
|
|
audio_in_ctx->channel_layout, 0);
|
2017-08-23 22:37:32 +08:00
|
|
|
av_opt_set_int(resample_ctx, "out_sample_fmt",
|
2018-04-15 02:58:25 +08:00
|
|
|
audio_out_ctx->sample_fmt, 0);
|
2017-08-23 22:37:32 +08:00
|
|
|
av_opt_set_int(resample_ctx, "out_sample_rate",
|
2018-04-15 02:58:25 +08:00
|
|
|
audio_out_ctx->sample_rate, 0);
|
2017-08-23 22:37:32 +08:00
|
|
|
av_opt_set_int(resample_ctx, "out_channels",
|
2018-04-15 02:58:25 +08:00
|
|
|
audio_out_ctx->channels, 0);
|
2017-08-23 22:37:32 +08:00
|
|
|
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( (ret = avresample_open(resample_ctx)) < 0 ) {
|
2018-12-03 23:33:53 +08:00
|
|
|
Error("Could not open resample ctx");
|
2017-05-17 00:04:56 +08:00
|
|
|
return false;
|
2018-12-03 23:33:53 +08:00
|
|
|
} else {
|
|
|
|
Debug(2, "Success opening resampler");
|
2017-05-17 00:04:56 +08:00
|
|
|
}
|
2018-12-21 02:38:11 +08:00
|
|
|
#endif
|
2018-11-21 22:46:14 +08:00
|
|
|
#endif
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2017-08-23 22:37:32 +08:00
|
|
|
out_frame->nb_samples = audio_out_ctx->frame_size;
|
|
|
|
out_frame->format = audio_out_ctx->sample_fmt;
|
2019-04-04 04:51:41 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100)
|
2019-01-14 23:48:29 +08:00
|
|
|
out_frame->channels = audio_out_ctx->channels;
|
2019-04-04 04:51:41 +08:00
|
|
|
#endif
|
2017-08-23 22:37:32 +08:00
|
|
|
out_frame->channel_layout = audio_out_ctx->channel_layout;
|
2019-01-14 23:48:29 +08:00
|
|
|
out_frame->sample_rate = audio_out_ctx->sample_rate;
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2017-08-23 22:37:32 +08:00
|
|
|
// The codec gives us the frame size, in samples, we calculate the size of the
|
|
|
|
// samples buffer in bytes
|
|
|
|
unsigned int audioSampleBuffer_size = av_samples_get_buffer_size(
|
2020-08-26 07:45:48 +08:00
|
|
|
nullptr, audio_out_ctx->channels,
|
2018-12-03 23:33:53 +08:00
|
|
|
audio_out_ctx->frame_size,
|
2017-08-23 22:37:32 +08:00
|
|
|
audio_out_ctx->sample_fmt, 0);
|
2019-09-10 04:13:32 +08:00
|
|
|
converted_in_samples = reinterpret_cast<uint8_t *>(av_malloc(audioSampleBuffer_size));
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( !converted_in_samples ) {
|
2018-12-03 23:33:53 +08:00
|
|
|
Error("Could not allocate converted in sample pointers");
|
2017-08-23 22:37:32 +08:00
|
|
|
return false;
|
2018-12-03 23:33:53 +08:00
|
|
|
} else {
|
|
|
|
Debug(2, "Frame Size %d, sample buffer size %d", audio_out_ctx->frame_size, audioSampleBuffer_size);
|
2017-08-23 22:37:32 +08:00
|
|
|
}
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2017-08-23 22:37:32 +08:00
|
|
|
// Setup the data pointers in the AVFrame
|
2019-02-13 05:40:27 +08:00
|
|
|
if ( avcodec_fill_audio_frame(
|
|
|
|
out_frame, audio_out_ctx->channels,
|
|
|
|
audio_out_ctx->sample_fmt,
|
|
|
|
(const uint8_t *)converted_in_samples,
|
2019-02-16 06:52:51 +08:00
|
|
|
audioSampleBuffer_size, 0) < 0 ) {
|
2018-12-03 23:33:53 +08:00
|
|
|
Error("Could not allocate converted in sample pointers");
|
2017-08-23 22:37:32 +08:00
|
|
|
return false;
|
|
|
|
}
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2017-08-23 22:37:32 +08:00
|
|
|
return true;
|
2017-05-17 00:04:56 +08:00
|
|
|
#endif
|
2017-08-23 22:37:32 +08:00
|
|
|
} // end bool VideoStore::setup_resampler()
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2020-12-30 01:18:26 +08:00
|
|
|
int VideoStore::writePacket(ZMPacket *ipkt) {
|
2017-11-13 00:42:34 +08:00
|
|
|
if ( ipkt->packet.stream_index == video_in_stream_index ) {
|
2020-12-30 01:18:26 +08:00
|
|
|
return writeVideoFramePacket(ipkt);
|
2017-11-13 00:42:34 +08:00
|
|
|
} else if ( ipkt->packet.stream_index == audio_in_stream_index ) {
|
2020-12-30 01:18:26 +08:00
|
|
|
return writeAudioFramePacket(ipkt);
|
2017-11-13 00:42:34 +08:00
|
|
|
}
|
2021-01-28 23:46:08 +08:00
|
|
|
Error("Unknown stream type in packet (%d) input video stream is (%d) and audio is (%d)",
|
2017-11-13 00:42:34 +08:00
|
|
|
ipkt->packet.stream_index, video_in_stream_index, ( audio_in_stream ? audio_in_stream_index : -1 )
|
|
|
|
);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-26 02:49:16 +08:00
|
|
|
int VideoStore::writeVideoFramePacket(ZMPacket *zm_packet) {
|
2020-05-03 06:03:42 +08:00
|
|
|
int ret;
|
2017-10-27 01:12:56 +08:00
|
|
|
frame_count += 1;
|
2017-11-13 00:42:34 +08:00
|
|
|
|
|
|
|
// if we have to transcode
|
2021-01-07 22:46:35 +08:00
|
|
|
if ( monitor->GetOptVideoWriter() == Monitor::ENCODE ) {
|
2020-12-30 01:18:26 +08:00
|
|
|
Debug(3, "Have encoding video frame count (%d)", frame_count);
|
2017-11-13 00:42:34 +08:00
|
|
|
|
2018-11-21 22:46:14 +08:00
|
|
|
if ( !zm_packet->out_frame ) {
|
2020-12-30 01:18:26 +08:00
|
|
|
Debug(3, "Have no out frame");
|
2018-11-21 22:46:14 +08:00
|
|
|
AVFrame *out_frame = zm_packet->get_out_frame(video_out_ctx);
|
2018-11-21 01:38:17 +08:00
|
|
|
if ( !out_frame ) {
|
2017-11-15 07:32:37 +08:00
|
|
|
Error("Unable to allocate a frame");
|
|
|
|
return 0;
|
|
|
|
}
|
2017-11-15 05:16:07 +08:00
|
|
|
|
2018-11-21 01:38:17 +08:00
|
|
|
if ( !zm_packet->in_frame ) {
|
2021-01-16 00:55:46 +08:00
|
|
|
Debug(4, "Have no in_frame");
|
2017-11-15 05:16:07 +08:00
|
|
|
if ( zm_packet->packet.size ) {
|
2021-01-16 00:55:46 +08:00
|
|
|
Debug(4, "Decoding");
|
2018-11-21 01:38:17 +08:00
|
|
|
if ( !zm_packet->decode(video_in_ctx) ) {
|
2017-11-15 05:16:07 +08:00
|
|
|
Debug(2, "unable to decode yet.");
|
|
|
|
return 0;
|
|
|
|
}
|
2020-12-30 01:18:26 +08:00
|
|
|
// Go straight to out frame
|
2018-11-21 01:38:17 +08:00
|
|
|
swscale.Convert(zm_packet->in_frame, out_frame);
|
2017-11-15 07:32:37 +08:00
|
|
|
} else if ( zm_packet->image ) {
|
2020-12-30 01:18:26 +08:00
|
|
|
Debug(2, "Have an image, convert it");
|
2017-11-15 07:32:37 +08:00
|
|
|
//Go straight to out frame
|
2017-12-02 03:33:51 +08:00
|
|
|
swscale.Convert(
|
|
|
|
zm_packet->image,
|
2017-11-15 07:32:37 +08:00
|
|
|
zm_packet->buffer,
|
2018-12-27 01:02:00 +08:00
|
|
|
zm_packet->codec_imgsize,
|
2020-12-30 01:18:26 +08:00
|
|
|
zm_packet->image->AVPixFormat(),
|
2017-11-15 07:32:37 +08:00
|
|
|
video_out_ctx->pix_fmt,
|
|
|
|
video_out_ctx->width,
|
|
|
|
video_out_ctx->height
|
|
|
|
);
|
2017-11-13 00:42:34 +08:00
|
|
|
|
2017-11-15 07:32:37 +08:00
|
|
|
} else {
|
2021-01-16 00:55:46 +08:00
|
|
|
Error("Have neither in_frame or image in packet %p %d!",
|
|
|
|
zm_packet, zm_packet->image_index);
|
2017-11-15 07:32:37 +08:00
|
|
|
return 0;
|
|
|
|
} // end if has packet or image
|
2017-11-18 07:19:37 +08:00
|
|
|
} else {
|
|
|
|
// Have in_frame.... may need to convert it to out_frame
|
|
|
|
swscale.Convert(zm_packet->in_frame, zm_packet->out_frame);
|
|
|
|
} // end if no in_frame
|
|
|
|
} // end if no out_frame
|
2017-11-13 00:42:34 +08:00
|
|
|
|
2021-01-16 06:02:26 +08:00
|
|
|
//zm_packet->out_frame->coded_picture_number = frame_count;
|
|
|
|
//zm_packet->out_frame->display_picture_number = frame_count;
|
|
|
|
//zm_packet->out_frame->sample_aspect_ratio = (AVRational){ 0, 1 };
|
2021-01-16 00:55:46 +08:00
|
|
|
// Do this to allow the encoder to choose whether to use I/P/B frame
|
2021-01-16 06:02:26 +08:00
|
|
|
//zm_packet->out_frame->pict_type = AV_PICTURE_TYPE_NONE;
|
2021-01-16 00:55:46 +08:00
|
|
|
zm_packet->out_frame->key_frame = zm_packet->keyframe;
|
2017-12-15 23:47:44 +08:00
|
|
|
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
2018-04-15 02:58:25 +08:00
|
|
|
zm_packet->out_frame->pkt_duration = 0;
|
2017-12-15 23:47:44 +08:00
|
|
|
#endif
|
2017-12-06 05:16:52 +08:00
|
|
|
|
2021-01-30 03:04:50 +08:00
|
|
|
if ( !video_first_pts ) {
|
|
|
|
video_first_pts = zm_packet->timestamp->tv_sec * (uint64_t)1000000 + zm_packet->timestamp->tv_usec;
|
|
|
|
Debug(2, "No video_first_pts, set to (%" PRId64 ") secs(%d) usecs(%d)",
|
|
|
|
video_first_pts, zm_packet->timestamp->tv_sec, zm_packet->timestamp->tv_usec);
|
2017-11-18 07:19:37 +08:00
|
|
|
zm_packet->out_frame->pts = 0;
|
2017-05-17 00:04:56 +08:00
|
|
|
} else {
|
2021-01-30 03:04:50 +08:00
|
|
|
uint64_t useconds = ( zm_packet->timestamp->tv_sec * (uint64_t)1000000 + zm_packet->timestamp->tv_usec ) - video_first_pts;
|
2021-01-07 22:46:35 +08:00
|
|
|
zm_packet->out_frame->pts = av_rescale_q(useconds, video_in_stream->time_base, video_out_ctx->time_base);
|
2021-01-16 00:55:46 +08:00
|
|
|
Debug(2, " Setting pts for frame(%d) to (%" PRId64 ") from (start %" PRIu64 " - %" PRIu64 " - secs(%d) usecs(%d)",
|
2021-01-30 03:04:50 +08:00
|
|
|
frame_count, zm_packet->out_frame->pts, video_first_pts, useconds, zm_packet->timestamp->tv_sec, zm_packet->timestamp->tv_usec);
|
2017-11-13 06:02:11 +08:00
|
|
|
}
|
|
|
|
|
2019-04-26 02:49:16 +08:00
|
|
|
av_init_packet(&opkt);
|
2020-12-30 01:18:26 +08:00
|
|
|
opkt.data = nullptr;
|
2019-04-26 02:49:16 +08:00
|
|
|
opkt.size = 0;
|
2017-11-15 07:32:37 +08:00
|
|
|
|
2021-01-07 22:46:35 +08:00
|
|
|
ret = zm_send_frame_receive_packet(video_out_ctx, zm_packet->out_frame, opkt);
|
2021-01-16 00:55:46 +08:00
|
|
|
if ( ret <= 0 ) {
|
|
|
|
if ( ret < 0 ) {
|
|
|
|
Error("Could not send frame (error '%s')", av_make_error_string(ret).c_str());
|
|
|
|
}
|
2021-01-14 23:31:55 +08:00
|
|
|
return ret;
|
2017-05-17 00:04:56 +08:00
|
|
|
}
|
2021-01-16 00:55:46 +08:00
|
|
|
dumpPacket(&opkt, "packet returned by codec");
|
2019-04-26 02:49:16 +08:00
|
|
|
|
2017-12-20 03:06:58 +08:00
|
|
|
// Need to adjust pts/dts values from codec time to stream time
|
2021-01-07 22:46:35 +08:00
|
|
|
if ( opkt.pts != AV_NOPTS_VALUE )
|
2017-12-20 03:06:58 +08:00
|
|
|
opkt.pts = av_rescale_q(opkt.pts, video_out_ctx->time_base, video_out_stream->time_base);
|
2021-01-07 22:46:35 +08:00
|
|
|
if ( opkt.dts != AV_NOPTS_VALUE )
|
2017-12-20 03:06:58 +08:00
|
|
|
opkt.dts = av_rescale_q(opkt.dts, video_out_ctx->time_base, video_out_stream->time_base);
|
2021-01-30 03:04:50 +08:00
|
|
|
Debug(1, "Timebase conversions using %d/%d -> %d/%d",
|
|
|
|
video_out_ctx->time_base.num,
|
|
|
|
video_out_ctx->time_base.den,
|
|
|
|
video_out_stream->time_base.num,
|
|
|
|
video_out_stream->time_base.den);
|
|
|
|
|
2017-11-13 00:42:34 +08:00
|
|
|
|
2021-01-16 00:55:46 +08:00
|
|
|
int64_t duration = 0;
|
2020-12-30 01:18:26 +08:00
|
|
|
if ( zm_packet->in_frame ) {
|
|
|
|
if ( zm_packet->in_frame->pkt_duration ) {
|
|
|
|
duration = av_rescale_q(
|
|
|
|
zm_packet->in_frame->pkt_duration,
|
2018-11-21 22:46:14 +08:00
|
|
|
video_in_stream->time_base,
|
|
|
|
video_out_stream->time_base);
|
2021-01-26 07:50:35 +08:00
|
|
|
Debug(1, "duration from ipkt: pts(%" PRId64 ") = pkt_duration(%" PRId64 ") => (%" PRId64 ") (%d/%d) (%d/%d)",
|
2020-12-30 01:18:26 +08:00
|
|
|
zm_packet->in_frame->pts,
|
|
|
|
zm_packet->in_frame->pkt_duration,
|
|
|
|
duration,
|
|
|
|
video_in_stream->time_base.num,
|
|
|
|
video_in_stream->time_base.den,
|
|
|
|
video_out_stream->time_base.num,
|
|
|
|
video_out_stream->time_base.den
|
|
|
|
);
|
2021-01-30 03:04:50 +08:00
|
|
|
} else if ( video_last_pts != AV_NOPTS_VALUE ) {
|
2020-12-30 01:18:26 +08:00
|
|
|
duration =
|
|
|
|
av_rescale_q(
|
|
|
|
zm_packet->in_frame->pts - video_last_pts,
|
|
|
|
video_in_stream->time_base,
|
|
|
|
video_out_stream->time_base);
|
|
|
|
Debug(1, "duration calc: pts(%" PRId64 ") - last_pts(%" PRId64 ") = (%" PRId64 ") => (%" PRId64 ")",
|
|
|
|
zm_packet->in_frame->pts,
|
|
|
|
video_last_pts,
|
|
|
|
zm_packet->in_frame->pts - video_last_pts,
|
|
|
|
duration
|
|
|
|
);
|
|
|
|
if ( duration <= 0 ) {
|
2021-01-16 00:55:46 +08:00
|
|
|
duration = zm_packet->in_frame->pkt_duration ? zm_packet->in_frame->pkt_duration : av_rescale_q(1, video_in_stream->time_base, video_out_stream->time_base);
|
2020-12-30 01:18:26 +08:00
|
|
|
}
|
|
|
|
} // end if in_frmae->pkt_duration
|
2021-01-30 03:04:50 +08:00
|
|
|
video_last_pts = zm_packet->in_frame->pts;
|
2020-12-30 01:18:26 +08:00
|
|
|
} else {
|
2021-01-16 00:55:46 +08:00
|
|
|
//duration = av_rescale_q(zm_packet->out_frame->pts - video_last_pts, video_in_stream->time_base, video_out_stream->time_base);
|
2020-12-30 01:18:26 +08:00
|
|
|
} // end if in_frmae
|
2018-11-21 22:46:14 +08:00
|
|
|
opkt.duration = duration;
|
|
|
|
|
2021-01-07 22:46:35 +08:00
|
|
|
} else { // Passthrough
|
2017-11-13 00:42:34 +08:00
|
|
|
AVPacket *ipkt = &zm_packet->packet;
|
2017-10-27 01:12:56 +08:00
|
|
|
Debug(3, "Doing passthrough, just copy packet");
|
|
|
|
// Just copy it because the codec is the same
|
2017-11-18 03:30:38 +08:00
|
|
|
av_init_packet(&opkt);
|
2017-10-27 01:12:56 +08:00
|
|
|
opkt.data = ipkt->data;
|
|
|
|
opkt.size = ipkt->size;
|
|
|
|
opkt.flags = ipkt->flags;
|
2020-05-03 06:03:42 +08:00
|
|
|
opkt.duration = ipkt->duration;
|
2019-12-01 03:59:39 +08:00
|
|
|
|
|
|
|
if ( ipkt->dts != AV_NOPTS_VALUE ) {
|
|
|
|
if ( !video_first_dts ) {
|
|
|
|
Debug(2, "Starting video first_dts will become %" PRId64, ipkt->dts);
|
|
|
|
video_first_dts = ipkt->dts;
|
|
|
|
}
|
|
|
|
opkt.dts = ipkt->dts - video_first_dts;
|
2017-05-17 00:04:56 +08:00
|
|
|
} else {
|
2019-12-01 03:59:39 +08:00
|
|
|
opkt.dts = next_dts[video_out_stream->index] ? av_rescale_q(next_dts[video_out_stream->index], video_out_stream->time_base, video_in_stream->time_base) : 0;
|
|
|
|
Debug(3, "Setting dts to video_next_dts %" PRId64 " from %" PRId64, opkt.dts, next_dts[video_out_stream->index]);
|
|
|
|
}
|
|
|
|
if ( ipkt->pts != AV_NOPTS_VALUE ) {
|
|
|
|
opkt.pts = ipkt->pts - video_first_dts;
|
|
|
|
} else {
|
|
|
|
opkt.pts = AV_NOPTS_VALUE;
|
|
|
|
}
|
2017-12-19 22:59:04 +08:00
|
|
|
|
2019-12-01 03:59:39 +08:00
|
|
|
av_packet_rescale_ts(&opkt, video_in_stream->time_base, video_out_stream->time_base);
|
2017-12-19 22:59:04 +08:00
|
|
|
|
2019-12-01 03:59:39 +08:00
|
|
|
dumpPacket(video_out_stream, &opkt, "after pts adjustment");
|
2018-11-21 01:38:17 +08:00
|
|
|
} // end if codec matches
|
2017-12-08 23:38:16 +08:00
|
|
|
|
2019-12-01 03:59:39 +08:00
|
|
|
write_packet(&opkt, video_out_stream);
|
2017-10-27 01:12:56 +08:00
|
|
|
zm_av_packet_unref(&opkt);
|
|
|
|
|
2017-11-13 00:42:34 +08:00
|
|
|
return 1;
|
2017-10-27 01:12:56 +08:00
|
|
|
} // end int VideoStore::writeVideoFramePacket( AVPacket *ipkt )
|
|
|
|
|
2017-11-13 00:42:34 +08:00
|
|
|
int VideoStore::writeAudioFramePacket(ZMPacket *zm_packet) {
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2017-11-13 00:42:34 +08:00
|
|
|
AVPacket *ipkt = &zm_packet->packet;
|
2019-09-09 04:10:57 +08:00
|
|
|
int ret;
|
2017-11-13 00:42:34 +08:00
|
|
|
|
2017-11-03 21:23:08 +08:00
|
|
|
if ( !audio_out_stream ) {
|
2017-08-23 22:37:32 +08:00
|
|
|
Debug(1, "Called writeAudioFramePacket when no audio_out_stream");
|
2019-04-26 02:49:16 +08:00
|
|
|
return 0;
|
|
|
|
// FIXME -ve return codes do not free packet in ffmpeg_camera at the moment
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
}
|
2019-04-04 01:23:00 +08:00
|
|
|
dumpPacket(audio_in_stream, ipkt, "input packet");
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2019-09-13 04:52:59 +08:00
|
|
|
if ( !audio_first_dts ) {
|
2019-09-13 05:59:08 +08:00
|
|
|
audio_first_dts = ipkt->dts;
|
2019-09-18 00:53:29 +08:00
|
|
|
audio_next_pts = audio_out_ctx->frame_size;
|
2019-09-13 04:52:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Need to adjust pts before feeding to decoder.... should really copy the pkt instead of modifying it
|
2019-09-18 00:53:29 +08:00
|
|
|
ipkt->pts -= audio_first_dts;
|
|
|
|
ipkt->dts -= audio_first_dts;
|
2019-09-13 04:52:59 +08:00
|
|
|
dumpPacket(audio_in_stream, ipkt, "after pts adjustment");
|
|
|
|
|
2017-11-03 21:23:08 +08:00
|
|
|
if ( audio_out_codec ) {
|
2019-09-14 02:34:53 +08:00
|
|
|
// I wonder if we can get multiple frames per packet? Probably
|
2019-09-18 00:53:29 +08:00
|
|
|
ret = zm_send_packet_receive_frame(audio_in_ctx, in_frame, *ipkt);
|
2019-10-16 21:01:59 +08:00
|
|
|
if ( ret < 0 ) {
|
|
|
|
Debug(3, "failed to receive frame code: %d", ret);
|
2019-02-16 06:26:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2019-04-04 01:23:00 +08:00
|
|
|
zm_dump_frame(in_frame, "In frame from decode");
|
2019-02-16 06:26:30 +08:00
|
|
|
|
2019-09-14 02:34:53 +08:00
|
|
|
AVFrame *input_frame = in_frame;
|
2019-02-16 06:26:30 +08:00
|
|
|
|
2019-09-14 02:34:53 +08:00
|
|
|
while ( zm_resample_audio(resample_ctx, input_frame, out_frame) ) {
|
|
|
|
//out_frame->pkt_duration = in_frame->pkt_duration; // resampling doesn't alter duration
|
|
|
|
if ( zm_add_samples_to_fifo(fifo, out_frame) <= 0 )
|
|
|
|
break;
|
2017-06-03 04:52:52 +08:00
|
|
|
|
2019-10-21 01:32:16 +08:00
|
|
|
// We put the samples into the fifo so we are basically resetting the frame
|
|
|
|
out_frame->nb_samples = audio_out_ctx->frame_size;
|
|
|
|
|
2019-09-14 02:34:53 +08:00
|
|
|
if ( zm_get_samples_from_fifo(fifo, out_frame) <= 0 )
|
|
|
|
break;
|
2019-07-07 20:57:22 +08:00
|
|
|
|
2019-09-14 02:34:53 +08:00
|
|
|
out_frame->pts = audio_next_pts;
|
|
|
|
audio_next_pts += out_frame->nb_samples;
|
|
|
|
|
|
|
|
zm_dump_frame(out_frame, "Out frame after resample");
|
|
|
|
|
|
|
|
av_init_packet(&opkt);
|
|
|
|
if ( zm_send_frame_receive_packet(audio_out_ctx, out_frame, opkt) <= 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Scale the PTS of the outgoing packet to be the correct time base
|
|
|
|
av_packet_rescale_ts(&opkt,
|
|
|
|
audio_out_ctx->time_base,
|
|
|
|
audio_out_stream->time_base);
|
2019-08-29 00:19:54 +08:00
|
|
|
|
|
|
|
write_packet(&opkt, audio_out_stream);
|
2019-09-14 02:34:53 +08:00
|
|
|
zm_av_packet_unref(&opkt);
|
|
|
|
|
2019-09-14 03:51:35 +08:00
|
|
|
if ( zm_resample_get_delay(resample_ctx, out_frame->sample_rate) < out_frame->nb_samples)
|
2019-09-14 02:34:53 +08:00
|
|
|
break;
|
|
|
|
// This will send a null frame, emptying out the resample buffer
|
2020-08-26 07:45:48 +08:00
|
|
|
input_frame = nullptr;
|
2019-09-14 02:34:53 +08:00
|
|
|
} // end while there is data in the resampler
|
Feature h264 videostorage (#1882)
* Moved writing of configure options from Controller to Model. Fixes #191.
* Initial commit for saving events as videos :)
* Add zm_video.cpp to autotools
* Add zm_video.h to autotools
* Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h
* Fix serve memory leak
* Few minor code improvements
* Added the ability to override preset, tune, profile and few other improvements
* Correctly write SPS & PPS from x264 encoder headers
* Remove unnessecary SPS & PPS writing code
* Imported missing files from master to feature-h264-videostorage
* Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem)
* Updates to make gcc happy
* Add html5 video control to timeline and event to support mkv playback
* Add zm_videostore.cpp to CMakeLists.txt
* Remove Modern Branch for now
* Fix minor bug
* Option handled added in master, removing duplicate declaration
* Add CaptureandRecord from zm_camera.h
* Putting placeholder in for CaptureAndRecord function
* Removed duplicate code and brackets
* add digest auth file for cmake
Conflicts:
src/CMakeLists.txt
* Add web dir back into Makefile.am
Revert "Removed web from SUBDIRS in Makefile.am"
This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d.
* Add CaptureAndRecord to vlc, still need to make it record
* Resolve SegFault on videostore
* Swap to mp4 container
* mp4 changes
* spaces to tabs, hide video stuff if video writer is turned off
* Make timeline open event.mp4 instead of mkv
* Missed mkv in timeline.js
* Fix some issues from the merge conflict
* Resolve post merge build issues with braces
* Fix whitespace
* Update Jpeg and Video options for passthrough options
* Whitespace fix zm_camera.h
* Fix array mkssing comma
* Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed
* Update VideoStoreData memory size comment
* Change from config.use_mkv_storage to per monitor option VideoWriter from video branch
* Fix bracket issues post merge
* Clean up comments and add av_free_packet
* Convert from event_directory to event file as per Video branch
* Testing videojs for video playback
* Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors
* bring recent improvements in ffmpeg capture function into captureandrecord
* Remove pict from writeAudioFramePacket as not used
* Add translate options for h264 Storage options in Monitor and update en_gb file
* Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0
Conflicts:
src/zm_ffmpeg.cpp
src/zm_remote_camera_rtsp.cpp
Conflicts:
distros/ubuntu1204/changelog
* Clean up videostore code and remove lots of unused code
* proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate
Conflicts:
web/skins/classic/views/event.php
* removed redundant field in sql query
Conflicts:
web/skins/classic/views/event.php
* local storage of video js plugin
* Beautify!
Make the code somewhat readable.
* added missing videojs.zoomrotate.js file
added missing videojs.zoomrotate.js file
* Typo
added missing "
* Added missing brackets
* fix to display thumbnails when only storing snapshot.jpg
* added control for video playback rate
Conflicts:
web/skins/classic/views/event.php
* dynamically create jpegs from video file for viewing in browser
* fix timeline view for SaveJPEGs monitors (without enabled VideoWriter)
* only expose monitor info which are being used in client
* fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8)
when libx264 is not installed
* better way of detecting showing image or video in timeline and event view
instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if
VideoWriter/SaveJPEG option is changed, a valid image or video will always be
displayed for historical events in both timeline and event view
this also fixes loading videos in timeline view
* Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file
* Remove syslog.h
* fixed SaveJPEGs are not working
which is caused in errors introduced when merging with master
* Update README.md
* Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues
* Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here
* Fix PRId64 issue in travis, another try
* Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3
* Revert space removal around PRId64
* video branch ffmpeg 2.9 fixes
ffmpeg 2.9 patched removed SSE2 CPU
* Add FFMPEGInit back
* use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event
also fixed bug which prevented seeking in timeline video preview
* ffmpeg 3.0 API build failure fixes
* Update README.md
* merge all the commits from the messed up iconnor_video branch
* fix whitespace
* revert
* whitespace fixes
* spelling fix
* put back some text
* add these back
* fix spelling mistake
* Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines
* add a test and error message if the codec is not h264
* these have been removed in master
* add a view to check auth and just send the video
* add some comments, and dump filename and AVFormatContext on failure to write header
* add the toggle for RecordAudio so that the checkbox works to turn off Audio
* Must init videoStore in constuctor
* more debug and comments, return checking
* Fix dropped part of sql query.
* fix extra else and some whitespace
* Fix missing } from merge that was preventing building.
* fix tabs
* get rid of use of separator, just use \n
* Restore lost fixes for deprecation
* Why are these failing
* Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio
* Forgot that I was trying to solve case of stream is true and record_audio
is false.
* Pass swscale_ctx back in to getCachedContext or it will create new
context every frame and leak memory like a mofo.
* Add libx264-dev and libmp4v2-dev to build requires to save hassle of
ensuring they are installed before build.
* Merge my Rotation/Orientation work and fixes for bad h264 streams
* need arpa/inet for reverse lookups
* pull in the new byte range code for viewing videos
* Move our recording flag deeper into closeevent
* add braces and only call closeEvent if there is an event
* deprecate the z_frame_rate stuff which is deprecated in ffmpeg
* remark out some debugging
* fix for video on stream 1
* fix audio_stream to audio_st
* Ignore bad decodes
* fix problems with content-length causing viewing to not work in chrome/android
* change logic of sending file contents to handle an off by one and be more readable
* Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table
* fix to sql for timeline
* added RecordAudio to sql in README
* Use sub queries instead of joins to fix errors when using new mysql defaults.
* fix sql queries
* Dockerfile to build feature-h264-videostorage
* Must cast codec
* add php-acpu as a dependency
* require php5-acpu
* fix typo
* remove extra /
* Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php
* delete merge conflict files
* delete merge conflict files
2017-05-16 10:02:48 +08:00
|
|
|
|
2017-05-17 00:04:56 +08:00
|
|
|
} else {
|
|
|
|
av_init_packet(&opkt);
|
|
|
|
opkt.data = ipkt->data;
|
|
|
|
opkt.size = ipkt->size;
|
2019-08-29 00:19:54 +08:00
|
|
|
opkt.flags = ipkt->flags;
|
2017-05-17 00:04:56 +08:00
|
|
|
|
2019-09-13 04:52:59 +08:00
|
|
|
opkt.duration = ipkt->duration;
|
|
|
|
opkt.pts = ipkt->pts;
|
|
|
|
opkt.dts = ipkt->dts;
|
|
|
|
av_packet_rescale_ts(&opkt, audio_in_stream->time_base, audio_out_stream->time_base);
|
2021-01-27 01:24:43 +08:00
|
|
|
dumpPacket(audio_out_stream, &opkt, "after stream pts adjustment");
|
2019-08-29 00:19:54 +08:00
|
|
|
write_packet(&opkt, audio_out_stream);
|
2019-04-26 02:49:16 +08:00
|
|
|
|
2019-08-29 00:19:54 +08:00
|
|
|
zm_av_packet_unref(&opkt);
|
2019-09-10 04:13:32 +08:00
|
|
|
} // end if encoding or copying
|
2019-04-26 02:49:16 +08:00
|
|
|
|
2019-08-29 00:19:54 +08:00
|
|
|
return 0;
|
2019-09-10 04:13:32 +08:00
|
|
|
} // end int VideoStore::writeAudioFramePacket(AVPacket *ipkt)
|
2017-11-13 00:42:34 +08:00
|
|
|
|
|
|
|
int VideoStore::write_packets( zm_packetqueue &queue ) {
|
|
|
|
// Need to write out all the frames from the last keyframe?
|
|
|
|
// No... need to write out all frames from when the event began. Due to PreEventFrames, this could be more than since the last keyframe.
|
|
|
|
unsigned int packet_count = 0;
|
|
|
|
ZMPacket *queued_packet;
|
|
|
|
|
|
|
|
while ( ( queued_packet = queue.popPacket() ) ) {
|
|
|
|
AVPacket *avp = queued_packet->av_packet();
|
|
|
|
|
|
|
|
packet_count += 1;
|
|
|
|
//Write the packet to our video store
|
2017-12-01 23:30:58 +08:00
|
|
|
Debug(2, "Writing queued packet stream: %d KEY %d, remaining (%d)",
|
|
|
|
avp->stream_index, avp->flags & AV_PKT_FLAG_KEY, queue.size() );
|
2017-11-13 00:42:34 +08:00
|
|
|
int ret = this->writePacket( queued_packet );
|
|
|
|
if ( ret < 0 ) {
|
|
|
|
//Less than zero and we skipped a frame
|
|
|
|
}
|
|
|
|
delete queued_packet;
|
|
|
|
} // end while packets in the packetqueue
|
|
|
|
Debug(2, "Wrote %d queued packets", packet_count );
|
|
|
|
return packet_count;
|
2019-12-01 03:59:39 +08:00
|
|
|
} // end int VideoStore::write_packets( PacketQueue &queue ) {
|
2019-04-04 01:23:00 +08:00
|
|
|
|
2019-08-29 00:19:54 +08:00
|
|
|
int VideoStore::write_packet(AVPacket *pkt, AVStream *stream) {
|
|
|
|
pkt->pos = -1;
|
|
|
|
pkt->stream_index = stream->index;
|
2019-05-13 00:14:03 +08:00
|
|
|
|
2019-10-12 02:04:51 +08:00
|
|
|
if ( pkt->dts == AV_NOPTS_VALUE ) {
|
|
|
|
Debug(1, "undef dts, fixing by setting to stream cur_dts %" PRId64, stream->cur_dts);
|
|
|
|
pkt->dts = stream->cur_dts;
|
2019-10-22 22:01:24 +08:00
|
|
|
} else if ( pkt->dts < stream->cur_dts ) {
|
2019-09-18 00:53:29 +08:00
|
|
|
Debug(1, "non increasing dts, fixing. our dts %" PRId64 " stream cur_dts %" PRId64, pkt->dts, stream->cur_dts);
|
2019-08-29 00:19:54 +08:00
|
|
|
pkt->dts = stream->cur_dts;
|
2019-10-22 22:01:24 +08:00
|
|
|
}
|
2019-04-04 01:23:00 +08:00
|
|
|
|
2019-10-22 22:01:24 +08:00
|
|
|
if ( pkt->dts > pkt->pts ) {
|
2017-08-23 22:37:32 +08:00
|
|
|
Debug(1,
|
2019-08-29 00:19:54 +08:00
|
|
|
"pkt.dts(%" PRId64 ") must be <= pkt.pts(%" PRId64 ")."
|
2018-12-05 07:23:08 +08:00
|
|
|
"Decompression must happen before presentation.",
|
2019-08-29 00:19:54 +08:00
|
|
|
pkt->dts, pkt->pts);
|
2019-10-22 22:01:24 +08:00
|
|
|
pkt->pts = pkt->dts;
|
2019-04-04 01:23:00 +08:00
|
|
|
}
|
|
|
|
|
2019-08-29 00:19:54 +08:00
|
|
|
dumpPacket(stream, pkt, "finished pkt");
|
2019-10-23 21:25:16 +08:00
|
|
|
next_dts[stream->index] = opkt.dts + opkt.duration;
|
|
|
|
Debug(3, "video_next_dts has become %" PRId64, next_dts[stream->index]);
|
2019-04-04 01:23:00 +08:00
|
|
|
|
2019-09-09 04:10:57 +08:00
|
|
|
int ret = av_interleaved_write_frame(oc, pkt);
|
2018-12-05 07:23:08 +08:00
|
|
|
if ( ret != 0 ) {
|
2019-08-29 00:19:54 +08:00
|
|
|
Error("Error writing packet: %s",
|
2017-08-23 22:37:32 +08:00
|
|
|
av_make_error_string(ret).c_str());
|
2017-05-17 00:04:56 +08:00
|
|
|
} else {
|
2021-01-27 01:24:43 +08:00
|
|
|
Debug(4, "Success writing packet");
|
2019-04-04 01:23:00 +08:00
|
|
|
}
|
2019-09-10 04:55:22 +08:00
|
|
|
return ret;
|
2019-09-10 04:13:32 +08:00
|
|
|
} // end int VideoStore::write_packet(AVPacket *pkt, AVStream *stream)
|