Skip to content

v18.1.1

Choose a tag to compare

@WyattBlue WyattBlue released this 21 Nov 04:50
· 1 commit to release/18.1 since this release

Fixes

  • Expose Frame.best_effort_timestamp, FFmpeg's estimate of a frame's presentation time, which falls back to the DTS when the PTS is unreliable (#2477).

  • Fix several crashes from reading freed or out-of-range memory:

    • Reading a Stream or its index_entries after the container is closed now raises instead of reading freed memory. An IndexEntry is a copy, so it stays readable after the close.
    • Resuming demux() or decode() after the container is closed now raises instead of reading the freed format context.
    • add_stream_from_template() checks that the template's container is still open.
    • Indexes are range checked before being turned into pointer arithmetic: MotionVectors[i] accepts negative indexes, and VideoFormatComponent, AudioPlane, BitmapSubtitlePlane, and VideoBlockParams reject out-of-range ones. VideoBlockParams also keeps its VideoEncParams alive.
    • A Python file whose read(n) returns more than n bytes raises ValueError instead of overflowing FFmpeg's I/O buffer.
    • Packet(bytearray) copies the data, so resizing the bytearray afterwards no longer leaves the packet reading freed memory.
    • Inserting into a Dictionary while iterating it no longer reads an invalidated entry.
    • HWConfig and the side data wrappers can no longer be left holding a NULL pointer when created through __new__.
  • Fix crashes in filter graphs:

    • A FilterContext or FilterLink that outlives its Graph keeps the graph alive instead of using freed memory.
    • push() to a buffer source configures the graph first, as pull() does.
    • Filters added or linked after Graph.configure() are configured on the next push or pull instead of segfaulting.
    • FilterContext.link_to raises ValueError when linking filters from different graphs instead of aborting the process.
  • FilterLink.input and FilterLink.output now follow the filters the graph auto-inserts while configuring, instead of the pad they first resolved.

  • repr() of a filter pad no longer raises AttributeError.

  • Fix memory corruption when decoding audio with custom channel layouts (e.g. "FR+FL"), which were shallow-copied and double freed (#2444).

  • Fix a deadlock when freeing a frame-threaded decoder while a worker thread logs an error. The codec context is now freed with the GIL released (#2440).

  • Release the GIL around hardware frame transfers.

  • Fix corrupted rows in threaded high bit depth VideoFrame.reformat() on x86 (#2431).

  • VideoFrame.reformat() (and so to_ndarray(format=...), to_rgb(), and to_image()) shares one SwsContext per thread instead of allocating one per frame, which used megabytes per frame with FFmpeg 8 (#2320).

  • Fix reference cycles that kept frames, streams, and filters alive until gc ran: reading Frame.side_data, MotionVectors memoizing its vectors, Stream.index_entries (#2425), and filter pads.

  • Frame.side_data now satisfies the Mapping protocol it advertises: iteration yields Type keys, so items(), keys(), and values() work instead of raising KeyError.

  • Frame.side_data and PacketSideData.data_type no longer raise on side data types FFmpeg has added since PyAV last listed them, such as the AV_PKT_DATA_HEVC_CONF an HEVC stream in MP4 or Matroska carries.

  • Attaching one object to the opaque of more than one frame or packet no longer loses it when the first holder is freed.

  • Frames returned by flushing a codec context directly (CodecContext.decode() with no packet) now carry the stream's time_base instead of None.

  • A failed CodecContext.open() no longer clears the selected codec, so is_encoder and is_decoder keep working and the context can be reopened after fixing the offending parameters.

  • A rejected add_stream() or add_mux_stream() no longer breaks the container, and a failed stream or output allocation no longer leaks.

  • Output containers pass their options to avio_open2(), so protocol options are used by the protocol. By @ANDYwyLEE.

  • InputContainer.size returns None when the size cannot be determined instead of a negative error code.

  • Audio encoding passes the codec's thread_count to its internal AudioResampler, which no longer starts an idle thread per CPU for codecs without threading. By @tonyay163.

  • AudioFrame.planes no longer counts one plane too many for 8-channel planar audio, and no longer reads past extended_data for more channels. By @ChandraChaan in (#2502).

  • AudioFifo.write() raises ValueError for a frame whose channel layout differs from the first frame's, instead of scrambling or over-reading the samples. By @ChandraChaan in (#2505).

  • SubtitleCodecContext.decode(None) flushes the decoder instead of raising RuntimeError, so delayed decoders such as EIA-608 closed captions return their final subtitle.

  • AssSubtitle.dialogue strips override tags such as {\b1}, turns \n and \h into spaces, treats \{ and \} as literal braces, and keeps a { with no closing } instead of dropping the rest of the line.

  • HWAccel.create passes flags on to the context it creates instead of dropping them.

  • Packet(str) and setting CodecContext.extradata to a str no longer drop the last bytes of non-ASCII text.

  • AVRational values with a zero denominator compare and hash consistently with float and Decimal infinities, and its operators return NotImplemented for unsupported operands.

  • av.video.frame.supported_np_pix_fmts now lists yuv422p.

  • BitStreamFilterContext now passes in_stream's time base to the filter, so filters that read it, such as setts with TB and pcm_rechunk, no longer return None timestamps. By @NotAFlightRisk.

  • CodecContext.open releases the GIL while the codec opens, as do creating a hardware device and its encoder frame pool, so other Python threads keep running while a hardware encoder takes seconds to start (#2517).

  • Release the GIL while initializing filters, configuring filter graphs, listing devices, and creating the CUDA device and frame pool used by VideoFrame.from_dlpack(), so slow setup such as loading a whisper model or probing capture devices no longer stops other Python threads.

  • FilterContext.push(None) on a filter that isn't a buffer source now flushes through its input instead of segfaulting.

  • VideoFrame.from_numpy_buffer() raises ValueError when width is wider than the array's rows, instead of reading past the end of the buffer.

  • VideoFrame.from_numpy_buffer() with a gbrp or gbrap format no longer garbles input whose rows are padded, or reads past the end of its copy.

  • Memory borrowed from read-only Python objects is no longer exported as writable: a Packet made from bytes or str, a frame from VideoFrame.from_numpy_buffer() on a read-only array, and side data now give read-only memoryview objects and refuse update().

  • Writing to a Python file object whose write() accepts only part of each buffer, such as a socket or pipe, no longer silently drops the rest.

  • Closing an input container opened with io_open now closes the file io_open returned for the main input, instead of leaving it open.

  • Container.set_chapters() no longer leaks memory or drops the existing chapters when given an invalid entry.

  • AVRational(x) now converts a float, Decimal or Fraction exactly instead of truncating it to an integer, and AVRational(num, den) raises TypeError unless both are integers.

  • VideoFrame.reformat() no longer changes a bt470bg frame's colorspace to smpte170m when dst_colorspace isn't given.

  • HWAccel now raises ValueError for an unknown device type name instead of falling back to the codec's first hardware config.

  • frame.side_data.get() and in no longer raise IndexError for an out-of-range integer key.

  • CodecContext.codec_tag no longer raises UnicodeDecodeError for a tag that isn't ASCII, such as AAC in WAV; it now reads and sets each byte as one Latin-1 character.

  • A failed VideoFrame.reformat() no longer leaves the source frame's color_trc and color_primaries changed to unspecified.

  • Setting CodecContext.extradata or SubtitleCodecContext.subtitle_header now zeroes the padding FFmpeg reads past the data, so an ASS header no longer reads past the end of its buffer.

  • VideoFrame.from_numpy_buffer() with yuv420p, yuvj420p, or nv12 now gets the right height when it isn't a multiple of 4.

  • container.streams.best() raises an error on a closed container instead of segfaulting.

  • OutputContainer.add_attachment() now pads its data with the zeroed bytes FFmpeg requires after it.

Full Changelog: v18.1.0...v18.1.1