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
4 changes: 2 additions & 2 deletions av/codec/context.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ cdef class CodecContext:
#
# NOTE: if the CodecContext's time_base is altered during encoding, all bets
# are off!
packet._time_base = self.ptr.time_base
packet.ptr.time_base = self.ptr.time_base

cpdef decode(self, Packet packet=None):
"""Decode a list of :class:`.Frame` from the given :class:`.Packet`.
Expand Down Expand Up @@ -469,7 +469,7 @@ cdef class CodecContext:
# TODO: Somehow get this from the stream so we can not pass the
# packet here (because flushing packets are bogus).
if packet is not None:
frame._time_base = packet._time_base
frame._time_base = packet.ptr.time_base

@property
def name(self):
Expand Down
4 changes: 2 additions & 2 deletions av/container/input.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ cdef class InputContainer(Container):
if packet.ptr.stream_index < len(self.streams):
packet._stream = self.streams[packet.ptr.stream_index]
# Keep track of this so that remuxing is easier.
packet._time_base = packet._stream.ptr.time_base
packet.ptr.time_base = packet._stream.ptr.time_base
yield packet

# Flush!
for i in range(self.ptr.nb_streams):
if include_stream[i]:
packet = Packet()
packet._stream = self.streams[i]
packet._time_base = packet._stream.ptr.time_base
packet.ptr.time_base = packet._stream.ptr.time_base
yield packet

finally:
Expand Down
6 changes: 0 additions & 6 deletions av/packet.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ from av.stream cimport Stream


cdef class Packet(Buffer):

cdef lib.AVPacket* ptr

cdef Stream _stream

# We track our own time.
cdef lib.AVRational _time_base
cdef _rebase_time(self, lib.AVRational)

# Hold onto the original reference.
cdef ByteSource source
cdef size_t _buffer_size(self)
Expand Down
15 changes: 7 additions & 8 deletions av/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ def _rebase_time(self, dst: lib.AVRational):
if not dst.num:
raise ValueError("Cannot rebase to zero time.")

if not self._time_base.num:
self._time_base = dst
if not self.ptr.time_base.num:
self.ptr.time_base = dst
return

if self._time_base.num == dst.num and self._time_base.den == dst.den:
if self.ptr.time_base.num == dst.num and self.ptr.time_base.den == dst.den:
return

lib.av_packet_rescale_ts(self.ptr, self._time_base, dst)

self._time_base = dst
lib.av_packet_rescale_ts(self.ptr, self.ptr.time_base, dst)
self.ptr.time_base = dst

def decode(self):
"""
Expand Down Expand Up @@ -106,11 +105,11 @@ def time_base(self):

:type: fractions.Fraction
"""
return avrational_to_fraction(cython.address(self._time_base))
return avrational_to_fraction(cython.address(self.ptr.time_base))

@time_base.setter
def time_base(self, value):
to_avrational(value, cython.address(self._time_base))
to_avrational(value, cython.address(self.ptr.time_base))

@property
def pts(self):
Expand Down
6 changes: 1 addition & 5 deletions include/libavcodec/avcodec.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -466,19 +466,15 @@ cdef extern from "libavcodec/avcodec.h" nogil:
cdef AVFrame* avcodec_alloc_frame()

cdef struct AVPacket:

int64_t pts
int64_t dts
uint8_t *data

AVRational time_base
int size
int stream_index
int flags

int duration

int64_t pos

void *opaque
AVBufferRef *opaque_ref

Expand Down
Loading