zoneminder icon indicating copy to clipboard operation
zoneminder copied to clipboard

Support FFMPEG 7

Open VVD opened this issue 1 year ago • 15 comments

Describe Your Environment

  • Version of ZoneMinder [release version, development version, or commit] 1.36.33
  • How you installed ZoneMinder [e.g. PPA, RPMFusion, from-source, etc]: from FreeBSD ports
  • Full name and version of OS: FreeBSD 14.0, 13.3 amd64.
  • Browser name and version (if this is an issue with the web interface): -

If the issue concerns a camera No.

Describe the bug Build failed with FFMPEG 7. All deprecated API in FFMPEG 5/6 was removed from FFMPEG 7.

To Reproduce Steps to reproduce the behavior:

  1. Try to build with FFMPEG 7.

Expected behavior Build and work without errors.

Debug Logs

In file included from /wrkdirs/usr/ports/multimedia/zoneminder/work/zoneminder-1.36.33/src/zm_monitor.h:24:
/wrkdirs/usr/ports/multimedia/zoneminder/work/zoneminder-1.36.33/src/zm_camera.h:111:51: error: no member named 'channels' in 'AVCodecParameters'
    return mAudioStream ? mAudioStream->codecpar->channels : -1;
                          ~~~~~~~~~~~~~~~~~~~~~~  ^
1 error generated.

Full build log: https://pkg-status.freebsd.org/beefy22/data/140amd64-default-foo/2024-05-04_07h10m46s/logs/errors/zoneminder-1.36.33_3.log

VVD avatar May 06 '24 12:05 VVD

This can help to update: https://code.videolan.org/videolan/vlc/-/merge_requests/5304/diffs Maybe replace mAudioStream->codecpar->channels with mAudioStream->codecpar->ch_layout.nb_channels.

VVD avatar May 06 '24 12:05 VVD

If you want to stay on 1.36, then please follow the release-1.36 branch which I believe (could be wrong) has this work done.

Otherwise, please follow current development release which again has this work done.

connortechnology avatar May 06 '24 13:05 connortechnology

If you want to stay on 1.36, then please follow the release-1.36 branch which I believe (could be wrong) has this work done.

https://ffmpeg.org/index.html#news

April 5th, 2024, FFmpeg 7.0 "Dijkstra"

Last commit to branch https://github.com/ZoneMinder/zoneminder/commits/release-1.36/ was on Jan 16, 2024. I doubt that all this has already been fixed there.

Otherwise, please follow current development release which again has this work done.

I'm working on update ffmpeg to 7.0 in FreeBSD ports: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278705 New release of the ZoneMinder or set of patches is enough for us. These commits: https://github.com/ZoneMinder/zoneminder/commit/d7682ba95dbe0a83ba32660e3ed620292208b489 https://github.com/ZoneMinder/zoneminder/commit/60285ba16ba74d487719bf38e8e32020ceaa38a2 https://github.com/ZoneMinder/zoneminder/commit/219af381272c979164157f5e40f4b9d5517a0e42 ?

VVD avatar May 06 '24 14:05 VVD

BTW, any plans for next release?

VVD avatar May 06 '24 14:05 VVD

/wrkdirs/usr/ports/multimedia/zoneminder/work/zoneminder-1.36.33/src/zm_mpeg.cpp:632:38: error: no member named 'frame_number' in 'AVCodecContext'; did you mean 'frame_num'?
  632 |                 opicture_ptr->pts = codec_context->frame_number;
      |                                                    ^~~~~~~~~~~~
      |                                                    frame_num
/usr/local/include/libavcodec/avcodec.h:2030:13: note: 'frame_num' declared here
 2030 |     int64_t frame_num;
      |             ^
2 warnings and 1 error generated.
*

https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/6b6f7db81932f94876ff4bcfd2da0582b8ab897e https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/2717dcfb8527dd65a9fb0e7f8cb00d118af65b68

This patch fixed the issue:

