From e23998447667b551bd705d4ccf40f89461a89eb3 Mon Sep 17 00:00:00 2001 From: moto <855818+mthrok@users.noreply.github.com> Date: Thu, 22 Aug 2024 18:30:37 -0400 Subject: [PATCH 1/2] stash --- src/libspdl/core/detail/ffmpeg/ctx_utils.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libspdl/core/detail/ffmpeg/ctx_utils.cpp b/src/libspdl/core/detail/ffmpeg/ctx_utils.cpp index 87fa31df..40ddcf6a 100644 --- a/src/libspdl/core/detail/ffmpeg/ctx_utils.cpp +++ b/src/libspdl/core/detail/ffmpeg/ctx_utils.cpp @@ -128,10 +128,26 @@ AVFormatInputContextPtr get_input_format_ctx( src ? av_error(errnum, "Failed to open the input: {}", src) : av_error(errnum, "Failed to open custom input.")); } + + for (int i = 0; i < fmt_ctx->nb_streams; ++i) { + LOG(INFO) << "@@@ av_dump_format, stream: " << i; + av_dump_format(fmt_ctx, i, src, 0); + + auto s = fmt_ctx->streams[i]; + LOG(INFO) << fmt::format( + "stream index: {}\n" + "width: {}\n" + "height: {}\n", + s->index, + s->codecpar->width, + s->codecpar->height); + } + // Now pass down the responsibility of resource clean up to RAII. AVFormatInputContextPtr ret{fmt_ctx}; check_empty(option); + return ret; } From 2e638e46557608ef63ad93a49105716a0be77a03 Mon Sep 17 00:00:00 2001 From: moto <855818+mthrok@users.noreply.github.com> Date: Thu, 22 Aug 2024 18:31:49 -0400 Subject: [PATCH 2/2] simplify test --- tests/spdl_unittest/io/async_test.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/spdl_unittest/io/async_test.py b/tests/spdl_unittest/io/async_test.py index b203c907..32d72b63 100644 --- a/tests/spdl_unittest/io/async_test.py +++ b/tests/spdl_unittest/io/async_test.py @@ -110,12 +110,18 @@ def test_decode_video_clips(get_sample): N = 10 async def _test(): - timestamps = [(i, i + 1) for i in range(N)] demuxer = spdl.io.Demuxer(sample.path) - arrays = await _test_async_decode(demuxer.demux_video, timestamps) - assert len(arrays) == N - for i, arr in enumerate(arrays): - print(i, arr.shape, arr.dtype) + print(demuxer) + for n in range(N): + timestamp = (n, n + 1) + packets = demuxer.demux_video((n, n+1)) + print(packets) + frames = await spdl.io.async_decode_packets(packets) + print(frames) + buffer = await spdl.io.async_convert_frames(frames) + print(buffer) + arr = spdl.io.to_numpy(buffer) + print(arr.shape, arr.dtype) assert arr.shape == (25, 240, 320, 3) assert arr.dtype == np.uint8