Merge ~liushuyu-011/ubuntu/+source/zoneminder:ubuntu/devel into ubuntu/+source/zoneminder:ubuntu/devel

Proposed by Zixing Liu
Status: Rejected
Rejected by: Robie Basak
Proposed branch: ~liushuyu-011/ubuntu/+source/zoneminder:ubuntu/devel
Merge into: ubuntu/+source/zoneminder:ubuntu/devel
Diff against target: 339 lines (+317/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/0010-ffmpeg-7.patch (+309/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Vladimir Petko (community) Needs Fixing
Review via email: mp+473472@code.launchpad.net

Description of the change

This merge proposal fixes FTBFS with FFmpeg 7 for zoneminder by backporting a patch from the upstream.

To post a comment you must log in.
Revision history for this message
Vladimir Petko (vpa1977) wrote :

- Needs PPA build
- Please run quilt refresh.
- Please add ftbfs bug and reference it in the changelog/patch

review: Needs Fixing
Revision history for this message
Zixing Liu (liushuyu-011) wrote :
Revision history for this message
Vladimir Petko (vpa1977) wrote :

Please mark as rejected, the issue was fixed in https://launchpad.net/ubuntu/+source/zoneminder/1.36.33+dfsg1-1ubuntu1

Unmerged commits

96290ec... by Zixing Liu

changelog

290a5ef... by Zixing Liu

d/p/0010-ffmpeg-7.patch: add a patch to fix FTBFS with FFmpeg 7

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index bcb8caf..3388259 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+zoneminder (1.36.33+dfsg1-1ubuntu1) oracular; urgency=medium
7+
8+ * d/p/0010-ffmpeg-7.patch: add a patch to fix FTBFS with FFmpeg 7
9+ (LP: #2080271, #2080395).
10+
11+ -- Zixing Liu <zixing.liu@canonical.com> Wed, 18 Sep 2024 13:16:07 -0600
12+
13 zoneminder (1.36.33+dfsg1-1build5) oracular; urgency=medium
14
15 * Rebuild against new libavcodec61.
16diff --git a/debian/patches/0010-ffmpeg-7.patch b/debian/patches/0010-ffmpeg-7.patch
17new file mode 100644
18index 0000000..f45c320
19--- /dev/null
20+++ b/debian/patches/0010-ffmpeg-7.patch
21@@ -0,0 +1,309 @@
22+Description: Fix FTBFS with FFmpeg 7
23+Author: Isaac Connor <isaac@zoneminder.com>
24+Origin: backport, https://github.com/ZoneMinder/zoneminder/commit/62789a83ab41da2c4829ad8bb22b584b67f6b3f6
25+Forwarded: not-needed
26+Last-Update: 2024-09-17
27+---
28+Index: zoneminder/src/zm_camera.h
29+===================================================================
30+--- zoneminder.orig/src/zm_camera.h
31++++ zoneminder/src/zm_camera.h
32+@@ -108,7 +108,7 @@ public:
33+ }
34+ int getChannels() {
35+ #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
36+- return mAudioStream ? mAudioStream->codecpar->channels : -1;
37++ return mAudioStream ? mAudioStream->codecpar->ch_layout.nb_channels : -1;
38+ #else
39+ return mAudioStream ? mAudioStream->codec->channels : -1;
40+ #endif
41+Index: zoneminder/src/zm_ffmpeg.h
42+===================================================================
43+--- zoneminder.orig/src/zm_ffmpeg.h
44++++ zoneminder/src/zm_ffmpeg.h
45+@@ -307,6 +307,18 @@ void zm_dump_codec(const AVCodecContext
46+ #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
47+ void zm_dump_codecpar(const AVCodecParameters *par);
48+ #endif
49++#if LIBAVUTIL_VERSION_CHECK(57, 28, 100, 28, 0)
50++#define zm_dump_frame(frame, text) Debug(1, "%s: format %d %s sample_rate %" PRIu32 " nb_samples %d" \
51++ " layout %" PRIu64 " pts %" PRId64, \
52++ text, \
53++ frame->format, \
54++ av_get_sample_fmt_name((AVSampleFormat)frame->format), \
55++ frame->sample_rate, \
56++ frame->nb_samples, \
57++ frame->ch_layout.u.mask, \
58++ frame->pts \
59++ );
60++#else
61+ #define zm_dump_frame(frame, text) Debug(1, "%s: format %d %s sample_rate %" PRIu32 " nb_samples %d" \
62+ " layout %" PRIu64 " pts %" PRId64, \
63+ text, \
64+@@ -317,6 +329,7 @@ void zm_dump_codecpar(const AVCodecParam
65+ frame->channel_layout, \
66+ frame->pts \
67+ );
68++#endif
69+
70+ #if LIBAVUTIL_VERSION_CHECK(54, 4, 0, 74, 100)
71+ #define zm_dump_video_frame(frame, text) Debug(1, "%s: format %d %s %dx%d linesize:%dx%d pts: %" PRId64 " keyframe: %d", \
72+Index: zoneminder/src/zm_videostore.cpp
73+===================================================================
74+--- zoneminder.orig/src/zm_videostore.cpp
75++++ zoneminder/src/zm_videostore.cpp
76+@@ -470,12 +470,16 @@ bool VideoStore::open() {
77+ audio_out_ctx->codec_tag = 0;
78+ #endif
79+
80++#if LIBAVUTIL_VERSION_CHECK(57, 28, 100, 28, 0)
81++ /* Seems like technically we could have multple channels, so let's not implement this for ffmpeg 5 */
82++#else
83+ if (audio_out_ctx->channels > 1) {
84+ Warning("Audio isn't mono, changing it.");
85+ audio_out_ctx->channels = 1;
86+ } else {
87+ Debug(3, "Audio is mono");
88+ }
89++#endif
90+ } // end if is AAC
91+
92+ if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
93+@@ -802,17 +806,23 @@ bool VideoStore::setup_resampler() {
94+
95+ Debug(2, "Got something other than AAC (%s)", audio_in_codec->name);
96+
97++#if LIBAVUTIL_VERSION_CHECK(57, 28, 100, 28, 0)
98++#else
99+ // Some formats (i.e. WAV) do not produce the proper channel layout
100+ if (audio_in_ctx->channel_layout == 0) {
101+ Debug(2, "Setting input channel layout to mono");
102+ // Perhaps we should not be modifying the audio_in_ctx....
103+ audio_in_ctx->channel_layout = av_get_channel_layout("mono");
104+ }
105++#endif
106+
107+ /* put sample parameters */
108+ audio_out_ctx->bit_rate = audio_in_ctx->bit_rate <= 32768 ? audio_in_ctx->bit_rate : 32768;
109+ audio_out_ctx->sample_rate = audio_in_ctx->sample_rate;
110+ audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt;
111++#if LIBAVUTIL_VERSION_CHECK(57, 28, 100, 28, 0)
112++ av_channel_layout_copy(&audio_out_ctx->ch_layout, &audio_in_ctx->ch_layout);
113++#else
114+ audio_out_ctx->channels = audio_in_ctx->channels;
115+ audio_out_ctx->channel_layout = audio_in_ctx->channel_layout;
116+ audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt;
117+@@ -842,6 +852,7 @@ bool VideoStore::setup_resampler() {
118+ audio_out_codec->supported_samplerates[0]);
119+ }
120+ }
121++#endif
122+
123+ /* check that the encoder supports s16 pcm in */
124+ if (!check_sample_fmt(audio_out_codec, audio_out_ctx->sample_fmt)) {
125+@@ -890,22 +901,22 @@ bool VideoStore::setup_resampler() {
126+ audio_out_ctx->time_base.num, audio_out_ctx->time_base.den);
127+
128+ Debug(1,
129+- "Audio in bit_rate (%" AV_PACKET_DURATION_FMT ") sample_rate(%d) channels(%d) fmt(%d) layout(%" PRIi64 ") frame_size(%d)",
130++ "Audio in bit_rate (%" AV_PACKET_DURATION_FMT ") sample_rate(%d) channels(%d) fmt(%d) frame_size(%d)",
131+ audio_in_ctx->bit_rate, audio_in_ctx->sample_rate,
132+- audio_in_ctx->channels, audio_in_ctx->sample_fmt,
133+- audio_in_ctx->channel_layout, audio_in_ctx->frame_size);
134++ audio_in_ctx->ch_layout.nb_channels, audio_in_ctx->sample_fmt,
135++ audio_in_ctx->frame_size);
136+ Debug(1,
137+- "Audio out context bit_rate (%" AV_PACKET_DURATION_FMT ") sample_rate(%d) channels(%d) fmt(%d) layout(% " PRIi64 ") frame_size(%d)",
138++ "Audio out context bit_rate (%" AV_PACKET_DURATION_FMT ") sample_rate(%d) channels(%d) fmt(%d) frame_size(%d)",
139+ audio_out_ctx->bit_rate, audio_out_ctx->sample_rate,
140+- audio_out_ctx->channels, audio_out_ctx->sample_fmt,
141+- audio_out_ctx->channel_layout, audio_out_ctx->frame_size);
142++ audio_out_ctx->ch_layout.nb_channels, audio_out_ctx->sample_fmt,
143++ audio_out_ctx->frame_size);
144+
145+ #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
146+ Debug(1,
147+- "Audio out stream bit_rate (%" PRIi64 ") sample_rate(%d) channels(%d) fmt(%d) layout(%" PRIi64 ") frame_size(%d)",
148++ "Audio out stream bit_rate (%" PRIi64 ") sample_rate(%d) channels(%d) fmt(%d) frame_size(%d)",
149+ audio_out_stream->codecpar->bit_rate, audio_out_stream->codecpar->sample_rate,
150+- audio_out_stream->codecpar->channels, audio_out_stream->codecpar->format,
151+- audio_out_stream->codecpar->channel_layout, audio_out_stream->codecpar->frame_size);
152++ audio_out_stream->codecpar->ch_layout.nb_channels, audio_out_stream->codecpar->format,
153++ audio_out_stream->codecpar->frame_size);
154+ #else
155+ Debug(1,
156+ "Audio out bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
157+@@ -933,11 +944,24 @@ bool VideoStore::setup_resampler() {
158+
159+ if (!(fifo = av_audio_fifo_alloc(
160+ audio_out_ctx->sample_fmt,
161+- audio_out_ctx->channels, 1))) {
162++ audio_out_ctx->ch_layout.nb_channels, 1))) {
163+ Error("Could not allocate FIFO");
164+ return false;
165+ }
166+ #if defined(HAVE_LIBSWRESAMPLE)
167++#if LIBAVUTIL_VERSION_CHECK(57, 28, 100, 28, 0)
168++ if ((ret = swr_alloc_set_opts2(&resample_ctx,
169++ &audio_out_ctx->ch_layout,
170++ audio_out_ctx->sample_fmt,
171++ audio_out_ctx->sample_rate,
172++ &audio_in_ctx->ch_layout,
173++ audio_in_ctx->sample_fmt,
174++ audio_in_ctx->sample_rate,
175++ 0, nullptr)) < 0) {
176++ Error("Could not allocate resample context");
177++ return false;
178++ }
179++#else
180+ resample_ctx = swr_alloc_set_opts(nullptr,
181+ audio_out_ctx->channel_layout,
182+ audio_out_ctx->sample_fmt,
183+@@ -952,6 +976,7 @@ bool VideoStore::setup_resampler() {
184+ av_frame_free(&out_frame);
185+ return false;
186+ }
187++#endif
188+ if ((ret = swr_init(resample_ctx)) < 0) {
189+ Error("Could not open resampler");
190+ av_frame_free(&in_frame);
191+@@ -1000,16 +1025,23 @@ bool VideoStore::setup_resampler() {
192+
193+ out_frame->nb_samples = audio_out_ctx->frame_size;
194+ out_frame->format = audio_out_ctx->sample_fmt;
195+-#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100)
196++#if LIBAVUTIL_VERSION_CHECK(57, 28, 100, 28, 0)
197++ out_frame->ch_layout = audio_out_ctx->ch_layout;
198++#else
199+ out_frame->channels = audio_out_ctx->channels;
200+-#endif
201+ out_frame->channel_layout = audio_out_ctx->channel_layout;
202++#endif
203+ out_frame->sample_rate = audio_out_ctx->sample_rate;
204+
205+ // The codec gives us the frame size, in samples, we calculate the size of the
206+ // samples buffer in bytes
207+ unsigned int audioSampleBuffer_size = av_samples_get_buffer_size(
208+- nullptr, audio_out_ctx->channels,
209++ nullptr,
210++#if LIBAVUTIL_VERSION_CHECK(57, 28, 100, 28, 0)
211++ audio_out_ctx->ch_layout.nb_channels,
212++#else
213++ audio_out_ctx->channels,
214++#endif
215+ audio_out_ctx->frame_size,
216+ audio_out_ctx->sample_fmt, 0);
217+ converted_in_samples = reinterpret_cast<uint8_t *>(av_malloc(audioSampleBuffer_size));
218+@@ -1023,7 +1055,12 @@ bool VideoStore::setup_resampler() {
219+
220+ // Setup the data pointers in the AVFrame
221+ if (avcodec_fill_audio_frame(
222+- out_frame, audio_out_ctx->channels,
223++ out_frame,
224++#if LIBAVUTIL_VERSION_CHECK(57, 28, 100, 28, 0)
225++ audio_out_ctx->ch_layout.nb_channels,
226++#else
227++ audio_out_ctx->channels,
228++#endif
229+ audio_out_ctx->sample_fmt,
230+ (const uint8_t *)converted_in_samples,
231+ audioSampleBuffer_size, 0) < 0) {
232+@@ -1183,7 +1220,7 @@ int VideoStore::writeVideoFramePacket(co
233+ //zm_packet->out_frame->pict_type = AV_PICTURE_TYPE_NONE;
234+ //zm_packet->out_frame->key_frame = zm_packet->keyframe;
235+ #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
236+- frame->pkt_duration = 0;
237++ //frame->pkt_duration = 0;
238+ #endif
239+
240+ int64_t in_pts = zm_packet->timestamp.tv_sec * (uint64_t)1000000 + zm_packet->timestamp.tv_usec;
241+@@ -1235,14 +1272,28 @@ int VideoStore::writeVideoFramePacket(co
242+
243+ int64_t duration = 0;
244+ if (zm_packet->in_frame) {
245+- if (zm_packet->in_frame->pkt_duration) {
246++
247++ if (
248++#if LIBAVCODEC_VERSION_CHECK(60, 3, 0, 3, 0)
249++ zm_packet->in_frame->duration
250++#else
251++ zm_packet->in_frame->pkt_duration
252++#endif
253++ ) {
254+ duration = av_rescale_q(
255++#if LIBAVCODEC_VERSION_CHECK(60, 3, 0, 3, 0)
256++ zm_packet->in_frame->duration,
257++#else
258+ zm_packet->in_frame->pkt_duration,
259++#endif
260+ video_in_stream->time_base,
261+ video_out_stream->time_base);
262+- Debug(1, "duration from ipkt: pts(%" PRId64 ") = pkt_duration(%" PRId64 ") => (%" PRId64 ") (%d/%d) (%d/%d)",
263+- zm_packet->in_frame->pts,
264++ Debug(1, "duration from ipkt: = duration(%" PRId64 ") => (%" PRId64 ") (%d/%d) (%d/%d)",
265++#if LIBAVCODEC_VERSION_CHECK(60, 3, 0, 3, 0)
266++ zm_packet->in_frame->duration,
267++#else
268+ zm_packet->in_frame->pkt_duration,
269++#endif
270+ duration,
271+ video_in_stream->time_base.num,
272+ video_in_stream->time_base.den,
273+@@ -1261,9 +1312,15 @@ int VideoStore::writeVideoFramePacket(co
274+ duration
275+ );
276+ if (duration <= 0) {
277++#if LIBAVCODEC_VERSION_CHECK(60, 3, 0, 3, 0)
278++ duration = zm_packet->in_frame->duration ?
279++ zm_packet->in_frame->duration :
280++ av_rescale_q(1, video_in_stream->time_base, video_out_stream->time_base);
281++#else
282+ duration = zm_packet->in_frame->pkt_duration ?
283+ zm_packet->in_frame->pkt_duration :
284+ av_rescale_q(1, video_in_stream->time_base, video_out_stream->time_base);
285++#endif
286+ }
287+ } // end if in_frmae->pkt_duration
288+ video_last_pts = zm_packet->in_frame->pts;
289+--- zoneminder-1.36.33+dfsg1.orig/src/zm_ffmpeg.cpp
290++++ zoneminder-1.36.33+dfsg1/src/zm_ffmpeg.cpp
291+@@ -335,7 +335,7 @@ void zm_dump_stream_format(AVFormatConte
292+ zm_log_fps(1 / av_q2d(st->time_base), "stream tb numerator");
293+ } else if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
294+ Debug(1, "profile %d channels %d sample_rate %d",
295+- codec->profile, codec->channels, codec->sample_rate);
296++ codec->profile, codec->ch_layout.nb_channels, codec->sample_rate);
297+ }
298+
299+ if (st->disposition & AV_DISPOSITION_DEFAULT)
300+--- zoneminder-1.36.33+dfsg1.orig/src/zm_ffmpeg_input.cpp
301++++ zoneminder-1.36.33+dfsg1/src/zm_ffmpeg_input.cpp
302+@@ -300,7 +300,7 @@ AVFrame *FFmpeg_Input::get_frame(int str
303+ last_seek_request = seek_target;
304+
305+ // Normally it is likely just the next packet. Need a heuristic for seeking, something like duration * keyframe interval
306+- if (frame->pts + 10*frame->pkt_duration < seek_target) {
307++ if (frame->pts + 10*frame->duration < seek_target) {
308+ Debug(1, "Jumping ahead");
309+ if (( ret = av_seek_frame(input_format_context, stream_id, seek_target,
310+ AVSEEK_FLAG_FRAME
311+@@ -313,7 +313,7 @@ AVFrame *FFmpeg_Input::get_frame(int str
312+ }
313+ // Seeking seems to typically seek to a keyframe, so then we have to decode until we get the frame we want.
314+ if (frame->pts <= seek_target) {
315+- while (frame && (frame->pts + frame->pkt_duration < seek_target)) {
316++ while (frame && (frame->pts + frame->duration < seek_target)) {
317+ if (is_video_stream(input_format_context->streams[stream_id])) {
318+ zm_dump_video_frame(frame, "pts <= seek_target");
319+ } else {
320+--- zoneminder-1.36.33+dfsg1.orig/src/zm_mpeg.cpp
321++++ zoneminder-1.36.33+dfsg1/src/zm_mpeg.cpp
322+@@ -629,7 +629,7 @@ double VideoStream::ActuallyEncodeFrame(
323+ pkt->size = buffer_size;
324+ got_packet = 1;
325+ } else {
326+- opicture_ptr->pts = codec_context->frame_number;
327++ opicture_ptr->pts = codec_context->frame_num;
328+ opicture_ptr->quality = codec_context->global_quality;
329+
330+ #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
331diff --git a/debian/patches/series b/debian/patches/series
332index 928749b..738c358 100644
333--- a/debian/patches/series
334+++ b/debian/patches/series
335@@ -3,3 +3,4 @@
336 0007-Default-to-not-checking-for-updated-versions-of-Zone.patch
337 0008-Unlink-installation-docs.patch
338 0009-Allow-generation-of-random-seeds-on-install-time-not.patch
339+0010-ffmpeg-7.patch

Subscribers

People subscribed via source and target branches