--- src/zm_mpeg.cpp.orig        2023-02-23 21:44:01 UTC
+++ src/zm_mpeg.cpp
@@ -629,7 +629,11 @@ double VideoStream::ActuallyEncodeFrame( const uint8_t
     pkt->size = buffer_size;
     got_packet = 1;
        } else {
+#if LIBAVCODEC_VERSION_CHECK(61, 64, 0, 3, 100)
+               opicture_ptr->pts = codec_context->frame_num;
+#else
                opicture_ptr->pts = codec_context->frame_number;
+#endif
                opicture_ptr->quality = codec_context->global_quality;

 #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)

But I don't know correct values for LIBAVCODEC_VERSION_CHECK(61, 64, 0, 3, 100).

VVD avatar May 06 '24 16:05 VVD

If you want to stay on 1.36, then please follow the release-1.36 branch which I believe (could be wrong) has this work done.

Otherwise, please follow current development release which again has this work done.

Both doesn't build. release-1.36 have a lot of different uses of removed from 7.0 deprecations. Current development need this patch:

--- src/zm_mpeg.cpp.orig        2023-02-23 21:44:01 UTC
+++ src/zm_mpeg.cpp
@@ -463,7 +463,11 @@ double VideoStream::ActuallyEncodeFrame( const uint8_t
     pkt->data = (uint8_t *)opicture_ptr;
     pkt->size = buffer_size;
   } else {
+#if LIBAVCODEC_VERSION_CHECK(61, 64, 0, 3, 100)
+    opicture_ptr->pts = codec_context->frame_num;
+#else
     opicture_ptr->pts = codec_context->frame_number;
+#endif
     opicture_ptr->quality = codec_context->global_quality;

     avcodec_send_frame(codec_context, opicture_ptr);

Offtopic question: added new build dependency from pkg-config and lib dependency from libcurl?

VVD avatar May 08 '24 12:05 VVD

I have updated both master and release-1.36 with further ffmpeg7 deprecation handling.

connortechnology avatar May 08 '24 20:05 connortechnology

Hey I switched to using quick_exit instead() of exit(). this breaks on openbsd for me. Just wondering if it has broken freebsd as well. Does ZM still c ompile for you?

connortechnology avatar May 14 '24 23:05 connortechnology

Do u say about this commit: https://github.com/ZoneMinder/zoneminder/commit/0048a6bc9972abc5a76a659d1cfd7e0423b56f17? I have only one host in production with zoneminder - can't test run development versions. I can test build only.

VVD avatar May 15 '24 11:05 VVD

Yes that's the one. quick_exit is not implemented in openbsd. I'm testing a workaround of using abort() instead. Just wondering if quick_exit exists in freebsd.

connortechnology avatar May 15 '24 13:05 connortechnology

Look like it work fine:

$ cat e.cpp
#include <cstdlib>
#include <iostream>

int main()
{
  std::cout << "Hello world!\n";
  std::quick_exit(1);
}
$ clang e.cpp -o e -lc++
$ ./e
Hello world!
$ echo $?
1

VVD avatar May 15 '24 13:05 VVD

Good to know, thanks for testing!

FYI on openBSD we get:

clang e.cpp -o e -lc++

e.cpp:7:8: error: reference to unresolved using declaration std::quick_exit(1); ^ /usr/include/c++/v1/cstdlib:145:1: note: using declaration annotated with 'using_if_exists' here using ::quick_exit _LIBCPP_USING_IF_EXISTS; ^ e.cpp:7:3: warning: expression result unused [-Wunused-value] std::quick_exit(1); ^ ~ 1 warning and 1 error generated.

connortechnology avatar May 15 '24 13:05 connortechnology

std::quick_exit is C++11 / C11 so I'd expect the OpenBSD folks will want to implement it.

They could presumably take the FreeBSD implementation from https://github.com/freebsd/freebsd-src/commit/0a31efe016d28d5f3bee6c24591831149d760650

emaste avatar May 23 '24 22:05 emaste

They don't seem to want to. I am using abort instead on openbsd. For now.

connortechnology avatar May 23 '24 23:05 connortechnology

It'd be great to prioritize this, if possible. ffmpeg 7 is now in the mirrors for Arch Linux, so the zoneminder AUR package is currently broken:

  • https://aur.archlinux.org/packages/zoneminder

It would be possible to put in the effort to create a custom ffmpeg 6 package that the zoneminder AUR package uses, or possibly vendor ffmpeg with zoneminder. However, if ffmpeg 7 support is already in the master branch, then all we need is another release to build against stable zoneminder sources.

Thanks in advance!

synthead avatar Aug 07 '24 17:08 synthead