Open prabhat00155 opened 3 years ago
Did you eventually solve it?
Did you eventually solve it?
No
Looks like you are building against ffmpeg 5 instead of ffmpeg 4. Encountered the same issue on macOS (see https://github.com/dmlc/decord/issues/203).
In case anyone's interested, here's a git diff showing the changes required to build against the latest FFmpeg (tested):
diff --git a/src/video/ffmpeg/ffmpeg_common.h b/src/video/ffmpeg/ffmpeg_common.h
index b0b973f..f0f7316 100644
--- a/src/video/ffmpeg/ffmpeg_common.h
+++ b/src/video/ffmpeg/ffmpeg_common.h
@@ -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>
diff --git a/src/video/nvcodec/cuda_threaded_decoder.cc b/src/video/nvcodec/cuda_threaded_decoder.cc
index 62bc7ee..957a90d 100644
--- a/src/video/nvcodec/cuda_threaded_decoder.cc
+++ b/src/video/nvcodec/cuda_threaded_decoder.cc
@@ -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),
@@ -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
diff --git a/src/video/nvcodec/cuda_threaded_decoder.h b/src/video/nvcodec/cuda_threaded_decoder.h
index d7e6fcd..61958a1 100644
--- a/src/video/nvcodec/cuda_threaded_decoder.h
+++ b/src/video/nvcodec/cuda_threaded_decoder.h
@@ -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();
@@ -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_;
diff --git a/src/video/video_reader.cc b/src/video/video_reader.cc
index af4858d..99c9635 100644
--- a/src/video/video_reader.cc
+++ b/src/video/video_reader.cc
@@ -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;
To suppress the Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC
warning, you can find your SM number/Compute Capability on your GPU (e.g., 3090 Ti is 86) and include it like this:
cmake .. -DUSE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 -DCMAKE_BUILD_TYPE=Release
If you don't want to apply the patch yourself or having trouble with it, you can consider using my fork: https://github.com/zhanwenchen/decord
is the patch for ? it's still referencing the ffmpeg 4. sudo add-apt-repository ppa:savoury1/ffmpeg5
giving it a go with 5 now.
I was able to get decord working on my MacBook (arm 64) by installing and linking to FFMPG 4 instead of the default latest version. This removes the header file and library incompatibilities.
% brew install ffmpeg@4
This resulted in a successful install of version 4 with the following additional steps to be done next:
ffmpeg@4 is keg-only, which means it was not symlinked into /opt/homebrew, because this is an alternate version of another formula.
If you need to have ffmpeg@4 first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/ffmpeg@4/bin:$PATH"' >> ~/.zshrc
(if you are using bash, then change above in your bash .profile
For compilers to find ffmpeg@4 you may need to set: export LDFLAGS="-L/opt/homebrew/opt/ffmpeg@4/lib" export CPPFLAGS="-I/opt/homebrew/opt/ffmpeg@4/include"
For pkg-config to find ffmpeg@4 you may need to set: export PKG_CONFIG_PATH="/opt/homebrew/opt/ffmpeg@4/lib/pkgconfig"
% source ~/.zshrc
cd decord (go to the build folder instead your local git repo'ed folder) and remove the old build dir
rm -r build
mkdir build
cd build
% cmake -DFFMPEG=/opt/homebrew/opt/ffmpeg@4 -DFFMPEG_INCLUDE_DIR=/opt/homebrew/opt/ffmpeg@4/include -DFFMPEG_LIBRARY_DIR=/opt/homebrew/opt/ffmpeg@4/lib ..
I am getting errors when I do
make
. I've built ffmpeg from source(with GPU support).Following is the result of cmake:
Versions: