Skip to content

Commit

Permalink
Fix for ffmpeg v5 (and maybe in the mean time mac and/or python 3.10)
Browse files Browse the repository at this point in the history
  • Loading branch information
schallerala committed Jul 27, 2022
1 parent 6288864 commit b0acac9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/video/ffmpeg/ffmpeg_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
extern "C" {
#endif
#include <libavcodec/avcodec.h>
#include <libavcodec/bsf.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
#include <libavfilter/avfilter.h>
Expand Down Expand Up @@ -251,13 +252,13 @@ class AVIOBytesContext {
bd_.size = data_.size();
bd_.file_size = bd_.size;

ctx_ = avio_alloc_context(buffer, buffer_size, 0, &bd_,
ctx_ = avio_alloc_context(buffer, buffer_size, 0, &bd_,
&AVIOBytesContext::read, 0, &AVIOBytesContext::seek);
if (!ctx_) {
LOG(WARNING) << "Unable to allocate AVIOContext!";
return;
}

}

~AVIOBytesContext() {
Expand Down
4 changes: 2 additions & 2 deletions src/video/nvcodec/cuda_threaded_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace decord {
namespace cuda {
using namespace runtime;

CUThreadedDecoder::CUThreadedDecoder(int device_id, AVCodecParameters *codecpar, AVInputFormat *iformat)
CUThreadedDecoder::CUThreadedDecoder(int device_id, AVCodecParameters *codecpar, const AVInputFormat *iformat)
: device_id_(device_id), stream_({device_id, false}), device_{}, ctx_{}, parser_{}, decoder_{},
pkt_queue_{}, frame_queue_{},
run_(false), frame_count_(0), draining_(false),
Expand Down Expand Up @@ -70,7 +70,7 @@ CUThreadedDecoder::CUThreadedDecoder(int device_id, AVCodecParameters *codecpar,
}
}

void CUThreadedDecoder::InitBitStreamFilter(AVCodecParameters *codecpar, AVInputFormat *iformat) {
void CUThreadedDecoder::InitBitStreamFilter(AVCodecParameters *codecpar, const AVInputFormat *iformat) {
const char* bsf_name = nullptr;
if (AV_CODEC_ID_H264 == codecpar->codec_id) {
// H.264
Expand Down
4 changes: 2 additions & 2 deletions src/video/nvcodec/cuda_threaded_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CUThreadedDecoder final : public ThreadedDecoderInterface {
using FrameOrderQueuePtr = std::unique_ptr<FrameOrderQueue>;

public:
CUThreadedDecoder(int device_id, AVCodecParameters *codecpar, AVInputFormat *iformat);
CUThreadedDecoder(int device_id, AVCodecParameters *codecpar, const AVInputFormat *iformat);
void SetCodecContext(AVCodecContext *dec_ctx, int width = -1, int height = -1, int rotation = 0);
bool Initialized() const;
void Start();
Expand All @@ -70,7 +70,7 @@ class CUThreadedDecoder final : public ThreadedDecoderInterface {
void LaunchThreadImpl();
void RecordInternalError(std::string message);
void CheckErrorStatus();
void InitBitStreamFilter(AVCodecParameters *codecpar, AVInputFormat *iformat);
void InitBitStreamFilter(AVCodecParameters *codecpar, const AVInputFormat *iformat);

int device_id_;
CUStream stream_;
Expand Down
4 changes: 2 additions & 2 deletions src/video/video_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ VideoReader::~VideoReader(){

void VideoReader::SetVideoStream(int stream_nb) {
if (!fmt_ctx_) return;
AVCodec *dec;
const AVCodec *dec;
int st_nb = av_find_best_stream(fmt_ctx_.get(), AVMEDIA_TYPE_VIDEO, stream_nb, -1, &dec, 0);
// LOG(INFO) << "find best stream: " << st_nb;
CHECK_GE(st_nb, 0) << "ERROR cannot find video stream with wanted index: " << stream_nb;
Expand Down Expand Up @@ -427,7 +427,7 @@ NDArray VideoReader::NextFrameImpl() {
break;
} else {
if (rewind_offset > REWIND_RETRY_MAX) {
LOG(FATAL) << "[" << filename_ << "]Unable to handle EOF because the video might have corrupted frames"
LOG(FATAL) << "[" << filename_ << "]Unable to handle EOF because the video might have corrupted frames"
<< "and `DECORD_REWIND_RETRY_MAX=" << REWIND_RETRY_MAX << "`. You may override the limit by `export DECORD_REWIND_RETRY_MAX=32`"
<< " for example to allow more auto-substituded frames, exit...";
}
Expand Down

0 comments on commit b0acac9

Please sign in to comment.