Skip to content

Commit b96bd56

Browse files
author
Daniel Flores
committed
add commented suggestions
1 parent 08b5851 commit b96bd56

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/torchcodec/_core/Encoder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ torch::Tensor validateFrames(const torch::Tensor& frames) {
527527
frames.sizes()[1] == 3,
528528
"frame must have 3 channels (R, G, B), got ",
529529
frames.sizes()[1]);
530-
// TODO-VideoEncoder: Investigate if non-contiguous frames can be returned
530+
// TODO-VideoEncoder: Investigate if non-contiguous frames can be accepted
531531
return frames.contiguous();
532532
}
533533

@@ -593,9 +593,6 @@ void VideoEncoder::initializeEncoder(
593593
*desiredBitRate >= 0, "bit_rate=", *desiredBitRate, " must be >= 0.");
594594
}
595595
avCodecContext_->bit_rate = desiredBitRate.value_or(0);
596-
// TODO-VideoEncoder: Verify that frame_rate and time_base are correct
597-
avCodecContext_->time_base = {1, inFrameRate_};
598-
avCodecContext_->framerate = {inFrameRate_, 1};
599596

600597
// Store dimension order and input pixel format
601598
// TODO-VideoEncoder: Remove assumption that tensor in NCHW format
@@ -618,7 +615,9 @@ void VideoEncoder::initializeEncoder(
618615
avCodecContext_->width = outWidth_;
619616
avCodecContext_->height = outHeight_;
620617
avCodecContext_->pix_fmt = outPixelFormat_;
618+
// TODO-VideoEncoder: Verify that frame_rate and time_base are correct
621619
avCodecContext_->time_base = {1, inFrameRate_};
620+
avCodecContext_->framerate = {inFrameRate_, 1};
622621

623622
// TODO-VideoEncoder: Allow GOP size and max B-frames to be set
624623
if (videoStreamOptions.gopSize.has_value()) {
@@ -726,6 +725,7 @@ UniqueAVFrame VideoEncoder::convertTensorToAVFrame(
726725
// TODO-VideoEncoder: Reorder tensor if in NHWC format
727726
int channelSize = inHeight_ * inWidth_;
728727
// Reorder RGB -> GBR for AV_PIX_FMT_GBRP format
728+
// TODO-VideoEncoder: Determine if FFmpeg supports RGB input format directly
729729
inputFrame->data[0] = tensorData + channelSize;
730730
inputFrame->data[1] = tensorData + (2 * channelSize);
731731
inputFrame->data[2] = tensorData;

src/torchcodec/_core/Encoder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ class VideoEncoder {
140140
int frameIndex);
141141
void encodeFrame(AutoAVPacket& autoAVPacket, const UniqueAVFrame& avFrame);
142142
void flushBuffers();
143-
void close_avio();
144143

145144
UniqueEncodingAVFormatContext avFormatContext_;
146145
UniqueAVCodecContext avCodecContext_;

test/test_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ def test_bad_input(self, tmp_path):
12291229
class TestVideoEncoderOps:
12301230

12311231
def test_bad_input(self, tmp_path):
1232-
output_file = str(tmp_path / ".mp3")
1232+
output_file = str(tmp_path / ".mp4")
12331233

12341234
with pytest.raises(
12351235
RuntimeError, match="frames must have uint8 dtype, got float"

0 commit comments

Comments
 (0)