Skip to content

Commit a7faca0

Browse files
author
Daniel Flores
committed
check LIBAVCODEC version
1 parent a17b466 commit a7faca0

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/torchcodec/_core/Encoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ torch::Tensor validateSamples(const torch::Tensor& samples) {
3434

3535
void validateSampleRate(const AVCodec& avCodec, int sampleRate) {
3636
const int* supportedSampleRates = nullptr;
37-
#if LIBAVFILTER_VERSION_MAJOR >= 10 // FFmpeg >= 7
37+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 13, 100)
3838
int numSampleRates = 0;
3939
int ret = avcodec_get_supported_config(
4040
nullptr,
@@ -92,7 +92,7 @@ static const std::vector<AVSampleFormat> preferredFormatsOrder = {
9292

9393
AVSampleFormat findBestOutputSampleFormat(const AVCodec& avCodec) {
9494
const AVSampleFormat* supportedSampleFormats = nullptr;
95-
#if LIBAVFILTER_VERSION_MAJOR >= 10 // FFmpeg >= 7
95+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 13, 100) // FFmpeg >= 7
9696
int numSampleFormats = 0;
9797
int ret = avcodec_get_supported_config(
9898
nullptr,

src/torchcodec/_core/FFMPEGCommon.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "src/torchcodec/_core/FFMPEGCommon.h"
88

99
#include <c10/util/Exception.h>
10-
#include <iostream>
1110

1211
namespace facebook::torchcodec {
1312

@@ -110,9 +109,8 @@ void setDefaultChannelLayout(UniqueAVFrame& avFrame, int numChannels) {
110109
}
111110

112111
void validateNumChannels(const AVCodec& avCodec, int numChannels) {
113-
#if LIBAVFILTER_VERSION_MAJOR >= 10 // FFmpeg >= 7
112+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 13, 100) // FFmpeg >= 7
114113
std::stringstream supportedNumChannels;
115-
std::cout << "ffmpeg7? " << std::endl;
116114
const AVChannelLayout* supported_layouts = nullptr;
117115
int num_layouts = 0;
118116
int ret = avcodec_get_supported_config(
@@ -158,7 +156,7 @@ void validateNumChannels(const AVCodec& avCodec, int numChannels) {
158156
}
159157
supportedNumChannels << avCodec.ch_layouts[i].nb_channels;
160158
}
161-
#else
159+
#else // FFmpeg <= 4
162160
if (avCodec.channel_layouts == nullptr) {
163161
// can't validate, same as above.
164162
return;

0 commit comments

Comments
 (0)