Skip to content
Closed
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
2 changes: 0 additions & 2 deletions av/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


def main():

parser = argparse.ArgumentParser()
parser.add_argument("--codecs", action="store_true")
parser.add_argument("--version", action="store_true")
Expand All @@ -11,7 +10,6 @@ def main():
# ---

if args.version:

import av
import av._core

Expand Down
12 changes: 12 additions & 0 deletions av/container/input.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ cdef class InputContainer(Container):
if self.ptr.start_time != lib.AV_NOPTS_VALUE:
return self.ptr.start_time

property start_time_realtime:
"""
Start time of the RTSP stream, expressed as microseconds since the UNIX epoch.

This property might not be set by FFmpeg for the first packets.

:type: int
"""
def __get__(self):
if self.ptr.start_time_realtime != lib.AV_NOPTS_VALUE:
return self.ptr.start_time_realtime

property duration:
def __get__(self):
if self.ptr.duration != lib.AV_NOPTS_VALUE:
Expand Down
2 changes: 0 additions & 2 deletions av/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


def iter_data_dirs(check_writable=False):

try:
yield os.environ["PYAV_TESTDATA_DIR"]
except KeyError:
Expand Down Expand Up @@ -45,7 +44,6 @@ def iter_data_dirs(check_writable=False):


def cached_download(url, name):

"""Download the data at a URL, and cache it under the given name.

The file is stored under `pyav/test` with the given name in the directory
Expand Down
1 change: 1 addition & 0 deletions include/libavformat/avformat.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ cdef extern from "libavformat/avformat.h" nogil:

int flags
int64_t max_analyze_duration
int64_t start_time_realtime

void *opaque

Expand Down
28 changes: 28 additions & 0 deletions tests/test_rtspstarttimerealtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import av

from .common import TestCase


# RTSP stream server, thanks https://github.com/rtspstream
RTSP_STREAM = "rtsp://rtsp.stream/pattern"
UNIX_TIMESTAMP_2022_01_01_00_00 = 1640995200000000 # microseconds


class TestRTSPStartTimeRealtime(TestCase):
def test_rtsp_start_time_realtime(self):
stream_options = {
'rtsp_transport': 'tcp', # preferred stable connection
'stimeout': '5000000' # socket timeout to 5s (default is unlimited)
}
with av.open(RTSP_STREAM, mode="r", options=stream_options) as container:
# wait for proper value set by RTSP in libavformat
while container.demux(container.streams.video[0]):
# it is okay to have None type at first dozens packets
if container.start_time_realtime is None:
continue
# Now value is ready, check this and go outside loop
else:
self.assertIsInstance(container.start_time_realtime, int)
break

self.assertGreater(container.start_time_realtime, UNIX_TIMESTAMP_2022_01_01_00_00)