__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ 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 enum import Flag
from av.error cimport err_check
from av.packet cimport Packet
from av.utils cimport (
avdict_to_dict,
avrational_to_fraction,
dict_to_avdict,
to_avrational,
)
class Disposition(Flag):
default = 1 << 0
dub = 1 << 1
original = 1 << 2
comment = 1 << 3
lyrics = 1 << 4
karaoke = 1 << 5
forced = 1 << 6
hearing_impaired = 1 << 7
visual_impaired = 1 << 8
clean_effects = 1 << 9
attached_pic = 1 << 10
timed_thumbnails = 1 << 11
non_diegetic = 1 << 12
captions = 1 << 16
descriptions = 1 << 17
metadata = 1 << 18
dependent = 1 << 19
still_image = 1 << 20
multilayer = 1 << 21
cdef object _cinit_bypass_sentinel = object()
cdef Stream wrap_stream(Container container, lib.AVStream *c_stream, CodecContext codec_context):
"""Build an av.Stream for an existing AVStream.
The AVStream MUST be fully constructed and ready for use before this is
called.
"""
# This better be the right one...
assert container.ptr.streams[c_stream.index] == c_stream
cdef Stream py_stream
if c_stream.codecpar.codec_type == lib.AVMEDIA_TYPE_VIDEO:
from av.video.stream import VideoStream
py_stream = VideoStream.__new__(VideoStream, _cinit_bypass_sentinel)
elif c_stream.codecpar.codec_type == lib.AVMEDIA_TYPE_AUDIO:
from av.audio.stream import AudioStream
py_stream = AudioStream.__new__(AudioStream, _cinit_bypass_sentinel)
elif c_stream.codecpar.codec_type == lib.AVMEDIA_TYPE_SUBTITLE:
from av.subtitles.stream import SubtitleStream
py_stream = SubtitleStream.__new__(SubtitleStream, _cinit_bypass_sentinel)
elif c_stream.codecpar.codec_type == lib.AVMEDIA_TYPE_ATTACHMENT:
from av.attachments.stream import AttachmentStream
py_stream = AttachmentStream.__new__(AttachmentStream, _cinit_bypass_sentinel)
elif c_stream.codecpar.codec_type == lib.AVMEDIA_TYPE_DATA:
from av.data.stream import DataStream
py_stream = DataStream.__new__(DataStream, _cinit_bypass_sentinel)
else:
py_stream = Stream.__new__(Stream, _cinit_bypass_sentinel)
py_stream._init(container, c_stream, codec_context)
return py_stream
cdef class Stream:
"""
A single stream of audio, video or subtitles within a :class:`.Container`.
::
>>> fh = av.open(video_path)
>>> stream = fh.streams.video[0]
>>> stream
<av.VideoStream #0 h264, yuv420p 1280x720 at 0x...>
This encapsulates a :class:`.CodecContext`, located at :attr:`Stream.codec_context`.
Attribute access is passed through to that context when attributes are missing
on the stream itself. E.g. ``stream.options`` will be the options on the
context.
"""
def __cinit__(self, name):
if name is _cinit_bypass_sentinel:
return
raise RuntimeError("cannot manually instantiate Stream")
cdef _init(self, Container container, lib.AVStream *stream, CodecContext codec_context):
self.container = container
self.ptr = stream
self.codec_context = codec_context
if self.codec_context:
self.codec_context.stream_index = stream.index
self.metadata = avdict_to_dict(
stream.metadata,
encoding=self.container.metadata_encoding,
errors=self.container.metadata_errors,
)
def __repr__(self):
name = getattr(self, "name", None)
return (
f"<av.{self.__class__.__name__} #{self.index} {self.type or '<notype>'}/"
f"{name or '<nocodec>'} at 0x{id(self):x}>"
)
def __setattr__(self, name, value):
if name == "id":
self._set_id(value)
return
if name == "disposition":
self.ptr.disposition = value
return
# Convenience setter for codec context properties.
if self.codec_context is not None:
setattr(self.codec_context, name, value)
if name == "time_base":
self._set_time_base(value)
cdef _finalize_for_output(self):
dict_to_avdict(
&self.ptr.metadata, self.metadata,
encoding=self.container.metadata_encoding,
errors=self.container.metadata_errors,
)
if not self.ptr.time_base.num:
self.ptr.time_base = self.codec_context.ptr.time_base
# It prefers if we pass it parameters via this other object.
# Lets just copy what we want.
err_check(lib.avcodec_parameters_from_context(self.ptr.codecpar, self.codec_context.ptr))
@property
def id(self):
"""
The format-specific ID of this stream.
:type: int
"""
return self.ptr.id
cdef _set_id(self, value):
"""
Setter used by __setattr__ for the id property.
"""
if value is None:
self.ptr.id = 0
else:
self.ptr.id = value
@property
def profiles(self):
"""
List the available profiles for this stream.
:type: list[str]
"""
if self.codec_context:
return self.codec_context.profiles
else:
return []
@property
def profile(self):
"""
The profile of this stream.
:type: str
"""
if self.codec_context:
return self.codec_context.profile
else:
return None
@property
def index(self):
"""
The index of this stream in its :class:`.Container`.
:type: int
"""
return self.ptr.index
@property
def time_base(self):
"""
The unit of time (in fractional seconds) in which timestamps are expressed.
:type: fractions.Fraction | None
"""
return avrational_to_fraction(&self.ptr.time_base)
cdef _set_time_base(self, value):
"""
Setter used by __setattr__ for the time_base property.
"""
to_avrational(value, &self.ptr.time_base)
@property
def start_time(self):
"""
The presentation timestamp in :attr:`time_base` units of the first
frame in this stream.
:type: int | None
"""
if self.ptr.start_time != lib.AV_NOPTS_VALUE:
return self.ptr.start_time
@property
def duration(self):
"""
The duration of this stream in :attr:`time_base` units.
:type: int | None
"""
if self.ptr.duration != lib.AV_NOPTS_VALUE:
return self.ptr.duration
@property
def frames(self):
"""
The number of frames this stream contains.
Returns ``0`` if it is not known.
:type: int
"""
return self.ptr.nb_frames
@property
def language(self):
"""
The language of the stream.
:type: str | None
"""
return self.metadata.get("language")
@property
def disposition(self):
return Disposition(self.ptr.disposition)
@property
def type(self):
"""
The type of the stream.
:type: Literal["audio", "video", "subtitle", "data", "attachment"]
"""
return lib.av_get_media_type_string(self.ptr.codecpar.codec_type)
| 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 |
|