From c78e0350577f5fa6f0af8d7800da0db32bae7bee Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 23 Sep 2021 19:07:07 -0400 Subject: [PATCH 1/6] Fix crash due to int64 cast to a %ld format. --- src/zm_event.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index c3bda0a4f..adda18655 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -109,7 +109,7 @@ Event::Event( "INSERT INTO `Events` " "( `MonitorId`, `StorageId`, `Name`, `StartDateTime`, `Width`, `Height`, `Cause`, `Notes`, `StateId`, `Orientation`, `Videoed`, `DefaultVideo`, `SaveJPEGs`, `Scheme` )" " VALUES " - "( %d, %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s', %d, %d, %d, '%s', %d, '%s' )", + "( %d, %d, 'New Event', from_unixtime(%" PRId64 "), %u, %u, '%s', '%s', %d, %d, %d, '%s', %d, '%s' )", monitor->Id(), storage->Id(), static_cast(std::chrono::system_clock::to_time_t(start_time)), @@ -120,11 +120,10 @@ Event::Event( state_id, monitor->getOrientation(), 0, - "", + "", save_jpegs, storage->SchemeString().c_str() ); - id = zmDbDoInsert(sql); if ( !SetPath(storage) ) { From dcd2c1677419d2a0ade5a00e22c6638b54fa8827 Mon Sep 17 00:00:00 2001 From: Steve Gilvarry Date: Mon, 27 Sep 2021 00:58:34 +1000 Subject: [PATCH 2/6] Define Date formats Set Locale for time to en_GB.utf8, changed STRF_FMT_DATETIME_SHORTER to %x which is locale aware short date, but does include year. Makes event table wider, not sure if that is a problem for others --- web/lang/en_gb.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index 8427d5bc6..8b412cd39 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -69,6 +69,11 @@ // setlocale( LC_CTYPE, 'en_GB' ); Character class settings 4.3.0 and after // setlocale( LC_TIME, 'en_GB' ); Date and time formatting 4.3.0 and after +setlocale( LC_TIME, 'en_GB.utf8' ); +define("DATE_FMT_CONSOLE_LONG", "%a %d %b, %Hh%M"); +define( "STRF_FMT_DATETIME_SHORT", "%d/%m/%y %H:%M:%S" ); +define( "STRF_FMT_DATETIME_SHORTER", "%x %H:%M:%S" ); + // Simple String Replacements $SLANG = array( 'SystemLog' => 'System Log', From 202d95fc5a67a23a76a47c714c44743ec548374f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 27 Sep 2021 10:58:16 -0400 Subject: [PATCH 3/6] handle AV_HWDEVICE_TYPE_MMAL not being defined --- src/zm_ffmpeg_camera.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 6415b2134..d0900ad78 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -66,8 +66,10 @@ static enum AVPixelFormat find_fmt_by_hw_type(const enum AVHWDeviceType type) { return AV_PIX_FMT_VDPAU; case AV_HWDEVICE_TYPE_CUDA: return AV_PIX_FMT_CUDA; +#ifdef AV_HWDEVICE_TYPE_MMAL case AV_HWDEVICE_TYPE_MMAL: return AV_PIX_FMT_MMAL; +#endif case AV_HWDEVICE_TYPE_VIDEOTOOLBOX: return AV_PIX_FMT_VIDEOTOOLBOX; default: From ac375bc6230d025ea9112c9cf2b4dab554563afb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 27 Sep 2021 11:01:41 -0400 Subject: [PATCH 4/6] fix errant = --- src/zm_ffmpeg_camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index d0900ad78..b122e0f2b 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -61,7 +61,7 @@ static enum AVPixelFormat find_fmt_by_hw_type(const enum AVHWDeviceType type) { case AV_HWDEVICE_TYPE_DXVA2: return AV_PIX_FMT_DXVA2_VLD; case AV_HWDEVICE_TYPE_D3D11VA: - return = AV_PIX_FMT_D3D11; + return AV_PIX_FMT_D3D11; case AV_HWDEVICE_TYPE_VDPAU: return AV_PIX_FMT_VDPAU; case AV_HWDEVICE_TYPE_CUDA: From 95a7c6c32fe17278d71f0d4b39c2e00d491fe6e1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 28 Sep 2021 10:29:41 -0400 Subject: [PATCH 5/6] fix crash on 32bit pi due to use of %ld instead of %PRId64 --- src/zm_ffmpeg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index bb7362b74..3986b38b8 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -213,7 +213,7 @@ void zm_dump_codecpar(const AVCodecParameters *par) { void zm_dump_codec(const AVCodecContext *codec) { Debug(1, "Dumping codec_context codec_type %d %s codec_id %d %s width %d height %d timebase %d/%d format %s profile %d level %d " - "gop_size %d has_b_frames %d max_b_frames %d me_cmp %d me_range %d qmin %d qmax %d bit_rate %ld extradata:%d:%s", + "gop_size %d has_b_frames %d max_b_frames %d me_cmp %d me_range %d qmin %d qmax %d bit_rate %" PRId64 " extradata:%d:%s", codec->codec_type, av_get_media_type_string(codec->codec_type), codec->codec_id, From aca477e73790be120cac81021bba487340b9655e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 28 Sep 2021 10:30:51 -0400 Subject: [PATCH 6/6] Add warning when MaxImageBufferCount is less than keyframe interval --- src/zm_packetqueue.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/zm_packetqueue.cpp b/src/zm_packetqueue.cpp index cef7e8e2f..ad9bb3ef1 100644 --- a/src/zm_packetqueue.cpp +++ b/src/zm_packetqueue.cpp @@ -195,6 +195,7 @@ void PacketQueue::clearPackets(const std::shared_ptr &add_packet) { add_packet->packet.stream_index, video_stream_id, add_packet->keyframe, keep_keyframes, packet_counts[video_stream_id], pre_event_video_packet_count, ( *(pktQueue.begin()) != add_packet ) ); + Warning("Keyframe interval may be larger than MaxImageBufferCount and PreEventCount. Please increase MaxImageBufferCount"); return; } std::unique_lock lck(mutex);