__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ 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.packet cimport Packet
from av.utils cimport avrational_to_fraction, to_avrational
from .frame cimport VideoFrame
cdef class VideoStream(Stream):
def __repr__(self):
return (
f"<av.VideoStream #{self.index} {self.name}, "
f"{self.format.name if self.format else None} {self.codec_context.width}x"
f"{self.codec_context.height} at 0x{id(self):x}>"
)
def __getattr__(self, name):
if name in ("framerate", "rate"):
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
return getattr(self.codec_context, name)
cpdef encode(self, VideoFrame frame=None):
"""
Encode an :class:`.VideoFrame` and return a list of :class:`.Packet`.
:rtype: list[Packet]
.. seealso:: This is mostly a passthrough to :meth:`.CodecContext.encode`.
"""
packets = self.codec_context.encode(frame)
cdef Packet packet
for packet in packets:
packet._stream = self
packet.ptr.stream_index = self.ptr.index
return packets
cpdef decode(self, Packet packet=None):
"""
Decode a :class:`.Packet` and return a list of :class:`.VideoFrame`.
:rtype: list[VideoFrame]
.. seealso:: This is a passthrough to :meth:`.CodecContext.decode`.
"""
return self.codec_context.decode(packet)
@property
def average_rate(self):
"""
The average frame rate of this video stream.
This is calculated when the file is opened by looking at the first
few frames and averaging their rate.
:type: fractions.Fraction | None
"""
return avrational_to_fraction(&self.ptr.avg_frame_rate)
@property
def base_rate(self):
"""
The base frame rate of this stream.
This is calculated as the lowest framerate at which the timestamps of
frames can be represented accurately. See :ffmpeg:`AVStream.r_frame_rate`
for more.
:type: fractions.Fraction | None
"""
return avrational_to_fraction(&self.ptr.r_frame_rate)
@property
def guessed_rate(self):
"""The guessed frame rate of this stream.
This is a wrapper around :ffmpeg:`av_guess_frame_rate`, and uses multiple
heuristics to decide what is "the" frame rate.
:type: fractions.Fraction | None
"""
# The two NULL arguments aren't used in FFmpeg >= 4.0
cdef lib.AVRational val = lib.av_guess_frame_rate(NULL, self.ptr, NULL)
return avrational_to_fraction(&val)
@property
def sample_aspect_ratio(self):
"""The guessed sample aspect ratio (SAR) of this stream.
This is a wrapper around :ffmpeg:`av_guess_sample_aspect_ratio`, and uses multiple
heuristics to decide what is "the" sample aspect ratio.
:type: fractions.Fraction | None
"""
cdef lib.AVRational sar = lib.av_guess_sample_aspect_ratio(self.container.ptr, self.ptr, NULL)
return avrational_to_fraction(&sar)
@property
def display_aspect_ratio(self):
"""The guessed display aspect ratio (DAR) of this stream.
This is calculated from :meth:`.VideoStream.guessed_sample_aspect_ratio`.
:type: fractions.Fraction | None
"""
cdef lib.AVRational dar
lib.av_reduce(
&dar.num, &dar.den,
self.format.width * self.sample_aspect_ratio.num,
self.format.height * self.sample_aspect_ratio.den, 1024*1024)
return avrational_to_fraction(&dar)
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| __init__.pxd | File | 0 B | 0644 |
|
| __init__.py | File | 62 B | 0644 |
|
| __init__.pyi | File | 103 B | 0644 |
|
| codeccontext.cpython-313-aarch64-linux-gnu.so | File | 133.88 KB | 0644 |
|
| codeccontext.pxd | File | 1.04 KB | 0644 |
|
| codeccontext.pyi | File | 968 B | 0644 |
|
| codeccontext.pyx | File | 10.57 KB | 0644 |
|
| format.cpython-313-aarch64-linux-gnu.so | File | 136.57 KB | 0644 |
|
| format.pxd | File | 727 B | 0644 |
|
| format.pyi | File | 775 B | 0644 |
|
| format.pyx | File | 5.8 KB | 0644 |
|
| frame.cpython-313-aarch64-linux-gnu.so | File | 393.54 KB | 0644 |
|
| frame.pxd | File | 621 B | 0644 |
|
| frame.pyi | File | 2.19 KB | 0644 |
|
| frame.pyx | File | 29.07 KB | 0644 |
|
| plane.cpython-313-aarch64-linux-gnu.so | File | 69.12 KB | 0644 |
|
| plane.pxd | File | 193 B | 0644 |
|
| plane.pyi | File | 223 B | 0644 |
|
| plane.pyx | File | 1.26 KB | 0644 |
|
| reformatter.cpython-313-aarch64-linux-gnu.so | File | 133.16 KB | 0644 |
|
| reformatter.pxd | File | 373 B | 0644 |
|
| reformatter.pyi | File | 1.35 KB | 0644 |
|
| reformatter.pyx | File | 8.22 KB | 0644 |
|
| stream.cpython-313-aarch64-linux-gnu.so | File | 133.27 KB | 0644 |
|
| stream.pxd | File | 209 B | 0644 |
|
| stream.pyi | File | 1.16 KB | 0644 |
|
| stream.pyx | File | 3.57 KB | 0644 |
|