Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Fixes:
- ``AudioFrame.planes`` no longer counts one plane too many for 8-channel planar audio (e.g. ``fltp`` with ``7.1``), which made ``planes``, ``to_ndarray()``, and ``from_ndarray()`` raise ``ValueError``, and no longer reads past the end of ``extended_data`` for more channels. By :gh-user:`ChandraChaan` in (:pr:`2502`).
- ``AudioFifo.write()`` now raises ``ValueError`` for a frame whose channel layout differs from the first frame's, instead of reading the wrong number of channels and scrambling or over-reading the samples. By :gh-user:`ChandraChaan` in (:pr:`2505`).
- A failed ``CodecContext.open()`` no longer clears the selected codec, so ``codec``, ``name``, ``is_encoder``, and ``is_decoder`` keep working and the context can be reused after fixing the offending parameters.
- :class:`.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 :gh-user:`NotAFlightRisk`.

v19.0.2
-------
Expand Down
1 change: 1 addition & 0 deletions av/bitstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __cinit__(
self.ptr.par_in, cython.cast(Stream, in_stream).ptr.codecpar
)
err_check(res)
self.ptr.time_base_in = cython.cast(Stream, in_stream).ptr.time_base
elif in_stream is not None:
# A Codec or codec name only pins the input codec, which is enough for
# codec-specific filters (e.g. h264_mp4toannexb) to initialize.
Expand Down
1 change: 1 addition & 0 deletions include/avcodec.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ cdef extern from "libavcodec/bsf.h" nogil:
const AVBitStreamFilter *filter
AVCodecParameters *par_in
AVCodecParameters *par_out
AVRational time_base_in

cdef int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf)
cdef int av_bsf_init(AVBSFContext *ctx)
Expand Down
16 changes: 16 additions & 0 deletions tests/test_bitstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ def test_filter_h264_mp4toannexb() -> None:
assert is_annexb(res_packet)


def test_filter_setts_uses_stream_time_base() -> None:
with av.open(fate_suite("h264/interlaced_crop.mp4"), "r") as container:
stream = container.streams.video[0]
ctx = BitStreamFilterContext("setts=pts=PTS+10/TB", stream)

offset = int(10 / stream.time_base)
expected = []
res_packets = []
for p in container.demux(stream):
if p.pts is not None:
expected.append(p.pts + offset)
res_packets.extend(ctx.filter(p))

assert [p.pts for p in res_packets] == expected


def test_filter_in_stream_codec_and_name() -> None:
# A Codec or codec-name str can stand in for a Stream to pin the input codec,
# which is all a codec-specific filter needs to initialize.
Expand Down
Loading