__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
cimport libav as lib
from av.bytesource cimport bytesource
from av.error cimport err_check
from av.opaque cimport opaque_container
from av.utils cimport avrational_to_fraction, to_avrational
cdef class Packet(Buffer):
"""A packet of encoded data within a :class:`~av.format.Stream`.
This may, or may not include a complete object within a stream.
:meth:`decode` must be called to extract encoded data.
"""
def __cinit__(self, input=None):
with nogil:
self.ptr = lib.av_packet_alloc()
def __init__(self, input=None):
cdef size_t size = 0
cdef ByteSource source = None
if input is None:
return
if isinstance(input, int):
size = input
else:
source = bytesource(input)
size = source.length
if size:
err_check(lib.av_new_packet(self.ptr, size))
if source is not None:
self.update(source)
# TODO: Hold onto the source, and copy its pointer
# instead of its data.
# self.source = source
def __dealloc__(self):
with nogil:
lib.av_packet_free(&self.ptr)
def __repr__(self):
stream = self._stream.index if self._stream else 0
return (
f"<av.{self.__class__.__name__} of #{stream}, dts={self.dts},"
f" pts={self.pts}; {self.ptr.size} bytes at 0x{id(self):x}>"
)
# Buffer protocol.
cdef size_t _buffer_size(self):
return self.ptr.size
cdef void* _buffer_ptr(self):
return self.ptr.data
cdef _rebase_time(self, lib.AVRational dst):
if not dst.num:
raise ValueError("Cannot rebase to zero time.")
if not self._time_base.num:
self._time_base = dst
return
if self._time_base.num == dst.num and self._time_base.den == dst.den:
return
lib.av_packet_rescale_ts(self.ptr, self._time_base, dst)
self._time_base = dst
def decode(self):
"""
Send the packet's data to the decoder and return a list of
:class:`.AudioFrame`, :class:`.VideoFrame` or :class:`.SubtitleSet`.
"""
return self._stream.decode(self)
@property
def stream_index(self):
return self.ptr.stream_index
@property
def stream(self):
"""
The :class:`Stream` this packet was demuxed from.
"""
return self._stream
@stream.setter
def stream(self, Stream stream):
self._stream = stream
self.ptr.stream_index = stream.ptr.index
@property
def time_base(self):
"""
The unit of time (in fractional seconds) in which timestamps are expressed.
:type: fractions.Fraction
"""
return avrational_to_fraction(&self._time_base)
@time_base.setter
def time_base(self, value):
to_avrational(value, &self._time_base)
@property
def pts(self):
"""
The presentation timestamp in :attr:`time_base` units for this packet.
This is the time at which the packet should be shown to the user.
:type: int
"""
if self.ptr.pts != lib.AV_NOPTS_VALUE:
return self.ptr.pts
@pts.setter
def pts(self, v):
if v is None:
self.ptr.pts = lib.AV_NOPTS_VALUE
else:
self.ptr.pts = v
@property
def dts(self):
"""
The decoding timestamp in :attr:`time_base` units for this packet.
:type: int
"""
if self.ptr.dts != lib.AV_NOPTS_VALUE:
return self.ptr.dts
@dts.setter
def dts(self, v):
if v is None:
self.ptr.dts = lib.AV_NOPTS_VALUE
else:
self.ptr.dts = v
@property
def pos(self):
"""
The byte position of this packet within the :class:`.Stream`.
Returns `None` if it is not known.
:type: int
"""
if self.ptr.pos != -1:
return self.ptr.pos
@property
def size(self):
"""
The size in bytes of this packet's data.
:type: int
"""
return self.ptr.size
@property
def duration(self):
"""
The duration in :attr:`time_base` units for this packet.
Returns `None` if it is not known.
:type: int
"""
if self.ptr.duration != lib.AV_NOPTS_VALUE:
return self.ptr.duration
@duration.setter
def duration(self, v):
if v is None:
self.ptr.duration = lib.AV_NOPTS_VALUE
else:
self.ptr.duration = v
@property
def is_keyframe(self):
return bool(self.ptr.flags & lib.AV_PKT_FLAG_KEY)
@is_keyframe.setter
def is_keyframe(self, v):
if v:
self.ptr.flags |= lib.AV_PKT_FLAG_KEY
else:
self.ptr.flags &= ~(lib.AV_PKT_FLAG_KEY)
@property
def is_corrupt(self):
return bool(self.ptr.flags & lib.AV_PKT_FLAG_CORRUPT)
@is_corrupt.setter
def is_corrupt(self, v):
if v:
self.ptr.flags |= lib.AV_PKT_FLAG_CORRUPT
else:
self.ptr.flags &= ~(lib.AV_PKT_FLAG_CORRUPT)
@property
def is_discard(self):
return bool(self.ptr.flags & lib.AV_PKT_FLAG_DISCARD)
@property
def is_trusted(self):
return bool(self.ptr.flags & lib.AV_PKT_FLAG_TRUSTED)
@property
def is_disposable(self):
return bool(self.ptr.flags & lib.AV_PKT_FLAG_DISPOSABLE)
@property
def opaque(self):
if self.ptr.opaque_ref is not NULL:
return opaque_container.get(<char *> self.ptr.opaque_ref.data)
@opaque.setter
def opaque(self, v):
lib.av_buffer_unref(&self.ptr.opaque_ref)
if v is None:
return
self.ptr.opaque_ref = opaque_container.add(v)
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| attachments | Folder | 0755 |
|
|
| audio | Folder | 0755 |
|
|
| codec | Folder | 0755 |
|
|
| container | Folder | 0755 |
|
|
| data | Folder | 0755 |
|
|
| filter | Folder | 0755 |
|
|
| sidedata | Folder | 0755 |
|
|
| subtitles | Folder | 0755 |
|
|
| video | Folder | 0755 |
|
|
| __init__.pxd | File | 0 B | 0644 |
|
| __init__.py | File | 2.07 KB | 0644 |
|
| __main__.py | File | 1.53 KB | 0644 |
|
| _core.cpython-313-aarch64-linux-gnu.so | File | 66.98 KB | 0644 |
|
| _core.pyi | File | 251 B | 0644 |
|
| _core.pyx | File | 1.92 KB | 0644 |
|
| about.py | File | 23 B | 0644 |
|
| bitstream.cpython-313-aarch64-linux-gnu.so | File | 69.05 KB | 0644 |
|
| bitstream.pxd | File | 184 B | 0644 |
|
| bitstream.pyi | File | 389 B | 0644 |
|
| bitstream.pyx | File | 2.73 KB | 0644 |
|
| buffer.cpython-313-aarch64-linux-gnu.so | File | 69.18 KB | 0644 |
|
| buffer.pxd | File | 126 B | 0644 |
|
| buffer.pyi | File | 316 B | 0644 |
|
| buffer.pyx | File | 1.6 KB | 0644 |
|
| bytesource.cpython-313-aarch64-linux-gnu.so | File | 68.87 KB | 0644 |
|
| bytesource.pxd | File | 241 B | 0644 |
|
| bytesource.pyx | File | 1.07 KB | 0644 |
|
| datasets.py | File | 3.02 KB | 0644 |
|
| descriptor.cpython-313-aarch64-linux-gnu.so | File | 69.02 KB | 0644 |
|
| descriptor.pxd | File | 519 B | 0644 |
|
| descriptor.pyi | File | 121 B | 0644 |
|
| descriptor.pyx | File | 2.21 KB | 0644 |
|
| dictionary.cpython-313-aarch64-linux-gnu.so | File | 134.56 KB | 0644 |
|
| dictionary.pxd | File | 174 B | 0644 |
|
| dictionary.pyi | File | 388 B | 0644 |
|
| dictionary.pyx | File | 1.52 KB | 0644 |
|
| error.cpython-313-aarch64-linux-gnu.so | File | 262.11 KB | 0644 |
|
| error.pxd | File | 89 B | 0644 |
|
| error.pyi | File | 3.13 KB | 0644 |
|
| error.pyx | File | 12.12 KB | 0644 |
|
| format.cpython-313-aarch64-linux-gnu.so | File | 133.55 KB | 0644 |
|
| format.pxd | File | 234 B | 0644 |
|
| format.pyi | File | 1.37 KB | 0644 |
|
| format.pyx | File | 5.57 KB | 0644 |
|
| frame.cpython-313-aarch64-linux-gnu.so | File | 69.44 KB | 0644 |
|
| frame.pxd | File | 411 B | 0644 |
|
| frame.pyi | File | 507 B | 0644 |
|
| frame.pyx | File | 4.82 KB | 0644 |
|
| logging.cpython-313-aarch64-linux-gnu.so | File | 133.65 KB | 0644 |
|
| logging.pxd | File | 24 B | 0644 |
|
| logging.pyi | File | 885 B | 0644 |
|
| logging.pyx | File | 8.87 KB | 0644 |
|
| opaque.cpython-313-aarch64-linux-gnu.so | File | 68.95 KB | 0644 |
|
| opaque.pxd | File | 237 B | 0644 |
|
| opaque.pyx | File | 833 B | 0644 |
|
| option.cpython-313-aarch64-linux-gnu.so | File | 135.05 KB | 0644 |
|
| option.pxd | File | 366 B | 0644 |
|
| option.pyi | File | 1.28 KB | 0644 |
|
| option.pyx | File | 5.02 KB | 0644 |
|
| packet.cpython-313-aarch64-linux-gnu.so | File | 133.67 KB | 0644 |
|
| packet.pxd | File | 447 B | 0644 |
|
| packet.pyi | File | 559 B | 0644 |
|
| packet.pyx | File | 5.77 KB | 0644 |
|
| plane.cpython-313-aarch64-linux-gnu.so | File | 68.91 KB | 0644 |
|
| plane.pxd | File | 196 B | 0644 |
|
| plane.pyi | File | 169 B | 0644 |
|
| plane.pyx | File | 564 B | 0644 |
|
| py.typed | File | 0 B | 0644 |
|
| stream.cpython-313-aarch64-linux-gnu.so | File | 133.61 KB | 0644 |
|
| stream.pxd | File | 635 B | 0644 |
|
| stream.pyi | File | 1.29 KB | 0644 |
|
| stream.pyx | File | 7.19 KB | 0644 |
|
| utils.cpython-313-aarch64-linux-gnu.so | File | 66.89 KB | 0644 |
|
| utils.pxd | File | 452 B | 0644 |
|
| utils.pyx | File | 2.06 KB | 0644 |
|