Skip to content

Commit bc04cb7

Browse files
committed
Update for FFmpeg 6
Remove flags and fields that were removed in FFmpeg 6, and rename AV_CODEC_CAP_AUTO_THREADS to AV_CODEC_CAP_OTHER_THREADS. These changes reflect deprecations made as of FFmpeg 4.4. Remove AV_FRAME_DATA_SEI_UNREGISTERED workaround for FFmpeg < 4.4
1 parent 4349105 commit bc04cb7

File tree

7 files changed

+8
-53
lines changed

7 files changed

+8
-53
lines changed

av/codec/codec.pyx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ Capabilities = define_enum('Capabilities', 'av.codec', (
5252
"""Codec uses get_buffer() for allocating buffers and supports custom allocators.
5353
If not set, it might not use get_buffer() at all or use operations that
5454
assume the buffer was allocated by avcodec_default_get_buffer."""),
55-
('TRUNCATED', lib.AV_CODEC_CAP_TRUNCATED),
5655
('HWACCEL', 1 << 4),
5756
('DELAY', lib.AV_CODEC_CAP_DELAY,
5857
"""Encoder or decoder requires flushing with NULL input at the end in order to
@@ -102,7 +101,7 @@ Capabilities = define_enum('Capabilities', 'av.codec', (
102101
"""Codec supports slice-based (or partition-based) multithreading."""),
103102
('PARAM_CHANGE', lib.AV_CODEC_CAP_PARAM_CHANGE,
104103
"""Codec supports changed parameters at any point."""),
105-
('AUTO_THREADS', lib.AV_CODEC_CAP_AUTO_THREADS,
104+
('OTHER_THREADS', lib.AV_CODEC_CAP_OTHER_THREADS,
106105
"""Codec supports avctx->thread_count == 0 (auto)."""),
107106
('VARIABLE_FRAME_SIZE', lib.AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
108107
"""Audio encoder supports receiving a different number of samples in each call."""),
@@ -114,10 +113,6 @@ Capabilities = define_enum('Capabilities', 'av.codec', (
114113
the stream.
115114
A decoder marked with this flag should only be used as last resort
116115
choice for probing."""),
117-
('INTRA_ONLY', lib.AV_CODEC_CAP_INTRA_ONLY,
118-
"""Codec is intra only."""),
119-
('LOSSLESS', lib.AV_CODEC_CAP_LOSSLESS,
120-
"""Codec is lossless."""),
121116
('HARDWARE', lib.AV_CODEC_CAP_HARDWARE,
122117
"""Codec is backed by a hardware implementation. Typically used to
123118
identify a non-hwaccel hardware decoder. For information about hwaccels, use
@@ -312,7 +307,6 @@ cdef class Codec(object):
312307

313308
draw_horiz_band = capabilities.flag_property('DRAW_HORIZ_BAND')
314309
dr1 = capabilities.flag_property('DR1')
315-
truncated = capabilities.flag_property('TRUNCATED')
316310
hwaccel = capabilities.flag_property('HWACCEL')
317311
delay = capabilities.flag_property('DELAY')
318312
small_last_frame = capabilities.flag_property('SMALL_LAST_FRAME')
@@ -324,11 +318,9 @@ cdef class Codec(object):
324318
frame_threads = capabilities.flag_property('FRAME_THREADS')
325319
slice_threads = capabilities.flag_property('SLICE_THREADS')
326320
param_change = capabilities.flag_property('PARAM_CHANGE')
327-
auto_threads = capabilities.flag_property('AUTO_THREADS')
321+
other_threads = capabilities.flag_property('OTHER_THREADS')
328322
variable_frame_size = capabilities.flag_property('VARIABLE_FRAME_SIZE')
329323
avoid_probing = capabilities.flag_property('AVOID_PROBING')
330-
# intra_only = capabilities.flag_property('INTRA_ONLY') # Dupes.
331-
# lossless = capabilities.flag_property('LOSSLESS') # Dupes.
332324
hardware = capabilities.flag_property('HARDWARE')
333325
hybrid = capabilities.flag_property('HYBRID')
334326
encoder_reordered_opaque = capabilities.flag_property('ENCODER_REORDERED_OPAQUE')

av/codec/context.pyx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ Flags = define_enum('Flags', __name__, (
9696
"""Only decode/encode grayscale."""),
9797
('PSNR', lib.AV_CODEC_FLAG_PSNR,
9898
"""error[?] variables will be set during encoding."""),
99-
('TRUNCATED', lib.AV_CODEC_FLAG_TRUNCATED,
100-
"""Input bitstream might be truncated at a random location
101-
instead of only at frame boundaries."""),
10299
('INTERLACED_DCT', lib.AV_CODEC_FLAG_INTERLACED_DCT,
103100
"""Use interlaced DCT."""),
104101
('LOW_DELAY', lib.AV_CODEC_FLAG_LOW_DELAY,
@@ -122,8 +119,6 @@ Flags2 = define_enum('Flags2', __name__, (
122119
"""Skip bitstream encoding."""),
123120
('LOCAL_HEADER', lib.AV_CODEC_FLAG2_LOCAL_HEADER,
124121
"""Place global headers at every keyframe instead of in extradata."""),
125-
('DROP_FRAME_TIMECODE', lib.AV_CODEC_FLAG2_DROP_FRAME_TIMECODE,
126-
"""Timecode is in drop frame format. DEPRECATED!!!!"""),
127122
('CHUNKS', lib.AV_CODEC_FLAG2_CHUNKS,
128123
"""Input bitstream might be truncated at a packet boundaries
129124
instead of only at frame boundaries."""),
@@ -168,10 +163,6 @@ cdef class CodecContext(object):
168163
self.ptr.thread_count = 0
169164
self.ptr.thread_type = 2
170165

171-
# Use "ass" format for subtitles (default as of FFmpeg 5.0), not the
172-
# deprecated "ass_with_timings" formats.
173-
self.ptr.sub_text_format = 0
174-
175166
def _get_flags(self):
176167
return self.ptr.flags
177168

@@ -195,7 +186,6 @@ cdef class CodecContext(object):
195186
loop_filter = flags.flag_property('LOOP_FILTER')
196187
gray = flags.flag_property('GRAY')
197188
psnr = flags.flag_property('PSNR')
198-
truncated = flags.flag_property('TRUNCATED')
199189
interlaced_dct = flags.flag_property('INTERLACED_DCT')
200190
low_delay = flags.flag_property('LOW_DELAY')
201191
global_header = flags.flag_property('GLOBAL_HEADER')
@@ -219,7 +209,6 @@ cdef class CodecContext(object):
219209
fast = flags2.flag_property('FAST')
220210
no_output = flags2.flag_property('NO_OUTPUT')
221211
local_header = flags2.flag_property('LOCAL_HEADER')
222-
drop_frame_timecode = flags2.flag_property('DROP_FRAME_TIMECODE')
223212
chunks = flags2.flag_property('CHUNKS')
224213
ignore_crop = flags2.flag_property('IGNORE_CROP')
225214
show_all = flags2.flag_property('SHOW_ALL')
@@ -273,13 +262,6 @@ cdef class CodecContext(object):
273262
raise ValueError('CodecContext is already open.')
274263
return
275264

276-
# We might pass partial frames.
277-
# TODO: What is this for?! This is causing problems with raw decoding
278-
# as the internal parser doesn't seem to see a frame until it sees
279-
# the next one.
280-
# if self.codec.ptr.capabilities & lib.CODEC_CAP_TRUNCATED:
281-
# self.ptr.flags |= lib.CODEC_FLAG_TRUNCATED
282-
283265
# TODO: Do this better.
284266
cdef _Dictionary options = Dictionary()
285267
options.update(self.options or {})

av/container/core.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ Flags = define_enum('Flags', __name__, (
157157
This flag is mainly intended for testing."""),
158158
('SORT_DTS', lib.AVFMT_FLAG_SORT_DTS,
159159
"Try to interleave outputted packets by dts (using this flag can slow demuxing down)."),
160-
('PRIV_OPT', lib.AVFMT_FLAG_PRIV_OPT,
161-
"Enable use of private options by delaying codec open (this could be made default once all code is converted)."),
162160
('FAST_SEEK', lib.AVFMT_FLAG_FAST_SEEK,
163161
"Enable fast, but inaccurate seeks for some formats."),
164162
('SHORTEST', lib.AVFMT_FLAG_SHORTEST,
@@ -329,7 +327,6 @@ cdef class Container(object):
329327
flush_packets = flags.flag_property('FLUSH_PACKETS')
330328
bit_exact = flags.flag_property('BITEXACT')
331329
sort_dts = flags.flag_property('SORT_DTS')
332-
priv_opt = flags.flag_property('PRIV_OPT')
333330
fast_seek = flags.flag_property('FAST_SEEK')
334331
shortest = flags.flag_property('SHORTEST')
335332
auto_bsf = flags.flag_property('AUTO_BSF')

docs/api/codec.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ Flags
4545

4646
Wraps :ffmpeg:`AVCodec.capabilities` (``AV_CODEC_CAP_*``).
4747

48-
Note that ``ffmpeg -codecs`` prefers the properties versions of
49-
``INTRA_ONLY`` and ``LOSSLESS``.
50-
5148
.. enumtable:: av.codec.codec.Capabilities
5249
:class: av.codec.codec.Codec
5350

include/libavcodec/avcodec.pxd

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ from libc.stdint cimport (
77

88

99
cdef extern from "libavcodec/avcodec.h" nogil:
10-
"""
11-
// AV_FRAME_DATA_SEI_UNREGISTERED available since version 56.54.100 of libavutil (FFmpeg >= 4.4)
12-
#define HAS_AV_FRAME_DATA_SEI_UNREGISTERED (LIBAVUTIL_VERSION_INT >= 3683940)
13-
14-
#if !HAS_AV_FRAME_DATA_SEI_UNREGISTERED
15-
#define AV_FRAME_DATA_SEI_UNREGISTERED -1
16-
#endif
17-
"""
1810

1911
# custom
2012
cdef set pyav_get_available_codecs()
@@ -39,7 +31,6 @@ cdef extern from "libavcodec/avcodec.h" nogil:
3931
cdef enum:
4032
AV_CODEC_CAP_DRAW_HORIZ_BAND
4133
AV_CODEC_CAP_DR1
42-
AV_CODEC_CAP_TRUNCATED
4334
# AV_CODEC_CAP_HWACCEL
4435
AV_CODEC_CAP_DELAY
4536
AV_CODEC_CAP_SMALL_LAST_FRAME
@@ -51,11 +42,9 @@ cdef extern from "libavcodec/avcodec.h" nogil:
5142
AV_CODEC_CAP_FRAME_THREADS
5243
AV_CODEC_CAP_SLICE_THREADS
5344
AV_CODEC_CAP_PARAM_CHANGE
54-
AV_CODEC_CAP_AUTO_THREADS
45+
AV_CODEC_CAP_OTHER_THREADS
5546
AV_CODEC_CAP_VARIABLE_FRAME_SIZE
5647
AV_CODEC_CAP_AVOID_PROBING
57-
AV_CODEC_CAP_INTRA_ONLY
58-
AV_CODEC_CAP_LOSSLESS
5948
AV_CODEC_CAP_HARDWARE
6049
AV_CODEC_CAP_HYBRID
6150
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
@@ -76,7 +65,6 @@ cdef extern from "libavcodec/avcodec.h" nogil:
7665
AV_CODEC_FLAG_LOOP_FILTER
7766
AV_CODEC_FLAG_GRAY
7867
AV_CODEC_FLAG_PSNR
79-
AV_CODEC_FLAG_TRUNCATED
8068
AV_CODEC_FLAG_INTERLACED_DCT
8169
AV_CODEC_FLAG_LOW_DELAY
8270
AV_CODEC_FLAG_GLOBAL_HEADER
@@ -89,7 +77,6 @@ cdef extern from "libavcodec/avcodec.h" nogil:
8977
AV_CODEC_FLAG2_FAST
9078
AV_CODEC_FLAG2_NO_OUTPUT
9179
AV_CODEC_FLAG2_LOCAL_HEADER
92-
AV_CODEC_FLAG2_DROP_FRAME_TIMECODE
9380
AV_CODEC_FLAG2_CHUNKS
9481
AV_CODEC_FLAG2_IGNORE_CROP
9582
AV_CODEC_FLAG2_SHOW_ALL
@@ -224,9 +211,6 @@ cdef extern from "libavcodec/avcodec.h" nogil:
224211
int frame_size
225212
int channel_layout
226213

227-
# Subtitles.
228-
int sub_text_format
229-
230214
#: .. todo:: ``get_buffer`` is deprecated for get_buffer2 in newer versions of FFmpeg.
231215
int get_buffer(AVCodecContext *ctx, AVFrame *frame)
232216
void release_buffer(AVCodecContext *ctx, AVFrame *frame)

include/libavformat/avformat.pxd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ cdef extern from "libavformat/avformat.h" nogil:
146146
AVFMT_FLAG_FLUSH_PACKETS
147147
AVFMT_FLAG_BITEXACT
148148
AVFMT_FLAG_SORT_DTS
149-
AVFMT_FLAG_PRIV_OPT
150149
AVFMT_FLAG_FAST_SEEK
151150
AVFMT_FLAG_SHORTEST
152151
AVFMT_FLAG_AUTO_BSF

tests/test_subtitles.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ def test_movtext(self):
2424

2525
sub = subset[0]
2626
self.assertIsInstance(sub, AssSubtitle)
27-
self.assertEqual(sub.ass, "0,0,Default,,0,0,0,,- Test 1.\\N- Test 2.")
27+
# The default subtitle format changed in FFmpeg 5.0
28+
if av.library_versions["libavcodec"] >= (59, 18):
29+
self.assertEqual(sub.ass, "0,0,Default,,0,0,0,,- Test 1.\\N- Test 2.")
30+
else:
31+
self.assertEqual(sub.ass, "Dialogue: 0,0:00:00.97,0:00:02.54,Default,,0,0,0,,- Test 1.\\N- Test 2.\r\n")
2832

2933
def test_vobsub(self):
3034

0 commit comments

Comments
 (0)