Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Investigate FFmpeg7 issues #189

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
16 changes: 16 additions & 0 deletions src/libspdl/core/detail/ffmpeg/ctx_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 11 additions & 5 deletions tests/spdl_unittest/io/async_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading