Skip to content
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
6 changes: 3 additions & 3 deletions src/torchcodec/_core/Encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ void VideoEncoder::initializeEncoder(
// TODO-VideoEncoder: Remove assumption that tensor in NCHW format
auto sizes = frames_.sizes();
inPixelFormat_ = AV_PIX_FMT_GBRP;
inHeight_ = sizes[2];
inWidth_ = sizes[3];
inHeight_ = static_cast<int>(sizes[2]);
inWidth_ = static_cast<int>(sizes[3]);

// Use specified dimensions or input dimensions
// TODO-VideoEncoder: Allow height and width to be set
Expand Down Expand Up @@ -664,7 +664,7 @@ void VideoEncoder::encode() {
getFFMPEGErrorStringFromErrorCode(status));

AutoAVPacket autoAVPacket;
int numFrames = frames_.sizes()[0];
int numFrames = static_cast<int>(frames_.sizes()[0]);
for (int i = 0; i < numFrames; ++i) {
torch::Tensor currFrame = frames_[i];
UniqueAVFrame avFrame = convertTensorToAVFrame(currFrame, i);
Expand Down
12 changes: 11 additions & 1 deletion src/torchcodec/_core/Encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ class VideoEncoder {
public:
~VideoEncoder();

// Rule of Five requires that we define copy and move
// constructors and assignment operators.
// Both are deleted because we have unique_ptr members
VideoEncoder(const VideoEncoder&) = delete;
VideoEncoder& operator=(const VideoEncoder&) = delete;

// Move assignment operator deleted since we have a const member
VideoEncoder(VideoEncoder&&) = default;
VideoEncoder& operator=(VideoEncoder&&) = delete;

VideoEncoder(
const torch::Tensor& frames,
int frameRate,
Expand All @@ -143,7 +153,7 @@ class VideoEncoder {

UniqueEncodingAVFormatContext avFormatContext_;
UniqueAVCodecContext avCodecContext_;
int streamIndex_;
int streamIndex_ = -1;
UniqueSwsContext swsContext_;

const torch::Tensor frames_;
Expand Down
Loading