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

Align DecodedOutput with BatchDecodedOutput #458

Merged
merged 5 commits into from
Jan 21, 2025
Merged
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 src/torchcodec/decoders/_core/VideoDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,10 +872,8 @@ VideoDecoder::DecodedOutput VideoDecoder::convertAVFrameToDecodedOutput(
output.streamIndex = streamIndex;
auto& streamInfo = streams_[streamIndex];
TORCH_CHECK(streamInfo.stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO);
output.pts = frame->pts;
output.ptsSeconds =
ptsToSeconds(frame->pts, formatContext_->streams[streamIndex]->time_base);
output.duration = getDuration(frame);
output.durationSeconds = ptsToSeconds(
getDuration(frame), formatContext_->streams[streamIndex]->time_base);
// TODO: we should fold preAllocatedOutputTensor into RawDecodedOutput.
Expand Down
4 changes: 0 additions & 4 deletions src/torchcodec/decoders/_core/VideoDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,8 @@ class VideoDecoder {
// The stream index of the decoded frame. Used to distinguish
// between streams that are of the same type.
int streamIndex;
// The presentation timestamp of the decoded frame in time base.
int64_t pts;
// The presentation timestamp of the decoded frame in seconds.
double ptsSeconds;
// The duration of the decoded frame in time base.
int64_t duration;
// The duration of the decoded frame in seconds.
double durationSeconds;
};
Expand Down
2 changes: 0 additions & 2 deletions test/decoders/VideoDecoderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,10 @@ TEST_P(VideoDecoderTest, ReturnsFirstTwoFramesOfVideo) {
torch::Tensor tensor0FromOurDecoder = output.frame;
EXPECT_EQ(tensor0FromOurDecoder.sizes(), std::vector<long>({3, 270, 480}));
EXPECT_EQ(output.ptsSeconds, 0.0);
EXPECT_EQ(output.pts, 0);
output = ourDecoder->getNextFrameNoDemux();
torch::Tensor tensor1FromOurDecoder = output.frame;
EXPECT_EQ(tensor1FromOurDecoder.sizes(), std::vector<long>({3, 270, 480}));
EXPECT_EQ(output.ptsSeconds, 1'001. / 30'000);
EXPECT_EQ(output.pts, 1001);

torch::Tensor tensor0FromFFMPEG =
readTensorFromDisk("nasa_13013.mp4.stream3.frame000000.pt");
Expand Down
Loading