Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FFMPEG 7 #3983

Open
VVD opened this issue May 6, 2024 · 14 comments
Open

Support FFMPEG 7 #3983

VVD opened this issue May 6, 2024 · 14 comments

Comments

@VVD
Copy link

VVD commented May 6, 2024

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
Copy link
Author

VVD commented May 6, 2024

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.

@connortechnology
Copy link
Member

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.

@VVD
Copy link
Author

VVD commented May 6, 2024

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: d7682ba 60285ba 219af38 ?

@VVD
Copy link
Author

VVD commented May 6, 2024

BTW, any plans for next release?

@VVD
Copy link
Author

VVD commented May 6, 2024

/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
Copy link
Author

VVD commented May 8, 2024

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?

@connortechnology
Copy link
Member

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

@connortechnology
Copy link
Member

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?

@VVD
Copy link
Author

VVD commented May 15, 2024

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

@connortechnology
Copy link
Member

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.

@VVD
Copy link
Author

VVD commented May 15, 2024

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

@connortechnology
Copy link
Member

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.

@emaste
Copy link

emaste commented May 23, 2024

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 freebsd/freebsd-src@0a31efe

@connortechnology
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants